Claude Code Best Practices: Six Habits, Each Tested Before We Recommend It
The Claude Code practice that changed results most in our tests was one rule in CLAUDE.md: a change only counts as done when the tests have run and the output is shown. Without it, Claude Code ran no tests in two of two runs and reported the change as made. With it, it added a test, ran the suite and reported "Not done" because two older tests were failing. Below are six habits we use daily, each with the test behind it, and two that sound good but did little in our runs.
Tested by us on 11 November 2026.
The six habits at a glance
| Habit | What we measured | Guide |
|---|---|---|
| 1. Make "done" mean proven | Tests run in 0 of 2 runs without the rule, 2 of 2 with it | This page |
| 2. Write hard rules with a reason in CLAUDE.md | Float money math in 1 of 3 runs without the rule, 0 of 3 with it | CLAUDE.md |
| 3. Put real limits in a hook, not a prompt | A deny rule missed a Python delete; the hook caught it | Permissions |
| 4. Plan first when a business word is undefined | On clear tasks no gain; on "repeat customer" the plan asked, the direct run guessed wrong | Plan mode |
| 5. Give a reviewer the original request | Briefed by the author, the reviewer took the author's view | Subagents |
| 6. Keep context and cost in view | Status line tested live on Linux and on Windows | Status line |
1. Make "done" mean proven
Anthropic's own best-practices page advises giving Claude a check that has to pass before anything counts as done. We measured what that changes. We asked Claude Code to make a discount function reject percentages above 100, twice without instructions and twice with the rule below in CLAUDE.md. The project had 302 tests, two of them already failing. Without the rule, Claude Code edited the function, said it hadn't run anything and finished in six seconds. With the rule, it read the tests first, added a test, ran the suite and led with "Not done", naming the two older failures.
Write the rule with its reason
Put this at the top of the CLAUDE.md in your project. Replace the test command with yours.
markdown## Done means proven (2026-10-01, hard rule) Why: a change was reported as done while two tests were failing. Rule: before you say a change is done, run the full test suite (python3 tests/test_prijzen.py) and show the last lines of its output. Add a test for the new behavior. If anything fails, the first line of your report is "Not done". ## How you report 1. First line: "Done." or "Not done: <reason>." 2. What changed, in plain words. 3. Proof: the test command and its result. 4. What's still open.Check the first line of every report
"Not done" isn't a failure. In our runs it was the only signal that the project already had broken tests. Read the proof block before you merge.
Decide what you pay for it
The rule made each run cost $0.16 to $0.17 instead of $0.04, and take 14 to 16 seconds instead of 6. On a quick experiment that may not be worth it. On anything that ships, it is.
(opens at full size)2. Write hard rules with a reason
Claude Code reads CLAUDE.md at the start of every session. One line about money math moved an average-invoice task from float in one of three runs to exact decimals in three of three. We add a date and the reason to every hard rule, so the agent can apply it to cases the rule doesn't name and so we know later why it's there. The CLAUDE.md guide has the full template.
3. Put real limits in a hook
An instruction is a request. A deny rule matches the text of a command, so Bash(rm *) stopped rm -rf build but not the same delete written as a Python one-liner. A 30-line PreToolUse hook stopped both. Our test for where a limit belongs: if the agent forgets it, is that an inconvenience or damage? Damage goes in a hook. See the permissions guide for the settings file and hook.
4. Plan first only when a word is undefined
On eight runs of clear tasks, plan mode didn't reduce corrections and took about twice as long. On "give repeat customers 10% off", the plan asked what "repeat" meant, while the direct run picked a definition and reported success. We now plan first when a request uses a business word the code doesn't define. Details in the plan mode guide.
5. Give a reviewer the original request
A reviewer subagent with a fresh context found both bugs we planted in a diff. When the main agent wrote the code and briefed the reviewer itself, the reviewer accepted a missing cent because "it follows from the request", the same view as the author. A subagent only knows what it's told, so pass it the original request and the diff. The subagents guide has our reviewer file and the context measurements.
6. Keep context and cost in view
A long session carries old conversation, and the work gets worse before you notice. We keep a status line with the context percentage and the estimated session cost on screen; when the bar turns red, a fresh session with a short summary works better than pushing on. The status line guide has the script, tested on Linux and Windows.
Two habits that did less than we expected
- Subagents to save context. On a noisy test run and a 40-file search, the main conversation shrank by 8% at best, while sessions cost 1.6 to 2.4 times as much. Claude Code already filtered output with grep and tail on its own.
- Planning every task. Plan mode found nothing on clear tasks that a direct run missed. Its value showed only when the request itself was ambiguous.
How long work fits in
Our agents often work for hours on one job. We don't keep those inside one interactive session. Each long job runs as its own session that survives a closed terminal, reports progress in plain words and ends with a status line, proof and what's still open, the same report format as habit 1. That's a practice rather than a test result, so we leave the numbers out.
Questions
What is the most important Claude Code best practice?
In our tests: define done as proven. One rule in CLAUDE.md made Claude Code run the tests, add a test and name the failing tests in two of two runs, where it ran no tests at all without it.
Should I always use plan mode?
No. On clear tasks it took about twice as long with the same result. Use it when the request contains a term the code doesn't define, or when a change touches live data.
Do these habits cost more?
Some do. The done-means-proven rule raised the cost per run from $0.04 to about $0.16 in our test, because Claude Code read and ran the tests. For work that ships, that trade is worth it.
Do the same habits work in Codex or other coding agents?
The ideas carry over: an instruction file with reasons, a definition of done, limits outside the prompt. We run Claude Code and Codex side by side with the same instruction text. The file names and hook mechanics differ per tool.
Sources
- Claude Code: Best practices checked on
- Claude Code: How Claude remembers your project checked on
More in claude in practice
- CLAUDE.md and Claude Code Memory: A Template We TestedHow Claude Code memory works through CLAUDE.md, with a template we tested: rules that stick, background files that load only when needed, and AGENTS.md.
- Claude Code Permissions: Let It Work Freely Without Breaking AnythingSet up Claude Code permissions so it works without constant prompts but can't delete or leak what matters. Tested settings file, deny rules and a blocking hook.
- Claude Code Plan Mode: How to Use It, and When It Pays OffHow to use Claude Code plan mode, and what it changed in ten timed runs: no gain on clear tasks, but it asked the one question the direct run got wrong.
- Claude Code Subagents: When They Help, and When They Only Cost MoreWe tested Claude Code subagents on real tasks: little context saved, up to twice the cost, and a reviewer that took the author's view. Two subagent files.
Also useful
- A Claude Code Status Line That Shows Cost, Context and Git BranchA Claude Code status line script that shows model, folder, git branch, a context bar and cost. Tested in a live session on Linux and on Windows, no jq needed.
- AGENTS.md Explained: One Instruction File for Codex, Claude Code and Other AgentsAGENTS.md is the shared instruction file for coding agents. How Codex reads it, when Claude Code does, and the one-line fix we tested.
- How to Build an MCP Server: A Tested Python and Node ExampleBuild a working MCP server in Python or Node, test it without a model, inspect it, then connect it to an AI app. Full code and the errors we hit.