Claude Code: the best practices that hold up in production
A coding agent does not write good software because it is powerful. It does when you give it context, a plan, a way to check its own work, and bounded permissions. What we apply on our own deliveries.
· 9 min read
This article is for technical leads and developers in SMEs who use Claude Code, or are considering it, and for managers who want to know what their team runs on its machines. It is not for anyone looking for a chatbot to write emails: Claude Code works inside a code repository, from the terminal or the editor.
In the sense of our article on agents, Claude Code is a real agent: the model chooses its steps, reads files, runs commands, reads the result, and carries on. That is what makes it useful. It is also what imposes the same rules as on any agent: a clear goal, bounded tools, and a human before the action that costs.
The short answer: the quality of what comes out depends less on the model than on four habits. A short CLAUDE.md file that says how the project is built and tested. An exploration and planning phase before any writing. A verification criterion the agent can run itself. And a context kept clean, one task at a time. The rest (subagents, hooks, non-interactive mode) comes after, once those four hold.
We use Claude Code on the software we deliver, this website included. What follows is what survived that use, cross-checked against the recommendations Anthropic has published. It is not a list of tricks: each practice answers a specific way a coding agent goes wrong.
1. A short CLAUDE.md, versioned, kept up to date
CLAUDE.md is a file Claude Code loads automatically at the start of every session. It is the project's memory: the build and test commands, the conventions you cannot guess by reading the code, the known pitfalls, what must never be touched. The /init command generates a first version from the repository.
The file is versioned with the code, at the root of the repository, so the whole team shares the same context. A CLAUDE.md in a subfolder adds local rules, and a personal file in the ~/.claude folder keeps each person's preferences out of the repository.
The most common mistake is to fill it up. Every line is read again in every session and costs context; an instruction buried in three pages is an ignored instruction. Keep what the agent cannot find on its own, write it as a checkable rule ("run npm run typecheck before concluding", not "write clean code"), and delete what no longer applies. When the agent makes the same mistake twice, a line is missing.
2. Explore, plan, and only then write
Left to itself, a coding agent starts writing straight away. On a one-line task, that is fine. On a task that touches several files, it is the surest way to solve the wrong problem with confidence.
The order that works is well known: have it read the relevant files without changing anything, ask for a plan, review and correct it, then start the implementation, and finally the commit. Plan mode (Shift+Tab in the terminal, until the status bar shows it) makes that split explicit: the agent explores and proposes, and writes nothing until you have approved.
The plan is the cheapest moment to fix a mistake. A poor architecture choice spotted in a ten-line plan is fixed in one sentence; spotted in a six-hundred-line diff, it is paid for in review and rollback. If you cannot describe the expected result in a few sentences, the plan is not ready, and neither is the agent.
3. Give the agent a way to check its work
This is the practice that changes the result most. An agent that can run a test, a typecheck, a build, or compare a screenshot with a mock-up fixes its own mistakes before showing them to you. An agent that cannot hands you plausible code, and you do the checking.
So tell it how to check, in the request or in CLAUDE.md: which command, which expected result, which edge case. Test-driven development fits particularly well: have the tests written first, see them fail, commit them, then ask for the implementation without changing the tests. The agent has a fixed target, and you know when it has reached it.
Be wary of the test it writes for itself after the fact. An agent can make a test pass by weakening it, or conclude "done" on a skipped test. The definition of done has to come from you, or be frozen before the implementation.
4. Be specific, and give real context
"Add tests for foo.py" produces tests. "Add a test for foo.py covering the case where the user is logged out, without mocking the database" produces the test you needed. The precision of the request shows up in the precision of the result.
Point to files rather than describing them, paste the full error message rather than a summary, attach the screenshot or the mock-up when the subject is visual, and name the existing file whose style should be followed. The agent reads the code; it does not read your mind.
Correct early. Escape interrupts the agent mid-task without losing what has been done, and a double Escape lets you go back to an earlier message and rephrase. A correction at step three costs a sentence; at step thirty, it costs a session.
5. Keep the context clean
The context window is the resource that degrades fastest. Every file read, every command output, every dead end stays in it. As it fills up, the agent follows the early instructions less well and mixes up tasks.
One task per session. /clear between two unrelated subjects, rather than chaining a bug fix and a page redesign in the same conversation. /compact when a long task has to continue, to summarise the history instead of dragging it along.
For broad searches ("where is payment handled?", "who calls this function?"), hand the exploration to a subagent. It reads what it needs in its own context and reports only the conclusion. The main session keeps its room for the work that matters.
6. Bounded permissions, and rules that run
Since version 2.1.283, Claude Code starts in auto mode: a second model, the classifier, reviews actions in your place and blocks only what looks risky. In Manual mode, it asks before every file edit or command. Either way, the protection that counts is the one you write down: explicitly allow the safe, repetitive commands (lint, tests, git status) in the project settings file, and deny what must never happen, such as reading .env files or pushing to the main branch.
The option that skips every permission exists. It belongs only in an isolated container, with no secrets and no network access, not on a developer machine connected to production.
An instruction in CLAUDE.md is advice: the agent follows it most of the time. When a rule must apply every time, make it a hook, a command Claude Code runs at a precise moment (after each file edit, before a command). Formatting the code, running the linter, blocking a write to a protected folder: those are hooks, not sentences.
7. What to refuse
A diff accepted without review. The agent writes fast; the person who merges remains responsible for the code. Review it as you would a colleague's pull request, and ask a second session for a review when the change is large: an instance that did not write the code judges it better than the one that did.
Several agents in parallel before mastering one. Git worktrees let several sessions work on separate branches, and non-interactive mode (claude -p) lets you plug Claude Code into a script or a CI pipeline. That is useful once the practices above hold on a single session. Before that, it multiplies errors instead of throughput. The setup that makes them safe, a preview environment per branch, is covered in our article on multi-agent and multi-staging.
Secrets or customer data in the context. What the agent reads goes to the model. Sensitive configuration files are excluded through permissions, and production data has no business in a development repository, agent or not.
A "done" without proof. A task is not finished because the agent says so, but because the tests pass, the build succeeds, and the expected behaviour has been seen.
Sources
The practices above cross-check the recommendations published by Anthropic. No productivity figure is put forward in this article: it depends too much on the project and the team to be generalised.
Claude Code documentation, "Best practices for Claude Code", reread 20 October 2026 (Anthropic's earlier article on the subject now redirects to this page): self-verification, explore then plan then code, CLAUDE.md and /init, permissions, hooks, subagents, Escape and /rewind, /clear and /compact, non-interactive mode, worktrees. Best practices.
Claude Code documentation: memory and CLAUDE.md, permission modes, settings, hooks, reread 20 October 2026. Memory, Permission modes, Settings, Hooks.
Anthropic, "Building effective agents", 19 December 2024, reread 20 October 2026: the distinction between workflow and agent used in the introduction. Anthropic article.
In one sentence
Claude Code is an agent: it works well when you give it what you would give a good developer joining the project, namely written context, a reviewed plan, a test that says when it is done, and permissions that match the trust.
The right use is not to let it run alone for longer. It is to make every session checkable, so that the speed gain is not paid back later in review and debt.
Is your team adopting Claude Code?
We look at your repository, your test pipeline and your access rights, then help you write the CLAUDE.md, permissions and hooks that go with them. If your project does not yet have a way to check an agent's work, that is where we will start.
Does your SME need an AI agent, or a well-built automation?
Most of the time, no. A clear scenario (Make, Zapier, or the equivalent) is enough. An agent is justified only when the path cannot be written in advance, with a goal, bounded tools, and a human check.
Technical
What we deliver is software: versioned, tested, shipped through a CI pipeline, monitored in production and documented so it can be taken over without us. This page is written for whoever wants to check - a CIO, a technical supplier, a buyer with a checklist.