| name | oclif-json-and-errors |
| description | Design stable oclif command output contracts with clean --json stdout, stderr diagnostics, and structured error codes. Use when defining plugin command output, exit behavior, or automation-facing error handling during the catalog reducer migration. |
Oclif JSON and Errors
Use this skill when shaping command UX or output contracts for the future plugin layer around the catalog reducer.
When to use
- Adding a new plugin command or migration wrapper.
- Changing
--json output shape.
- Handling partial failures where automation still needs machine-readable details.
- Standardizing exit codes and error messages.
Core rules
- Keep
--json output machine-safe.
- Keep human status logs out of JSON payloads.
- Prefer stable error codes for scriptability.
- Use one predictable schema per command mode.
Recommended pattern
- Build a typed response object first.
- Print JSON exactly once in
--json mode.
- Emit human-friendly logs only in non-JSON mode.
- On failure, include actionable context and a stable
code in this.error().
Repo guidance
- Do not invent a public JSON contract for the reducer until the plugin command surface is explicitly defined.
- When a plugin wrapper is introduced, keep JSON payloads stable per command and separate human logs from machine output.
- For total-failure batch operations, keep actionable error details available before exiting non-zero.
Checklist
References