arrow_back Back to Blog
claude code best practicesclaude codeai coding

Claude Code Best Practices for an App You Plan to Ship

·

What are the Claude Code best practices that matter most? The official best practices page, checked November 29, 2026, boils down to three things: tell Claude what it can’t see from the code, give it a check that comes back pass or fail, and move every rule that can’t have exceptions out of CLAUDE.md and into a hook, a deny rule or a managed setting. The rest is detail.

That third point is the one most founders skip, and it’s the one that decides whether your app is safe to put in front of real users.

Guidelines versus rules

The docs split every instruction into two kinds. A prompt, a CLAUDE.md line or a skill is read by the model, and the model decides what to do with it. A hook, a deny rule or a managed setting is applied by the harness every time, whatever the model decided.

Most of the time you want the first kind. A model looking at the actual code makes better calls than a rule you wrote last month. But some things are not judgment calls:

  • the .env file is never read;
  • the generated Supabase types are never hand-edited;
  • nothing gets pushed to main directly;
  • a migration that drops a column is never applied without a person looking.

Written in CLAUDE.md, each of those holds nearly every time. “Nearly” is fine for a naming convention. It’s not fine for a production database.

The docs have a good tell for this: if you keep adding IMPORTANT to a line and it still gets missed, the line belongs in a hook. The reverse is true too. A hook for something that’s only a preference is noise; delete it.

Rules from a CLAUDE.md sorted into two bins: preferences stay as guidelines, the never-do items move into deny rules, hooks and CI

Keep CLAUDE.md short

Everything in CLAUDE.md is loaded into every session and takes a little attention on every task. The docs say it should hold only what Claude can’t work out from the repo:

  • the exact test, typecheck and lint commands, and how to run one test file;
  • places where the code is misleading (an old pattern new code must not copy);
  • decisions that aren’t written anywhere else, like how deploys work;
  • anything you’ve had to correct twice.

The memory guide suggests staying under 200 lines. /init writes a first draft, and /doctor suggests cuts. Describing your folder layout is listed under advice you can stop following: Claude reads the repo itself. Personal preferences go in CLAUDE.local.md, kept out of git. We went through what a good one looks like in our CLAUDE.md guide.

Give it a check that says pass or fail

“Claude stops when the work looks done.” Without something to run, “looks done” is the only signal it has, and you become the test suite.

For a typical Lovable-style app (React, Vite, Supabase), the checks are cheap to add:

  • npm run build and tsc --noEmit for the frontend;
  • a handful of tests on the parts that move money or data;
  • a script that lists every table without row level security turned on.

Put the commands in CLAUDE.md so Claude can run them as it goes. If a passing typecheck must happen before it finishes, use a Stop hook: it runs your script when Claude tries to end its turn and sends it back to work if the script exits with code 2. The docs’ example is one line, pnpm tsc --noEmit 1>&2 || exit 2. After eight blocked stops in a row with no tool call between them, Claude Code lets the turn end anyway, so it can’t loop forever.

Ask for evidence either way. “All tests pass” tells you very little; the command and its output tell you a lot. Our hooks guide has more examples.

Lock the doors with deny rules

Permission rules decide what Claude may run, read and fetch, and deny rules hold in every permission mode, including auto and bypassPermissions. That’s why secrets go there:

{
  "permissions": {
    "ask": ["Bash(git push *)", "Bash(supabase db push *)"],
    "deny": ["Read(./.env)", "Read(./.env.local)", "Read(./supabase/.temp/**)"]
  }
}

The docs are honest about the edges. A Read deny rule catches cat .env, because Claude Code knows the common file-reading commands. It won’t catch a script that opens the file. A WebFetch deny rule does nothing about curl to the same domain unless the sandbox is on. For real limits on files and network, turn on the sandbox with /sandbox as well. Auto mode’s classifier is a judgment call, and the docs say plainly that your “never” rules belong in deny rules or hooks, not in it.

Use subagents for review, not for a smarter answer

Subagents pay off for parallel work, for keeping long output out of your session, and for a reviewer that never saw the reasoning behind the code. A reviewer limited to tools: Read, Grep, Glob can’t edit anything, and that limit is enforced. What they don’t give you is a better answer: same model, same task, more tokens. Details in our subagents post.

Before you leave it running

For unattended runs, the docs list five questions worth answering for each task:

  1. Does it know what done looks like (a spec, a goal, a failing test)?
  2. Can it check its own work?
  3. What may it touch (permission rules, a worktree, one branch)?
  4. What stops it (--max-turns, --max-budget-usd, a spend limit)?
  5. Where does the result go, and which person signs off?

That last one is the part founders most often leave out. Branch protection and a human approving the merge are the final word, not Claude’s summary of what it did.

A short list to copy

  • CLAUDE.md: commands, gotchas, decisions. Under 200 lines.
  • Deny rules for .env and anything with keys in it.
  • ask rules for git push and database pushes.
  • A Stop hook for the typecheck, CI for the tests.
  • /clear between unrelated tasks, and after two failed corrections. A third correction mostly adds noise.
  • Protected main, and a person who merges.

Where we come in

Setting all of this up for your app (the CLAUDE.md, deny rules, hooks, CI with tests and a security scan on every change, staging and production) is our AI-ready setup from $600. If you’d like a senior developer to review every pull request the AI writes, the guardrail retainer starts at $500 a month on the same page. And if the app is already built and needs to go live, see taking a Claude Code or Cursor app to production.