r/ClaudeCode • u/Harshit_Ahluwalia • 4d ago
Built with Claude A Claude Code workflow for real codebases: context, plan, test, guardrails
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
•
u/AutoModerator 4d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/karol207 4d ago
For the guardrails bit, check what happens when the hook script is missing or times out. A PreToolUse hook can fail open; if it's enforcing a hard rule, set `onFailure: "block"` and test that failure case too.
0
u/Harshit_Ahluwalia 4d ago
For anyone who wants to see this workflow on a real codebase: Micheal Lanham and Chris Noring (Google Developer Expert) run a hands-on Claude agentic coding workshop on 16 Dec, [TIME + TIMEZONE], virtual. It covers setting up context, breaking work into agent-sized pieces, reviewing and steering output, and guardrails so the agent stays useful.
There's also a bundle with the follow-up Harness Engineering with Claude Code workshop (27 Jan), which goes deep on instructions, rules, permissions and hooks. 2-for-1 tickets are available too.
Code HARSHIT30 is applied through this link: https://luma.com/Agentic-Coding-with-Claude?coupon=HARSHIT30&utm_source=reddit&utm_campaign=claudecode