My Claude Code Workflow for Building Features
Most people use Claude Code like a magic wand. Type a request, get code, ship it. Sometimes it works. Often it doesn't.
After building dozens of features this way, I've developed a workflow that catches issues before they ship, maintains code quality as the codebase grows, and lets me pick up exactly where I left off between sessions.
The Problem with "Vibes-Based" Development
The default Claude Code experience has three failure modes:
-
Context drift: The agent accumulates context throughout a session. By message 50, it's forgotten your coding standards and is making mistakes it wouldn't make fresh.
-
No review step: Coding agents don't critique their own work. They ship the first thing that compiles. Security vulnerabilities, edge cases, and code quality issues slip through.
-
Lost work: Clear your context window and everything's gone. Start over. Re-explain your architecture. Watch the agent make the same mistakes again.
My workflow addresses all three.
What I'm Optimizing For
- It works: Functional as intended. No bugs. Handles edge cases. Looks right.
- It's secure: No vulnerabilities. Validates input. Fails safely.
- I can easily build new features: Clean architecture. Adding functionality doesn't break existing code.
- Context window stays small: Research shows LLM performance degrades as context grows. Best practice: stay under 40%. Try to never go above 75%.
The default approach optimizes for speed. Ship fast, fix later. The first few features go smoothly, but the larger the project gets, the harder it is to add anything new.
My workflow optimizes for all four. Slower per feature, but compound time savings as the codebase grows.
The Default Approach
Here's what most people do: ask for a feature, let the agent build it, ship it. Watch the context window fill up as the agent reads files, writes code, and accumulates conversation history.
Click Send to start the conversation
The code shipped. It even works... until you try to change plans and get double-charged, or a bad actor sends malformed webhook payloads to your endpoint.
The agent didn't review its own work. It didn't think about security. It just built what you asked for as fast as possible. And now your context window is nearly full, so any follow-up questions will get degraded responses.
My Approach
Same feature, different workflow. Watch for:
- Plan review catches security gaps before any code is written
- /clear resets the context window so the agent starts fresh
- Code review catches implementation vulnerabilities the main agent missed
- Context stays low because sub-agents get their own windows
- Session end protocol (land the plane) standardizes cleanup: tests, lint, format, commit, push
Click Send to start the conversation
The plan reviewer flags missing webhook verification. The code reviewer catches a timing attack vulnerability. Both issues would have shipped silently in the default approach.
Why Sub-Agents Work
Sub-agents are specialists. Each one gets a fresh context window dedicated entirely to enforcing specific standards, standards too detailed to fit in your main agent's context alongside everything else it needs to do.
A sub-agent is just a markdown file in .claude/agents/. Here's what a code review sub-agent looks like:
- Task: Review
git diffagainst coding standards - Guidelines: Prefer early returns. No magic numbers. Handle errors at call site. Functions do one thing. No console.log in production code...
- Output: List of issues with file locations and suggested fixes
When invoked, the sub-agent loads this file as its system prompt, does its job, and returns findings. Your main agent receives the feedback and implements fixes.
Your main agent juggles a lot: file contents, conversation history, implementation details, your requests. Load it with 2,000 words of architecture guidelines, 1,500 words of security requirements, 1,000 words of code style rules, and 800 words of testing philosophy, and it'll do a mediocre job at everything. Context is finite. Attention degrades.
Sub-agents solve this by specialization. Each sub-agent's definition contains the detailed standards it enforces:
- Plan reviewer: Your architecture patterns, design standards, security requirements
- Code reviewer: Your syntax conventions, quality standards, testing requirements
- Frontend design reviewer: Your design system, component patterns, accessibility rules
These are just examples. Any domain with detailed standards deserves its own specialist: API documentation, database migrations, performance optimization, accessibility compliance. If you find yourself repeating the same review feedback, put it in a sub-agent.
Each reviewer starts fresh, loads only its specialized context, does one job well, and returns findings. Your main agent receives the feedback and implements it, playing to its strength (execution) while the specialists handle verification.
I typically run 1-2 plan reviews per feature and 1-3 code reviews per task, depending on feature complexity. The overhead is worth it.
Quality Gates
Sub-agents catch design and implementation issues. Quality gates catch everything else.
- Tests: Run after every change. Agents break things they didn't mean to touch.
- Linting: Catches what code review misses. Unused imports, type errors, bad patterns.
- Formatting: Eliminates style drift. One command, consistent output.
I run all three before every commit. The "land the plane" protocol in my CLAUDE.md automates this: tests, lint, format, then commit. No manual steps to forget. And when something fails, the agent fixes it automatically. This ensures your codebase always remains error-free and clean.
My Setup
Before the workflow, you need the foundation:
- Global CLAUDE.md: Your coding standards, architecture patterns, and instructions that apply everywhere
- Project CLAUDE.md: Project-specific context that gets loaded automatically
- Opus 4.5: I use Opus for everything. The quality difference matters.
- Beads for task management: A CLI issue tracker that lives in your repo. Tasks persist as a JSON file, so agents can pick up where you left off across sessions.
The CLAUDE.md files are where you encode your preferences. When the agent drifts, it has a reference to come back to.
The Workflow
TL;DR: Plan mode → Review plan → Create tasks → Repeat until complete: (Clear context → Pick task → Implement → Code review → Commit)
-
Write a feature prompt, put Claude in plan mode, send
-
Run a plan reviewer sub-agent
-
Review feedback, make decisions, regenerate the plan
-
Repeat steps 2-3 until you're happy
-
Agent creates epics and issues with verbose task descriptions
-
Clear context window
-
Ask "What's next?", agent pulls highest priority unblocked tasks
-
Pick an unblocked task, agent writes the code
-
Run a code reviewer sub-agent
-
Review feedback, agent fixes issues
-
Repeat steps 9-10 until you're happy
-
Say "land the plane", which triggers a sequence defined in my CLAUDE.md:
- File issues for follow-up work
- Run quality gates (tests, linters, builds)
- Update issue statuses
- Push to remote
- Clean up git state
- Remove temporary files
- Suggest next task
-
Go back to step 6. Repeat until the feature is complete.
The Key Insight
AI agents are powerful but directionless. They'll build whatever you ask, however you ask for it. The workflow provides the direction:
- Plan mode forces thinking before doing
- Sub-agents provide independent verification
- Persistent tasks maintain continuity across sessions
- Quality gates catch what slips through
- Land the plane automates the cleanup you'd otherwise forget
The agent does the heavy lifting. The workflow ensures it's lifting in the right direction.
Start Here
You don't need to adopt the full workflow immediately. Start with one change:
Set up a code review sub-agent. Run /agents, select "create new agent", and describe what you want: "Create a code review sub-agent that checks for security vulnerabilities, edge cases, and our coding standards." Claude generates a solid foundation you can customize. After your agent writes code, say "run a code review" and the fresh context catches what the implementation mindset misses.
Once that feels natural, add plan mode. Then persistent tasks. The workflow is modular: take what works, leave what doesn't.
Want more like this? Get my best AI tips in your inbox.