Claude Code is powerful, but power without discipline leads to chaos. These best practices come from
hundreds of production hours. Follow them and you’ll get faster, safer, and more predictable results.
1. Start every project with AGENTS.md
This is the single highest‑ROI action. Create a file named AGENTS.md in your project root.
Fill it with your coding standards, folder structure, testing requirements, and any repetitive warnings
(e.g., “never use relative imports from lib/”). Claude Code reads this file automatically at the start
of each session. It acts like a permanent system prompt for your codebase.
# Project conventions
- Use TypeScript strict mode
- Prefer named exports over default exports
- Write unit tests for all utils/
- Never commit secrets; use .env
- Run `pnpm lint` before suggesting changes
2. Be specific, not polite
Claude Code doesn’t need “please” or “if you have time”. It needs precise instructions.
- Bad: “Can you maybe refactor this function a little?”
- Good: “Refactor `parseCSV` to return a stream instead of loading everything into memory. Keep the same interface.”
Specify the output format, edge cases, and what “done” looks like. A well‑formed prompt saves two rounds of back‑and‑forth.
3. Use the built‑in skills (don’t DIY everything)
Claude Code ships with dozens of built‑in skills. find-skills helps you discover them.
Before you write a long manual prompt, ask: “Is there a skill for this?” Common built‑ins include
refactor, write-tests, explain-code, and document-api.
4. Keep context windows clean
Claude’s context window is large but not infinite. Every file you open, every error message, every
long conversation stays in memory. Prune old turns manually by starting a fresh chat when the
conversation drifts. Use /clear to reset context while keeping the project loaded.
5. Test‑driven prompting
Ask Claude to write the test first, then the implementation. This forces clarity on expected behaviour.
It also gives you a fast feedback loop: if the test passes, the code works. If the test fails,
you have a precise specification of what’s wrong.
6. Review before accepting
Claude Code is confident but not infallible. Always review diffs before applying. Enable
diff mode in settings so you see every change line by line. For critical paths,
ask Claude to explain its reasoning before generating code.
7. Use a project‑specific CLAUDE.md for team rules
While AGENTS.md is for the AI, CLAUDE.md can contain team‑wide instructions
that also benefit human developers. Store your lint config, commit message conventions, and review
checklist there. Claude will follow it; your team can reference it.
8. Set up pre‑commit hooks with Claude
Install a pre‑commit hook that runs claude code check (or similar). This catches
style violations, missing tests, and unsafe patterns before code reaches the remote repo.
It’s like a lightweight, AI‑powered CI.
• Asking Claude to “fix everything” without specifying scope → leads to over‑refactoring.
• Ignoring token usage → costs add up; use
/cost to monitor.• Not saving good prompts as skills → you’ll retype the same instructions.
• Assuming Claude remembers project conventions without AGENTS.md → it won’t.
Related guides
- Claude Code Skills Hub – find the right skill
- Context Engineering for AI Agents – fix quality issues
- Build Custom Skills – automate your team’s workflows
Leave a Reply