Claude Code works great in a demo repo and surprisingly badly in a real one, unless you set it up for the real one. This is the workflow that makes the difference:
1. Context: make CLAUDE.md earn its place
Run /init to generate a starting CLAUDE.md, then edit it down to what actually matters:
- How to build, run and test (exact commands)
- Conventions that aren't obvious from the code (error handling, logging, naming)
- Areas it must not touch without asking (migrations, auth, generated code)
- Where things live in an unusual repo layout
Short and specific beats long and general. Anything Claude keeps getting wrong goes in here.
2. Plan: use plan mode for anything non-trivial
Have it explore and propose a plan before editing. Check that it found the right files, understood the existing pattern, and plans to add tests. Fix the plan, then let it execute.
3. Test: make tests the stop condition
"Done" means the relevant tests pass, not "I've made the changes". For bugs, have it write a failing test that reproduces the issue first, then fix it. That's the single best habit for agentic debugging.
4. Review: steer early, not late
Watch the first few edits. If it's heading the wrong way, interrupt and redirect. Reviewing a finished 600-line diff is where most of the pain comes from.
5. Guardrails: turn repeated corrections into hooks and permissions
If you keep telling it the same thing, it should become a rule in CLAUDE.md. If it must never happen, make it a hook or a permission rule, so it's enforced rather than requested.
6. Reset context between tasks
Use /clear when switching to an unrelated task. Stale context from the last job is a common cause of strange edits.
What's the one line in your CLAUDE.md that made the biggest difference?
Worth checking the workshop in comments