Branchwell

Become a Pro / website · becomeapro.ai / content / lessons / knowledge-work / using-ai / claude-code-best-practices.mdx

Raw 7.4 KB on 807b8657974875ed44f307014cfbf8ce673dc5a6
1---
2title: "Claude Code best practices"
3description: "The habits that get the most out of Claude Code today: tell it what it cannot see, give it a check to run, enforce hard rules with hooks, and steer early."
4level: Beginner
5minutes: 7
6updated: 2026-12-03
7order: 3
8sources:
9 - https://code.claude.com/docs/en/best-practices
10 - https://code.claude.com/docs/en/overview
11 - https://code.claude.com/docs/en/quickstart
12 - https://code.claude.com/docs/en/how-claude-code-works
13 - https://code.claude.com/docs/en/common-workflows
14 - https://code.claude.com/docs/en/memory
15 - https://code.claude.com/docs/en/features-overview
16 - https://code.claude.com/docs/en/skills
17 - https://code.claude.com/docs/en/hooks-guide
18 - https://code.claude.com/docs/en/sub-agents
19 - https://code.claude.com/docs/en/mcp
20 - https://code.claude.com/docs/en/security
21 - https://code.claude.com/docs/en/permission-modes
22 - https://code.claude.com/docs/en/commands
23 - https://code.claude.com/docs/en/whats-new
24 - https://code.claude.com/docs/en/changelog
25 - https://support.claude.com/en/articles/14554000-claude-code-power-user-tips
26 - https://academy.claude.com/courses
27 - https://anthropic.skilljar.com/claude-code-in-action
28 - https://claude.com/resources/webinar-series/claude-code
29 - https://claude.com/resources/webinars/claude-code-foundations-series
30 - https://claude.com/resources/webinars/claude-code-workshop-advanced
31 - https://claude.com/resources/videos
32 - https://claude.com/code-with-claude
33 - https://claude.com/code-with-claude/session/tyo-whats-new-in-claude-code
34 - https://claude.com/code-with-claude/session/sf-ext-how-we-claude-code
35 - https://www.anthropic.com/engineering
36---
37
38Claude Code is Anthropic's coding agent. It reads your project, edits files and runs commands in your terminal, your editor or the desktop app. Its defaults already handle most plain requests well: new terminal sessions start in auto mode, where a separate model reviews each action and blocks risky ones, Claude hands side work to subagents on its own, and long conversations are compacted automatically before the context fills up.
39
40So the best practices today are not tricks for getting a model to behave. They cover the things no default can know about your project. This lesson follows Anthropic's own best-practices guide and puts it in plain steps.
41
42<Diagram caption="Most sessions that go wrong are missing one of these three things.">
43 <svg viewBox="0 0 600 230" role="img" aria-label="Three boxes in a row: tell Claude what it cannot see, give it a check to run, and enforce the rules with no exceptions, all feeding into a finished task">
44 <rect x="20" y="30" width="170" height="80" rx="10" fill="none" stroke="currentColor" strokeWidth="2" />
45 <text x="105" y="64" fontSize="15" textAnchor="middle" fill="currentColor">Tell it what</text>
46 <text x="105" y="86" fontSize="15" textAnchor="middle" fill="currentColor">it can't see</text>
47 <rect x="215" y="30" width="170" height="80" rx="10" fill="none" stroke="currentColor" strokeWidth="2" />
48 <text x="300" y="64" fontSize="15" textAnchor="middle" fill="currentColor">Give it a</text>
49 <text x="300" y="86" fontSize="15" textAnchor="middle" fill="currentColor">check to run</text>
50 <rect x="410" y="30" width="170" height="80" rx="10" fill="none" stroke="currentColor" strokeWidth="2" />
51 <text x="495" y="64" fontSize="15" textAnchor="middle" fill="currentColor">Enforce the</text>
52 <text x="495" y="86" fontSize="15" textAnchor="middle" fill="currentColor">hard rules</text>
53 <line x1="105" y1="110" x2="300" y2="160" stroke="currentColor" strokeWidth="2" />
54 <line x1="300" y1="110" x2="300" y2="160" stroke="currentColor" strokeWidth="2" />
55 <line x1="495" y1="110" x2="300" y2="160" stroke="currentColor" strokeWidth="2" />
56 <rect x="200" y="160" width="200" height="50" rx="10" className="soft" stroke="currentColor" strokeWidth="2" />
57 <text x="300" y="191" fontSize="16" textAnchor="middle" fill="currentColor">Work that is really done</text>
58 </svg>
59</Diagram>
60
61## Tell Claude what it can't see
62
63Claude reads your code, so it already knows your folder layout and your frameworks. What it can't read is the knowledge in people's heads: the exact command that runs one test, the decision your team made last month, the folder that looks dead but is still live.
64
65- **Keep a short `CLAUDE.md`.** Write down the test, typecheck and lint commands, your team's conventions and the misleading corners of the code. Aim for under 200 lines. Leave out what Claude can see in the repo. Our [CLAUDE.md guide](/knowledge-work/using-ai/claude-md-guide) shows how.
66- **Scope rules that only matter in one place.** Put them in `.claude/rules/` with a `paths` filter so they load only when Claude works on matching files.
67- **Put long procedures in skills.** A release checklist or a deploy routine fits better in a skill, which Claude reads only when the task calls for it.
68- **Write a specific prompt.** Name the file, describe the symptom and say what "fixed" looks like. If you have the error message or a screenshot, paste it in.
69
70## Give Claude a check to run
71
72Claude says a task is done when it believes it is done. A check that comes back pass or fail lets it find and fix its own mistakes instead of stopping when the work only looks right.
73
74- Tell it which test, build or linter proves the change works, and ask it to run it.
75- Ask for the command it ran and the end of the output as evidence, not just a summary.
76- For a bigger feature, ask a subagent to review the change against your written spec before you merge.
77
78## Enforce the rules that can't have exceptions
79
80A line in `CLAUDE.md` works most of the time. For "always" and "never", most of the time is not enough.
81
82- **Hooks** are shell commands Claude Code runs at fixed points, such as before every tool call or when Claude finishes. A hook can format code after each edit or block a dangerous command, whatever the model decides.
83- **Permission rules and the sandbox** limit which files Claude can read and which commands it can run.
84- **Permission modes** set how much Claude does without asking. Press `Shift+Tab` to cycle through Manual, Accept edits and Plan, plus Auto when it is available.
85
86## Steer early
87
88Watch the first minute of a task. Press `Esc` the moment Claude drifts: it stops right away and keeps the work so far. Run `/rewind` to roll the code or the conversation back to an earlier point. After two failed corrections, run `/clear` and write one better prompt instead of a third correction, because a conversation full of failed attempts keeps pulling Claude back toward them.
89
90## Drop the old workarounds
91
92Older models needed tricks that now do more harm than good:
93
94- ALL CAPS and IMPORTANT make Claude over-apply a rule. If a line keeps getting missed, the file is too long or the rule needs a hook.
95- "Think harder" is ordinary text. Effort is the real control, and `ultrathink` still asks for deeper reasoning on a single turn.
96- "Keep going, don't be lazy" tends to cause extra work. A check to pass works better.
97- Describing your whole architecture in `CLAUDE.md` wastes context. Claude reads the repo itself.
98
99## Practice
100
1011. Run `/init` in a real project, then cut the result down to the lines Claude couldn't work out alone.
1022. Give Claude a small bug with a "done means" line that names a test command.
1033. Press `Esc` once mid-task and redirect it, so the habit is there when you need it.
1044. Run `/usage` at the end of the day to see how much of your plan the session used.