CLI Tool CLAUDE.md
CLAUDE.md template for command-line tools with argument parsing, output formatting, and error conventions.
Insert label
CLI Tool Prompt
Project Instructions
Commands
- One file per command or subcommand. Keep the entry point thin.
- Use a proper argument parser (commander, yargs, argparse, click). Don’t parse argv manually.
- Every command should have —help text that’s actually helpful.
Output
- Print results to stdout. Print errors and diagnostics to stderr.
- Support —json or —quiet flags for scripted usage.
- Use exit codes correctly: 0 for success, 1 for errors, 2 for usage mistakes.
Error Handling
- Show clear error messages. Include what went wrong and what to do about it.
- Don’t print stack traces to users unless —verbose is set.
- Fail fast on bad input. Don’t continue with partial arguments.
Testing
- Test commands end-to-end by capturing stdout/stderr and checking exit codes.
- Test edge cases: missing arguments, invalid input, empty files.
Git
- Write short commit messages. One feature or fix per commit.
Use this claude.md template with Crystl.
Get Crystl