Sub topic 3
Reusable Prompt Files
This chapter assumes you have used an AI coding assistant, can read Markdown and simple YAML, and know basic Git. File names and frontmatter fields differ between products, so check your tool's documentation for the exact layout.
What a prompt file is
A prompt file is a Markdown file that holds a prompt you use often. You invoke it by name, usually as a slash command, instead of retyping the request. Typical locations are a prompts or commands folder inside the repository, or a folder in your home directory for personal prompts.
A prompt file is loaded only when you call it. It adds nothing to the context window until then, which makes it different from persistent project instructions that load in every session.
Anatomy of a prompt file
Most tools use a short YAML frontmatter block followed by the prompt body. The frontmatter carries metadata such as a description. The body is the text sent to the model.
---
description: Review the staged changes for bugs and missing tests
---
Review the changes I have staged in Git.
1. List any likely bugs, with file and line references.
2. Point out public behavior that has no test.
3. Suggest the smallest fix for each finding.
Do not edit any files. Reply with a short Markdown list ordered by severity.This file has four parts that make a prompt reusable:
- A fixed task. It names what to review and where to find it.
- Steps. A numbered list keeps the work in the same order each run.
- A boundary. "Do not edit any files" stops the agent from changing code during a review.
- An output format. A severity-ordered Markdown list makes results easy to compare between runs.
Writing good prompt files
Write the prompt as if for a colleague who has no memory of your last conversation. Each run starts fresh, so the file must hold everything the task needs.
- Make one file do one job. A file called "review and fix and deploy" is hard to trust and hard to test.
- State what the agent must not do. Boundaries matter as much as steps.
- Specify the output shape. Without it, the format drifts between runs.
- Point to files instead of pasting them. A line such as "follow CONTRIBUTING.md" stays current when that file changes.
Common errors
- Vague descriptions. The description often appears in command menus. "Helper" tells you nothing, while "Review staged changes for bugs" does.
- Hidden assumptions. If the prompt relies on a convention you never wrote down, another teammate gets different results.
- Too much in one file. Long prompts use context on every call and bury the key instruction.
- Wrong location or extension. If the command does not appear, check the folder and file name your tool expects.
Exercise
A teammate's prompt file works well for them but gives you a different output format each time. Name two changes that would make the results more consistent.
Show answer
Add an explicit output format, such as "Reply with a Markdown list ordered by severity", and add numbered steps so the work runs in the same order. Stating boundaries, such as "Do not edit any files", and pointing to shared files instead of relying on unwritten conventions also help.