Five habits, five commands
Every list of Claude Code habits tells you what to do. This one turns each habit into a command that Claude Code runs, so the habit holds whether or not the model reads it. We ran all five on a real repo, ledgerly, a small Node 20 and TypeScript invoicing API, with Claude Code 2.1.294.
The reason is in Anthropic's own best practices: a line like "Always typecheck before you finish" in your CLAUDE.md "works most of the time, not every time". The five commands below are /goal, a PreToolUse hook, /context with /clear, /skill-doctor, and a read-only reviewer subagent.
Why a written habit slips
CLAUDE.md is the instructions file Claude reads at the start of every session, a readme written for a new teammate: commands, conventions and rules. It is where most habits end up, often with the most important ones in capitals, like "NEVER edit src/store/migrations.ts".
Anthropic's memory docs are explicit about what that file is: Claude reads it as context, not as enforced configuration. Every line is advice weighed against the task in front of it. The difference is the one between a code review checklist on a wiki page and a check in your CI pipeline: the first depends on somebody reading it, the second runs anyway.
The gesture: open your CLAUDE.md and mark every line that has to hold every single time. Keep the rest where it is, since the file is still the right place for what Claude cannot infer from your code, and the docs target under 200 lines per file.
Habit one: say what done looks like
Claude stops when the work looks done. If nothing tells it whether the work actually is done, Anthropic's best practices note, you become the test suite.
/goal sets a finish line once. After every turn, a small fast model reads the conversation and returns met, not yet met, or impossible. It cannot run commands or read files, so write the condition as something Claude's own output can show, such as the full test output.
| Run on ledgerly | What we saw |
|---|---|
| Plain session, same feature request | Tests ran inside a collapsed tool call; the reply said "pnpm test passes (37/37)" |
With /goal and the condition "full pnpm test output printed" |
The reply printed the whole run, "Tests 44 passed (44)", then "Goal achieved (45s · 1 turn · 5.1k tokens)" |
Type /goal alone to see its status and /goal clear to remove it. For a one-line fix you do not need it; the docs say it matters most on long runs, where Claude sometimes ends a turn with items still open.
Habit two: a rule that can't break
A rule in capitals is respected most of the time, which is exactly the problem. A hook is a small script Claude Code runs by itself at a fixed moment; a PreToolUse hook runs before each tool call. Ours reads the file path and, when it is src/store/migrations.ts, prints "migrations.ts is append-only: add a new migration file instead" and exits with code 2. The hooks guide says exit code 2 blocks the call and sends the message back to Claude, and the block holds even when permission prompts are switched off.
On our runs: with the rule in CLAUDE.md, Claude refused the edit on its own. With the rule removed, Claude went for the migrations file twice and the hook blocked both edits; Claude edited the rest and reported "A project hook blocked both of my edits to that file." In two later runs it read the hook script first and never tried the file.
A hook only blocks what it can match, a path or a command. Judgement rules, like "write clean code", stay in CLAUDE.md, and a narrow match keeps the hook from blocking your own work.
Habit three: one task, one context
The context is everything the model sees on each turn: your instructions, the files it read and the whole conversation. /context shows it as a grid; /clear empties the conversation while files and settings stay.
/context on ledgerly |
Total | Messages |
|---|---|---|
| After the finished task | 57.5k of 1m tokens | 26.4k tokens |
After /clear |
31.1k of 1m tokens | 130 tokens |
The docs: /clear between unrelated tasks costs nothing, and after two failed corrections you clear and write a better prompt. In the middle of a task, use /compact with a focus instead.
Habit four: load only what you use
A skill is a packaged instruction Claude loads when a task matches it. The full skill loads only when it runs, but its one-line listing sits in the prompt every turn, and the listing budget is about 1% of the context window, so the least-used skills lose their descriptions first.
/skill-doctor lists every skill with its context cost and how often you used it. On our machine it reported:
| Kind | Loaded but never invoked |
|---|---|
| Personal skills | 13 |
| Synced from claude.ai | 14 |
| Plugin skills | 25 |
It also listed 4 plugins not used recently. Switch a skill off in /skills; synced skills come back if you delete them, so turn those off on claude.ai; plugin skills go through the plugin manager. One listing line is small, so this trims noise rather than freeing half your context.
Habit five: fresh eyes on the diff
A subagent is a second Claude session started for one job, with its own empty context, that hands back a summary. Anthropic's docs put it plainly: handing the same task to a subagent does not make the answer better, but a fresh reviewer helps because it has not seen your reasoning.
Our reviewer lives in .claude/agents/reviewer.md with read-only tools: Read, Grep, Glob, Bash(git diff:*) and Bash(git status:*). On the overdue-invoices diff, the author session's own review found a real bug: invoices with the same due date sorted by id as text. The reviewer found the same bug and the missing test in 28 seconds, then checked every README convention one by one. It also claimed the type check was clean, which its tools could not run, and the main session flagged it as unverified. Call it once per feature, before the merge.
Which habit to set up first
Start with the hook, on the rule that has already been broken more than once in your repo. /clear and /skill-doctor cost nothing. Keep /goal for long runs and the reviewer for the merge. The rule to keep: if a habit has to hold every time, make it something Claude Code runs, not something Claude reads.
AIDive