add-command
Skill15 starsChanged 6 days agoMITView on GitHub
This skill should be used when the user asks to "add a CLI command", "create a subcommand", "add a new command", or mentions "new CLI command", "new subcommand", or "command-line tool". Provides scaffolding guidance for implementing a new CLI subcommand with argument parsing, validation, and tests.
12 other projects use a version of this.
Adopted by
Most recently taken up by
- M0xoo/wisptheir own version, first seen Nov 29, 2026
- WispAgents/wisptheir own version, first seen Nov 29, 2026
- Doist/todoist-clitheir own version, first seen Nov 27, 2026
- AdamAkhlaq/agent-utilstheir own version, first seen Nov 22, 2026
- todoist/todoist-clitheir own version, first seen Nov 15, 2026
- coralogix/cx-clitheir own version, first seen Nov 8, 2026
Used with
Projects with it also use release.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MicrosoftSkillrelease
Use ONLY when the user explicitly asks to cut/publish a Huabu desktop release or tag a version. Performs an outward action — bumps the version in apps/desktop/package.json, commits + annotated-tags vX.Y.Z, and pushes the branch + tag. That tag push auto-builds the macOS/Windows installers and publishes a GitHub Release. Provides `status`, `bump`, `tag-push`, and a one-command `run` (bump → tag-push).
Also in 4 projects that use this
Other versions12 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 12
- redis/go-redis★ 22ksame name
- gitkraken/vscode-gitlens★ 10ksame name
- microsoft/vscode-cmake-tools★ 1.7ksame name
- Doist/todoist-cli★ 339same name
- todoist/todoist-cli★ 339same name
- coralogix/cx-cli★ 243same name
- ldayton/Dippy★ 243same name
- WispAgents/wisp★ 17same name
- rajdeepratan/SlashForge★ 6same name
- Doist/twist-cli★ 3same name
2 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- implement-sliceSkill
- write-tech-specSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. 0 are common, 15 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 9 edited versions we read keep these.
15
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Before writing any code:
- Very specific: line 16
Read the project's architecture decisions rule (.claude/rules/architecture.md) to verify active patterns and constraints
- Distinctive: line 22
Create the command definition using cobra conventions.
- Very specific: line 26
Place the command where existing commands live (e.g., cmd/, commands/, cli/)
- Distinctive: line 43
Default value (for optional flags)
- Distinctive: line 49
Write clear help text following these guidelines:
- Distinctive: line 81
Check file paths exist and are accessible (when applicable)
- Distinctive: line 119
Never read files, call APIs, or produce output directly from the pure function
- Distinctive: line 124
Create a thin executor that performs the side effects described by action objects.
- Distinctive: line 146
Test the pure logic function and input validation directly -- no mocks needed.
- Distinctive: line 176
Test the command end-to-end through the CLI interface.
- Distinctive: line 181
Verify stdout output matches expected format and content
- Distinctive: line 182
Verify stderr output for progress/error messages
- Distinctive: line 183
Verify exit codes: 0 for success, non-zero for each error category
- Distinctive: line 184
Test with real files (create temp files in test fixtures)
- Distinctive: line 185
Test piped input if the command supports stdin
- Distinctive: line 197
Before considering the command complete:
“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- Generated by dev-standards plugin. Customize as needed. -->Add CLI Subcommand
Scaffold a new CLI subcommand using cobra. Follow the side-effect isolation pattern: pure function for command logic, action objects for I/O operations.
Pre-Flight Checks
Before writing any code:
- Confirm the command name, arguments, flags, and purpose with the user
- Read the project's architecture decisions rule (
.claude/rules/architecture.md) to verify active patterns and constraints - Identify the existing command directory structure by examining neighboring commands
- Review the root command or command group this subcommand belongs to
Step 1 -- Define the Command
Create the command definition using cobra conventions.
Command Definition
- Place the command where existing commands live (e.g.,
cmd/,commands/,cli/) - Match the naming convention of neighboring commands
- Register the command with its parent command or root
Arguments and Flags
Define all inputs explicitly:
- Positional arguments: required values in a fixed order
- Required flags: named parameters that must be provided
- Optional flags: named parameters with sensible defaults
- Boolean flags: on/off toggles (default to false)
For each argument/flag, specify:
- Name (short form and long form for flags, e.g.,
-o,--output) - Type (string, int, bool, path, enum)
- Default value (for optional flags)
- Description (shown in help text)
- Validation rules (required, valid values, file must exist, etc.)
Help Text
Write clear help text following these guidelines:
- One-line description: what the command does (imperative form)
- Usage line showing required arguments and flags
- Examples section with at least two real-world invocations
- Long description if the command has non-obvious behavior
# Example help structure
command-name - Brief description of what this command does
Usage:
tool command-name [flags] <required-arg>
Examples:
tool command-name --output report.json data.csv
tool command-name --format table --verbose input/
Flags:
-o, --output string Output file path (default: stdout)
-f, --format string Output format: json, table, csv (default: json)
-v, --verbose Enable verbose outputStep 2 -- Validate Inputs
Validate all arguments and flags before executing logic.
Validation Guidelines
- Validate immediately after parsing, before any processing
- Return clear, actionable error messages (tell the user what to fix)
- Check file paths exist and are accessible (when applicable)
- Validate enum values against allowed options
- Validate numeric ranges
- Exit with non-zero status code on validation failure
Validation as Pure Function
# Pure function: validates parsed inputs, returns validated config or errors
validate_inputs(args, flags) -> ValidatedConfig | list[ValidationError]:
errors = []
check each constraint
return errors if any, else ValidatedConfigStep 3 -- Implement Command Logic (Pure Function)
Implement the core logic as a pure function that receives validated inputs and produces action objects.
Side-Effect Isolation Pattern
# Pure function: decides WHAT to do
compute_actions(validated_config, input_data) -> list[Action] | CommandError:
process input_data according to config
return actions describing output to write, API calls to make, etc.
# Action objects (plain data)
WriteFile(path, content)
PrintOutput(text, format)
HttpRequest(method, url, body)Logic Guidelines
- Accept only the validated configuration and any input data (already loaded)
- Return action objects describing all side effects
- Return typed errors for failure cases, not exceptions
- Never read files, call APIs, or produce output directly from the pure function
- Handle edge cases: empty input, large input, malformed data
Step 4 -- Implement the Executor
Create a thin executor that performs the side effects described by action objects.
Executor Guidelines
- One executor function that iterates over action objects and dispatches each
- Handle I/O errors at this layer (file write failures, network errors)
- Report progress to stderr (never stdout -- stdout is for command output)
- Exit with appropriate status codes (0 = success, 1 = general error, 2 = usage error)
# Executor: performs side effects
execute(actions) -> ExitCode:
for action in actions:
match action:
WriteFile: write file, handle permission errors
PrintOutput: write to stdout in requested format
HttpRequest: make request, handle timeout/errors
return exit_codeStep 5 -- Write Unit Tests for Command Logic
Test the pure logic function and input validation directly -- no mocks needed.
Test Cases to Cover
- Input validation: each valid input accepted, each invalid input rejected with clear error
- Happy path: valid config + valid data produces correct actions
- Edge cases: empty input, single item, maximum size, special characters
- Error handling: malformed data produces typed error, not crash
- Output formats: each supported format produces correct action objects
Test Structure
describe("validate_inputs")
it("accepts valid arguments and flags")
it("rejects missing required argument")
it("rejects invalid enum value for --format")
it("rejects negative value for --limit")
describe("compute_actions for process-data")
it("returns WriteFile action with correct content for JSON format")
it("returns PrintOutput action for table format")
it("returns error when input data is empty")
it("handles large input without excessive memory use")Run with: tman run -- go test ./internal/cli/...
Step 6 -- Write Integration Tests
Test the command end-to-end through the CLI interface.
Integration Test Guidelines
- Invoke the command as a subprocess or through cobra's test utilities
- Verify stdout output matches expected format and content
- Verify stderr output for progress/error messages
- Verify exit codes: 0 for success, non-zero for each error category
- Test with real files (create temp files in test fixtures)
- Test piped input if the command supports stdin
Test Scenarios
- Full happy path with all flags
- Minimal invocation with only required arguments
- Each error case produces correct exit code and error message
- Help flag (
--help) produces usage text - Version flag (
--version) if applicable
Step 7 -- Integration Checklist
Before considering the command complete:
- Command is registered and discoverable via the CLI tool's help
- All arguments and flags have clear names, types, defaults, and descriptions
- Help text includes a description, usage line, and at least two examples
- Input validation happens before any processing and returns actionable errors
- Core logic is a pure function returning action objects -- no I/O
- Executor handles I/O errors gracefully and sets correct exit codes
- Progress output goes to stderr, command output goes to stdout
- Unit tests cover validation and logic without mocks
- Integration tests verify end-to-end behavior including exit codes
- No debug statements, no commented-out code, no placeholder data in tests
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

