nyxx-stack/agent-skills/cli-builder
Claude Code and agent skill by nyxx-stack/agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Guide for building hyper-optimized, agent-native command-line interfaces that autonomous agents can discover, call, validate, retry, and audit. Use when creating or refactoring CLIs, command wrappers, scripts, developer tools, deployment tools, data tools, API CLIs, batch processors, or local tools intended primarily for AI agents rather than humans.
Install
npx vskill@latest install nyxx-stack/agent-skills/cli-builderSKILL.md
The same SKILL.md was published earlier as nyxx-stack/agent-skills/cli-builder.
Agent-Native CLI Builder
Prerequisites
Designed for agents with shell and filesystem access. The optional validator script (scripts/validate_agent_cli.py) requires Python 3.10+.
Overview
Build command-line interfaces for agents, not humans. Treat the CLI as a typed process-execution API: deterministic inputs, structured outputs, bounded context cost, explicit side effects, and self-describing contracts.
A high-quality agent CLI lets an agent:
- Discover capabilities without reading external docs.
- Construct valid commands without guessing.
- Preview mutation scope before execution.
- Parse every result and error deterministically.
- Retry safely when allowed.
- Produce audit artifacts a reviewer can inspect.
Primary quality metric: how reliably an agent can complete realistic tasks with low token use, low command count, no blocked prompts, no hidden state, and reviewable side effects.
Process
High-Level Workflow
Creating a high-quality agent CLI has five phases:
- Deep research and planning
- Contract design
- Implementation
- Review and test
- Agent evaluations
Phase 1: Deep Research and Planning
1.1 Understand agent-native CLI design
Design for autonomous execution:
Non-interactive by default: Never require TTY prompts, menus, password dialogs, confirmations, progress spinners, or animated output. Accept all inputs through flags, stdin, files, or environment variables. Fail fast if required input is missing.
Structured output first: Default to JSON for agent mode. If the CLI must preserve a human mode, expose --json and --quiet, and make agent workflows always use them. Data goes to stdout. Diagnostics, warnings, and progress go to stderr.
Introspection: Every CLI must expose machine-readable self-description:
--helpfor concise human-readable usage.--help-jsonorschemafor command schemas.capabilitiesfor supported operations, auth needs, risk levels, and examples.versionfor CLI version, schema version, and feature flags.
Explicit scope: Mutating commands must require scope flags such as --file, --dir, --resource-id, --project, --env, or --account. If scope is ambiguous, fail closed.
Plan before mutation: Destructive, external, batch, billing, deployment, or data-writing commands must support --dry-run or a separate plan command. The plan must list intended side effects, touched resources, external calls, validations, and required confirmations.
Idempotent and retry-safe: Agents retry. Provide --idempotency-key, --operation-id, or natural idempotency semantics for writes. Return conflicts as typed errors, not ambiguous failures.
Bounded context cost: Default outputs must be compact and limited. Support --limit, --offset/--cursor, --fields, --summary, and --output FILE for large results. Avoid dumping large logs to stdout unless explicitly requested.
Typed errors: Error output must be structured, include an error code, explain what was expected, show what was received when safe, and provide the next action.
Auditability: Mutations should emit an artifact manifest with command intent, scope, plan, validations, final side effects, warnings, and output file paths.
Read references/agent-cli-best-practices.md for the full design contract.
1.2 Research the target situation
Before designing commands, inspect the task domain:
- Target users: agents only, or agents plus humans?
- Core tasks: read, search, validate, transform, mutate, deploy, monitor, audit.
- Data models: resources, identifiers, relationships, schema versions.
- Authentication: env vars, config files, keychains, cloud identities, service accounts.
- State model: local-only, remote API, long-running jobs, eventually consistent systems.
- Risk tiers: read-only, local write, remote write, destructive, money/legal/security impact.
- Failure modes: auth, permissions, missing scope, malformed input, rate limits, conflicts, partial success, timeouts.
- Output size: small records, paginated lists, logs, binary artifacts, reports.
- Agent environment: shell, filesystem, network availability, package manager, CI, sandbox limits.
Use web search and primary documentation for any current API, dependency, platform, or standard. Do not rely on memory for version-sensitive details.
1.3 Decide CLI shape
Default shape for new CLIs:
For domain operations, use action-oriented subcommands:
Prefer comprehensive primitive operations plus a few high-value workflow commands. Primitive commands give agents composability; workflow commands reduce repeated multi-step command sequences. When uncertain, implement safe primitives first, then add workflows only after real evals show repeated friction.
See references/architecture-patterns.md for command archetypes.
1.4 Choose implementation stack
Default stack when constraints are unknown:
- Python 3.10+ with
argparse,json,dataclasses, and no required external packages. - Add Pydantic/Typer only if the project already accepts dependencies and needs richer validation.
- Use TypeScript with Commander/Zod when the target ecosystem is Node/TypeScript.
- Use Rust with clap/serde when single-binary distribution, startup time, or high-throughput parsing dominates.
Do not pick a stack because it is fashionable. Pick the smallest stack that can enforce schemas, produce deterministic output, and test non-interactivity.
See references/implementation-guides.md for templates.
Phase 2: Contract Design
2.1 Write the CLI contract before code
Create a contract document with:
- CLI name and version.
- Global flags.
- Command list.
- Required/optional arguments.
- Input schema for each command.
- Output schema for each command.
- Error codes.
- Exit codes.
- Risk tier per command.
- Dry-run behavior.
- Idempotency behavior.
- Pagination behavior.
- Artifact outputs.
- Auth/environment requirements.
- Examples using JSON/stdin/files.
2.2 Global flags
Include these unless the situation proves they are unnecessary:
Avoid ambiguous positionals except obvious input paths. Prefer long flag names over short flags.
2.3 Output envelopes
Success envelope:
Error envelope:
JSONL streaming event:
Use the schemas in assets/agent_cli_contract.schema.json and assets/error_envelope.schema.json.
2.4 Exit codes
Document exit codes in --help and --help-json.
Recommended mapping:
| Code | Meaning | |
|---|---|---|
| 0 | success | |
| 1 | runtime/internal error | |
| 2 | invalid arguments or malformed input | |
| 3 | validation failed | |
| 4 | resource not found | |
| 5 | authentication missing/invalid | |
| 6 | authorization denied | |
| 7 | conflict/already exists/stale state | |
| 8 | rate limited | |
| 9 | timeout | |
| 10 | external dependency unavailable | |
| 11 | unsafe operation blocked | |
| 12 | partial success; inspect data.failures |
Avoid using shell-reserved meanings such as command-not-found or permission-denied codes for application semantics.
2.5 Safety model
Risk tiers:
Rules:
read_only: may execute directly.local_write: require explicit output path or scope.remote_write: require--dry-runsupport and explicit scope.destructive: require--dry-run,--confirm, and typed audit artifact.regulated: require all destructive controls plus provenance, review artifacts, and conservative defaults.
Phase 3: Implementation
3.1 Project structure
Recommended structure:
3.2 Core infrastructure
Implement shared utilities before domain commands:
- Envelope builder for success/error JSON.
- Error-code registry.
- Exit-code registry.
- Schema validation.
- JSON/JSONL writer.
- Stderr diagnostic writer.
- Pagination helpers.
- Timeout handling.
- Auth loader with explicit missing-auth errors.
- Dry-run plan model.
- Audit artifact writer.
- Idempotency key handling.
- Deterministic sorting and stable timestamps.
3.3 Command implementation rules
For each command:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cli-builder/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 3
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/nyxx-stack/agent-skills/cli-builder)