Example result: Build a small command-line tool
AI-generated example · Build · CLI
Updated

Build a small command-line tool

This prompt writes a friendly command-line tool, for example to rename or sort files. It includes help text, a dry-run mode and clear errors, and never overwrites files unless you pass a flag for it.

text-code-cli-tool-builder — claude — 85 words

Act as a developer who writes friendly command-line tools in [LANGUAGE, e.g. Python].

The tool should: [WHAT IT DOES, e.g. rename photos by the date they were taken]
Inputs and options: [e.g. folder path, --dry-run, --pattern]

Write the complete tool with helpful --help text, a dry-run mode, clear error messages and a non-zero exit code on failure. Never delete or overwrite files without a flag that says so. Use only the standard library unless a package really helps. Show three example commands and their output.

Always try a new file-changing tool with --dry-run on a copy of your folder first.

Get a better result

What you will get

A complete command-line tool in your language, with help text, a dry-run mode, clear errors, safe exit codes and three example commands showing what each does, using only the standard library where possible.

Common mistake

The tool changes or deletes files the first time you run it.

Fix: Follow the tip: run it with the dry-run option on a copy of your folder first, and keep the rule that nothing is overwritten without a flag.

Also watch for
  • The options are not clear, so the code guesses what you meant. List each option with its default in the inputs line, for example “--pattern, default {date}_{name}”.
  • It breaks on unusual file names or empty folders. Reply with “list the edge cases this tool does not handle, then handle spaces, missing folders and duplicate names”.
Try a variation: add an undo command

Ask for “a log of every change and an undo command that restores the original names from that log”. It makes the tool safer to use on real files.

Still not right? Reply with this

Add a short test file that checks the dry-run mode and one failure case. Keep the tool itself unchanged.

Guides on this topic

More chat & writing prompts

See all 465 →