CLI Spec (Implementation-Grade)
Note: The current year is 2026. Use this when dating specification artifacts.
ce-spec defines system contracts. cli-spec defines the CLI Implementation Contract (command trees, JSON schemas, dry-run plans, and safety gates).
This skill produces a technical contract at docs/cli-specs/. It does not produce implementation code.
Table of Contents
Working agreement
- Specification answers WHAT the CLI owns, how it behaves in dual-mode (Human/Agent), and how correctness is verified.
- Use the most authoritative source; do not invent behavior that belongs in a parent product spec.
- Prefer the smallest spec that removes ambiguity; scope to one tool or 3-5 tightly coupled commands.
- Leave a written artifact in
docs/cli-specs/ for substantial work.
- Every acceptance criterion must have a stable
CA ID (e.g., CA1, CA2).
When to use
Use this skill when you need a binding technical design for a CLI before planning or coding begins.
Primary triggers:
- "Create an implementation-grade CLI spec for [context]."
- "Turn this brainstorm into a formal CLI contract."
- "Refactor this legacy CLI into a Gold Standard 2026 interface."
- "Define the command tree, JSON schema, and safety gates for [tool]."
Inputs
- Source: A brainstorm path, feature description, or legacy tool definition.
- Audience: Human-first, Agent-first, or Dual-mode hybrid.
- Constraints: Secret handling requirements, platform limits, and ecosystem (Rust, Go, etc.).
Outputs
- Technical Contract: A markdown file in
docs/cli-specs/ following the schema_version: 1 standard.
- CA Matrix: A set of stable CLI Acceptance IDs for verification.
- JSON Schemas: Machine-readable definitions for all command outputs.
Workflow
Phase 1: Local Grounding
Research existing CLI patterns in the repository to ensure consistency.
- Use
repo-research-analyst to find similar tools.
- Check
references/cli-guidelines.md for local standards.
- Consult
assets/cli-spec.png for the canonical command tree layout.
Phase 2: Build the Contract
Draft the technical specification. Ensure the document answers:
- Strategic Alignment: Problem statement and audience goals.
- Command Model: The
<topic> <action> hierarchy.
- Type-Safe Signatures: TypeScript-style help declarations.
- Response Envelope: The
CallResult JSON contract (trace_id, status, errors).
- Safety Spec: Detailed
--dry-run behavior and plan schema.
- Acceptance Matrix: Sequential
CA IDs for happy and failure paths.
Phase 3: Write the Artifact
Save the spec to docs/cli-specs/YYYY-MM-DD-<name>-cli-spec.md. Use the canonical frontmatter from references/cli-spec-artifacts.md.
Artifact contracts
- Standard Path:
docs/cli-specs/YYYY-MM-DD-<tool-name>-cli-spec.md
- Stable IDs: Use
CA1, CA2 for all verification items.
- Output: Must include a JSON schema for all machine-readable endpoints.
Validation and Gates
Fail fast: stop at first failed gate and do not proceed. Review the detailed contracts before claiming completion:
references/contract.yaml
references/evals.yaml
references/gold-standard-2026.md
references/cli-spec-artifacts.md
references/advanced-patterns-2026.md
references/lifecycle-and-errors-2026.md
Run these checks:
python3 scripts/diagnose_skill.py backend/cli-spec
python3 utilities/skill-builder/scripts/quick_validate.py backend/cli-spec --mode strict
Philosophy
- Predictability beats Cleverness: A command should be deterministic.
- The "Plan" Pattern: Always show what would happen before changing state.
- Agent-Native DX: Structured data is a first-class requirement, not an export option.
Constraints
- Absolute Paths: Do not use absolute paths from your local machine in examples.
- Redaction: Always redact secrets, API keys, or PII when providing sample outputs or logs.
- Scope: Do not implement logic; stay focused on the interface contract.
Anti-patterns
- God Commands: Overloading a single command with too many flags.
- Regex-Parsing: Forcing users to parse text output instead of providing JSON.
- Vague Errors: Returning non-zero exit codes without a machine-readable error object.
Examples
- When the user asks: "I need an implementation-grade spec for a CLI that manages our S3 bucket permissions. Save it to docs."
- When the user says: "Refactor the
mcporter command tree into a formal CLI contract with CA IDs and JSON schemas."
- When the user asks: "Create a Gold Standard 2026 spec for a new internal tool called 'vault-sync'."
Response format
Use these headings in order:
## Strategic alignment (Confirming Gold Standard goals)
## Command model (The <topic> <action> tree)
## Type-safe Signatures (TypeScript-style help)
## Response Envelope and Exits (The CallResult contract)
## Safety and Dry-run spec
## Verification checklist (CA IDs)
Required inputs
- Tool name, primary ecosystem (e.g., Rust, Go, Node), and target audience.
- Interaction Model: human, agent, or dual-mode hybrid.
- Data Flow: inbound (args, stdin, files) and outbound (structured JSON, logs, exit codes).
- Security Posture: secret management requirements and isolation levels.
- Maturity Level: prototype or production-grade "Gold" CLI.
Deliverables
- Command Hierarchy: logical
<topic> <action> tree.
- Flags & Schema: comprehensive table with type-safety and defaults.
- Output Contract: JSON schema, field masking, and
next_steps metadata.
- Failure Model: semantic exit codes and machine-readable error objects.
- Safety Spec: dry-run behavior and confirmation gates.
Failure mode
- If required inputs are incomplete, stop and request clarification before proceeding.
- If the CLI design conflicts with established project patterns, flag this explicitly and suggest alternatives.
- If safety gates cannot be met, do not proceed with the spec.
Gotchas
- Absolute Paths: Never use absolute paths from your local machine in examples.
- Secret Redaction: Always redact secrets, API keys, or PII in sample outputs.
- NO_COLOR Standard: Respect the
NO_COLOR environment variable standard in all output examples.
See Also
| Skill |
When to use together |
| [[ce-spec]] |
Use when the CLI is a front for a broader system spec |
| [[agent-native-architecture]] |
Ensure the CLI fits into an autonomous workflow |
| [[docs-expert]] |
Generate user-facing docs from the technical contract |
Topic map: [[backend-platform]]
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: cli-spec3description: Create an implementation-grade CLI specification when the user requests a binding technical contract for a new or existing command-line interface. Use when this capability is needed.4---56# CLI Spec (Implementation-Grade)78**Note: The current year is 2026.** Use this when dating specification artifacts.910`ce-spec` defines system contracts. `cli-spec` defines the **CLI Implementation Contract** (command trees, JSON schemas, dry-run plans, and safety gates).1112This skill produces a technical contract at `docs/cli-specs/`. It does **not** produce implementation code.1314## Table of Contents15- [Working agreement](#working-agreement)16- [When to use](#when-to-use)17- [Inputs](#inputs)18- [Outputs](#outputs)19- [Workflow](#workflow)20- [Artifact contracts](#artifact-contracts)21- [Validation and Gates](#validation-and-gates)22- [Philosophy](#philosophy)23- [Constraints](#constraints)24- [Anti-patterns](#anti-patterns)25- [Examples](#examples)26- [Response format](#call-signature)27- [See Also](#see-also)2829## Working agreement30- Specification answers **WHAT** the CLI owns, how it behaves in dual-mode (Human/Agent), and how correctness is verified.31- Use the most authoritative source; do not invent behavior that belongs in a parent product spec.32- Prefer the smallest spec that removes ambiguity; scope to one tool or 3-5 tightly coupled commands.33- Leave a written artifact in `docs/cli-specs/` for substantial work.34- Every acceptance criterion must have a stable **`CA`** ID (e.g., `CA1`, `CA2`).3536## When to use37Use this skill when you need a binding technical design for a CLI before planning or coding begins.3839Primary triggers:40- "Create an implementation-grade CLI spec for [context]."41- "Turn this brainstorm into a formal CLI contract."42- "Refactor this legacy CLI into a Gold Standard 2026 interface."43- "Define the command tree, JSON schema, and safety gates for [tool]."4445## Inputs46- **Source:** A brainstorm path, feature description, or legacy tool definition.47- **Audience:** Human-first, Agent-first, or Dual-mode hybrid.48- **Constraints:** Secret handling requirements, platform limits, and ecosystem (Rust, Go, etc.).4950## Outputs51- **Technical Contract:** A markdown file in `docs/cli-specs/` following the `schema_version: 1` standard.52- **CA Matrix:** A set of stable CLI Acceptance IDs for verification.53- **JSON Schemas:** Machine-readable definitions for all command outputs.5455## Workflow5657### Phase 1: Local Grounding58Research existing CLI patterns in the repository to ensure consistency.59- Use `repo-research-analyst` to find similar tools.60- Check `references/cli-guidelines.md` for local standards.61- Consult `assets/cli-spec.png` for the canonical command tree layout.6263### Phase 2: Build the Contract64Draft the technical specification. Ensure the document answers:65- **Strategic Alignment:** Problem statement and audience goals.66- **Command Model:** The `<topic> <action>` hierarchy.67- **Type-Safe Signatures:** TypeScript-style help declarations.68- **Response Envelope:** The `CallResult` JSON contract (trace_id, status, errors).69- **Safety Spec:** Detailed `--dry-run` behavior and plan schema.70- **Acceptance Matrix:** Sequential `CA` IDs for happy and failure paths.7172### Phase 3: Write the Artifact73Save the spec to `docs/cli-specs/YYYY-MM-DD-<name>-cli-spec.md`. Use the canonical frontmatter from `references/cli-spec-artifacts.md`.7475## Artifact contracts76- **Standard Path:** `docs/cli-specs/YYYY-MM-DD-<tool-name>-cli-spec.md`77- **Stable IDs:** Use `CA1`, `CA2` for all verification items.78- **Output:** Must include a JSON schema for all machine-readable endpoints.7980## Validation and Gates81Fail fast: stop at first failed gate and do not proceed. Review the detailed contracts before claiming completion:82- `references/contract.yaml`83- `references/evals.yaml`84- `references/gold-standard-2026.md`85- `references/cli-spec-artifacts.md`86- `references/advanced-patterns-2026.md`87- `references/lifecycle-and-errors-2026.md`8889Run these checks:90```bash91python3 scripts/diagnose_skill.py backend/cli-spec92python3 utilities/skill-builder/scripts/quick_validate.py backend/cli-spec --mode strict93```9495## Philosophy96- **Predictability beats Cleverness:** A command should be deterministic.97- **The "Plan" Pattern:** Always show what *would* happen before changing state.98- **Agent-Native DX:** Structured data is a first-class requirement, not an export option.99100## Constraints101- **Absolute Paths:** Do not use absolute paths from your local machine in examples.102- **Redaction:** Always redact secrets, API keys, or PII when providing sample outputs or logs.103- **Scope:** Do not implement logic; stay focused on the interface contract.104105## Anti-patterns106- **God Commands:** Overloading a single command with too many flags.107- **Regex-Parsing:** Forcing users to parse text output instead of providing JSON.108- **Vague Errors:** Returning non-zero exit codes without a machine-readable error object.109110## Examples111- **When the user asks:** "I need an implementation-grade spec for a CLI that manages our S3 bucket permissions. Save it to docs."112- **When the user says:** "Refactor the `mcporter` command tree into a formal CLI contract with `CA` IDs and JSON schemas."113- **When the user asks:** "Create a Gold Standard 2026 spec for a new internal tool called 'vault-sync'."114115## Response format116Use these headings in order:1171. `## Strategic alignment` (Confirming Gold Standard goals)1182. `## Command model` (The `<topic> <action>` tree)1193. `## Type-safe Signatures` (TypeScript-style help)1204. `## Response Envelope and Exits` (The `CallResult` contract)1215. `## Safety and Dry-run spec`1226. `## Verification checklist (CA IDs)`123124## Required inputs125- Tool name, primary ecosystem (e.g., Rust, Go, Node), and target audience.126- Interaction Model: human, agent, or dual-mode hybrid.127- Data Flow: inbound (args, stdin, files) and outbound (structured JSON, logs, exit codes).128- Security Posture: secret management requirements and isolation levels.129- Maturity Level: prototype or production-grade "Gold" CLI.130131## Deliverables132- Command Hierarchy: logical `<topic> <action>` tree.133- Flags & Schema: comprehensive table with type-safety and defaults.134- Output Contract: JSON schema, field masking, and `next_steps` metadata.135- Failure Model: semantic exit codes and machine-readable error objects.136- Safety Spec: dry-run behavior and confirmation gates.137138## Failure mode139- If required inputs are incomplete, stop and request clarification before proceeding.140- If the CLI design conflicts with established project patterns, flag this explicitly and suggest alternatives.141- If safety gates cannot be met, do not proceed with the spec.142143## Gotchas144- **Absolute Paths:** Never use absolute paths from your local machine in examples.145- **Secret Redaction:** Always redact secrets, API keys, or PII in sample outputs.146- **NO_COLOR Standard:** Respect the `NO_COLOR` environment variable standard in all output examples.147148## See Also149| Skill | When to use together |150|---|---|151| [[ce-spec]] | Use when the CLI is a front for a broader system spec |152| [[agent-native-architecture]] | Ensure the CLI fits into an autonomous workflow |153| [[docs-expert]] | Generate user-facing docs from the technical contract |154155**Topic map:** [[backend-platform]]156157---158> Converted and distributed by [TomeVault](https://tomevault.io/claim/jscraik) — claim your Tome and manage your conversions.159<!-- tomevault:4.0:skill_md:2026-04-13 -->