Writing reusable prompts for coding agents
2 min read
When you run the same coding task more than once, rewriting your prompt from scratch slows you down. This guide covers how to structure reusable prompts for coding agents with clear done criteria, narrow scope, and named folders so you can execute repetitive tasks efficiently.
Define Clear Done Criteria
A prompt fails when the agent cannot tell when it has finished the work. Vague instructions like "improve the error handling" leave too much room for interpretation, leading to endless loops or incomplete changes.
To make a prompt repeatable, specify the exact conditions required for completion. List concrete tests that must pass, specific files that should be modified, and output formats that are expected.
Task: Format the JSON response in <file_name>
Done Criteria:
- All keys are sorted alphabetically
- Indentation uses two spaces
- Running <test_command> passes without errors
When you feed explicit criteria into your workflow, the agent executes the steps predictably every time you trigger the run.
Keep the Scope Narrow
Reusable prompts work best when they focus on a single, isolated responsibility. If a prompt tries to refactor your database schema, update frontend components, and write documentation all at once, minor variations in your codebase will break it.
Break large workflows into smaller, modular prompts. Instead of a single prompt that handles an entire feature migration, create distinct steps: one prompt for extracting data structures, another for updating queries, and a third for generating tests.
Narrow prompts reduce the token overhead, minimize unexpected side effects, and make it easier to isolate failures when an agent runs into trouble.
Organize Prompts in Named Folders
As you accumulate prompts for different repositories and tasks, keeping them in a flat directory creates clutter. Group your prompts into a clear directory structure named after the component or workflow they target.
Create a dedicated directory in your project root or home directory, such as agent-prompts/, with subfolders matching your domains:
agent-prompts/
├── database/
│ ├── add-migration.md
│ └── validate-schema.md
├── frontend/
│ └── generate-component.md
└── testing/
└── run-smoke-tests.md
Naming folders by functional area lets you quickly locate the right instructions when you are juggling multiple codebases.
Saving and Running Saved Tasks
Once your prompts are structured with strict criteria, narrow scopes, and organized folders, you can turn them into repeatable routines. Instead of pasting them manually into a terminal every time, you can save a task once and run it at a set time, on a repeating schedule, or with one click using Tidepane automations.
Organized prompts combined with scheduled automations ensure consistency across repetitive tasks like dependency audits, log checks, and routine formatting runs.
To get started, take one repetitive task you ran this week, rewrite it with explicit done criteria, and save it in a dedicated folder for your next run.