Claude Code: Concise, Specific, Maintainable Instructions
In this article
This guide shows you how to write instructions for Claude Code that are concise, specific, and easy to maintain. You'll learn a repeatable format that reduces ambiguity, cuts down on back-and-forth corrections, and makes updating your prompts over time far simpler.
What You'll Need
- Claude Code installed and authenticated on your machine.
- A text editor for drafting instructions (any will do).
- A sample task or project to practice on.
Step-by-Step
- Start with the outcome, not the process. Write one clear sentence describing the finished result. For example: "Refactor the login function to use OAuth 2.0." Avoid vague verbs like "improve" or "optimize" unless you define what that means in measurable terms.
- Break the task into numbered sub-tasks. List each action as a separate numbered line. This makes it easier for Claude to follow sequentially and for you to track progress. For instance: 1) Read the current auth code, 2) Replace the old token logic, 3) Update tests, 4) Run the test suite.
-
Use exact file paths and function names.
Instead of saying "the config file," write "
src/config.js". Instead of "the main function," write "handleRequest()". This removes guesswork and prevents Claude from editing the wrong file. - Specify constraints as a checklist. Add a short "Constraints" section with bullet points like: "Do not modify package.json", "Keep the public API unchanged", "Use only built-in Node.js modules". These act as guardrails that keep the output within your project's boundaries.
- Define the definition of done. State exactly what must be true for the task to be considered complete. For example: "All tests pass, no new warnings, and the code is formatted with Prettier." This gives Claude a clear stopping point and gives you a checklist for review.
- Use placeholders for anything that changes. Instead of hardcoding values in your instructions, use variables like or . This makes the same instruction reusable across different contexts without editing the whole prompt.
- Keep it under 200 words when possible. Short prompts are easier for Claude to parse and for you to maintain. If you find yourself writing paragraphs, convert them into bullet points. Remove any filler like "please" or "I'd like you to".
-
Version your instruction files.
Save your instructions as a markdown file in your repo (e.g.,
docs/claude-instructions.md) and use Git to track changes. This lets you see what changed and revert if a new version causes issues. - Test with a dry run. Before using instructions on a real task, run them on a small dummy file to see if Claude interprets them as intended. Adjust wording based on the output.
- Review and refine periodically. Set a reminder to revisit your instructions every few weeks. As your project evolves, update file paths, function names, and constraints. Remove any steps that are no longer needed.
Common Mistakes
- Being too vague: "Make the code better" is useless. Always specify what "better" means (faster, cleaner, more secure).
- Overloading with context: Including too much irrelevant background confuses Claude. Stick to what's needed for the task.
- Mixing instructions and questions: If you ask a question mid-instruction, Claude may pause or answer instead of executing. Keep questions separate.
- Forgetting to update paths: After a refactor, old paths in instructions become stale. Always update them.
- Using absolute language: Words like "always" or "never" can be too rigid. Use "unless..." to allow edge cases.
Tips
- Use a consistent template for every instruction set. This reduces cognitive load when you switch between tasks.
- Put the most critical constraint first. Claude pays more attention to the beginning of a prompt.
- Use code blocks for commands or code snippets to prevent formatting issues.
- If a task recurs, turn it into a reusable script or alias rather than rewriting instructions each time.
- Ask Claude to output a summary of what it did at the end. This helps you verify that all steps were completed.
Troubleshooting
Claude doesn't follow the order of steps: Make the sequence explicit by numbering and using words like "first", "then", "finally". If it still skips, break the task into separate calls.
Claude edits files you didn't mention: Add a constraint like "Only modify files listed below" and list them. If it still happens, check that your file paths are correct and unambiguous.
Output is too verbose: Add a constraint: "Keep the response under 100 words" or "Return only the code, no explanations".
Instructions work once but fail later: Likely due to a change in the codebase. Update file paths and function names in your instructions.
Claude asks for clarification: This usually means your instruction is missing a key detail. Add the missing information and re-run.
Frequently Asked Questions
How long should my instructions be?
As short as possible while covering the essentials. Aim for 50-200 words for a single task. If you need more, break it into sub-tasks.
Can I use the same instructions for different projects?
Yes, if you use placeholders for project-specific details. Keep the core logic generic and swap out paths and names.
Should I write instructions in natural language or code?
Use natural language for what you want done, and code blocks for exact commands or snippets. Avoid mixing them.
How do I handle a task that has many edge cases?
List the edge cases explicitly in a "Constraints" or "Edge Cases" section. If there are too many, consider simplifying the task or breaking it into smaller pieces.
What if Claude misunderstands a term?
Define the term the first time you use it. For example: "Refactor the auth module (the file src/auth.js) to use async/await."
Is it worth maintaining a separate instruction file?
Yes, for tasks you run repeatedly. It saves time in the long run and ensures consistency. Store it in version control.