Vibe Coding Patterns
Move quickly with Claude Code while preserving engineering control.
Key takeaways
- Vibe coding describes intent and lets the agent build it; it works only when speed is paired with a tight intent-code-verification loop.
- Follow the four-phase loop — Explore (plan mode), Plan, Implement, Commit — and repeat it instead of asking for one giant speculative change; skip planning when you can describe the diff in one sentence.
- Match session shape to the work: parallel worktree sessions for independent features, separate sessions for bug fix versus feature, and the Writer/Reviewer pattern for unbiased review.
- Closing the verification loop is the central practice: give the agent a pass/fail signal (tests, build exit code,
/goal, a Stop hook, or a/code-reviewsubagent) and require evidence over assertions. - Avoid documented anti-patterns — the kitchen-sink session, repeated correcting, trust-then-verify gaps, bloated
CLAUDE.md, and unscoped exploration — each with/clear, scoping, or verification as the fix.
Vibe coding is a way of working where you describe the intent and let the agent figure out how to build it. It works when speed is paired with tight feedback. The goal is not to make the agent guess more; it is to shorten the loop between intent, code, and verification.
Productive Loop
The official best practice is a four-phase workflow that separates research and planning from implementation, so the agent does not jump straight to coding and solve the wrong problem.
- Explore. Enter plan mode so the agent reads files and answers questions without making changes. State the user-facing behavior you want.
- Plan. Ask the agent to produce a detailed implementation plan: which files change, what the flow is, what is out of scope.
- Implement. Switch out of plan mode and let the agent code a narrow slice, verifying against its plan.
- Commit. Run the focused check, review the diff, then commit with a descriptive message and open a PR before widening scope.
Repeat the loop instead of asking for one giant speculative change.
Plan mode is optional for small, clear tasks
Plan mode is useful but adds overhead. When the scope is clear and the fix is small (a typo, a log line, a variable rename), ask the agent to do it directly. Planning pays off most when the approach is uncertain, the change spans multiple files, or you are unfamiliar with the code. If you can describe the diff in one sentence, skip the plan.
Plan mode can be entered with Shift+Tab mid-session, or started directly with
claude --permission-mode plan. Press Ctrl+G to open the plan in your editor before the agent
proceeds.
Multi-session Strategy
Conversations are persistent and reversible, so match the session shape to the work.
| Situation | Strategy |
|---|---|
| 2-3 independent features | Parallel sessions, one git worktree each |
| Analyze, then build | Plan mode to analyze, then a separate implementation session |
| Large refactor | Analyze first, then split into per-part sessions |
| Bug fix + feature work | Separate sessions to avoid context pollution |
| Repetitive simple tasks | Slash command or skill, run in headless mode |
For isolated experiments, start a worktree session so concurrent edits never collide:
claude --worktree feature-auth # isolated checkout on its own branch
claude --worktree bugfix-123 # a second isolated session in another terminalA fresh context also improves review quality: the reviewer is not biased toward code it just wrote. The Writer/Reviewer pattern (one session implements, another reviews the diff) and the test-first pattern (one session writes tests, another writes code to pass them) both rely on this.
Prompt Patterns
The more precise your instructions, the fewer corrections you need. Reference specific files, state constraints, and point to example patterns.
Good:
Add JWT refresh logic in src/auth/login.ts: when the token expires, refresh
automatically using the refresh token. Implement it inside the existing
handleLogin function. On failure, redirect to /login.Add English locale support for the selected handbook only.
Do not let unsupported books fall back to Korean.
Update route filtering, sitemap, and E2E coverage.Risky:
Improve login.
Internationalize everything.The good prompts name the file, the behavior, the constraint, and the error path. The risky prompts invite accidental scope expansion. A vague prompt is fine only when you are exploring and can afford to course-correct (for example, "what would you improve in this file?").
Provide rich context
The official docs emphasize feeding concrete context into the prompt:
- Reference files with
@(e.g.@src/utils/auth.js). The agent reads the file before responding, and theCLAUDE.mdfiles in that file's directory and parent directories are added to context. - Paste images (screenshots, design mockups) by drag-and-drop or with
Ctrl+Vin the CLI. UseCtrl+V, notCmd+V, even on macOS. - Pipe in data directly, e.g.
cat error.log | claude. - Reference existing patterns in the codebase ("look at how the home page widgets are built and follow that pattern").
Close the Verification Loop
Give the agent a way to verify its own work
This is the central best practice. The agent stops when the work "looks done," so without a check it can run, you become the verification loop. Give it something that returns a pass/fail signal it can read (a test suite, a build exit code, a linter, a script that diffs output against a fixture, or a screenshot compared against a design) and it iterates until the check passes.
Choose how hard the check gates the stop:
- In one prompt. Ask the agent to run the check and iterate in the same message ("implement it, run the tests, and fix any failures").
- Across a session. Set the check as a
/goalcondition. A separate evaluator re-checks it after every turn and the agent keeps working until it holds. - As a deterministic gate. A Stop hook runs your check as a script and blocks the turn from ending until it passes. Claude Code overrides the hook and ends the turn after 8 consecutive blocks.
- By a second opinion. A verification subagent or
the bundled
/code-reviewskill reviews the diff in a fresh context and tries to refute the result, so the agent doing the work is not the one grading it.
Have the agent show evidence (test output, the command and its result, a screenshot) rather than asserting success.
Keep Control
- Ask for file references when the agent makes claims.
- Require tests or a documented reason tests cannot run.
- Keep unrelated refactors out of feature work.
- Use worktrees when exploring competing approaches.
- Stop and inspect when the agent starts editing broad shared surfaces.
- Course-correct early: press
Escto stop mid-action (context is preserved),Esc + Escor/rewindto restore previous conversation/code state, or tell the agent to "undo that." - Delegate wide investigation to subagents ("use a subagent to investigate how token refresh works") so the exploration does not consume your main context.
Anti-patterns
These are the documented failure patterns, with the official fix for each.
- The kitchen sink session. One task, then something unrelated, then back again. Context fills
with irrelevant information.
Fix: run
/clearbetween unrelated tasks. - Correcting over and over. You correct the same issue more than twice and context is polluted
with failed approaches.
Fix: after two failed corrections,
/clearand write a better initial prompt that incorporates what you learned. Claude Code auto-compacts near the context limit; for finer control use/compact <instructions>or summarize part of the conversation withEsc + Esc//rewind. - The trust-then-verify gap. Accepting plausible-looking code without reading the diff or
checking edge cases.
Fix: always provide verification (tests, scripts, screenshots). If you cannot verify it, do not ship it. A green build is not proof that the UX is correct.
- The over-specified CLAUDE.md. A bloated
CLAUDE.mdcauses the agent to ignore half of it because important rules get lost.Fix: prune ruthlessly. Ask "would removing this line cause a mistake?" If not, cut it or convert it to a hook. Move occasional domain knowledge into a skill so it loads only when relevant.
- The infinite exploration. Asking the agent to "investigate" without scoping it, so it reads
hundreds of files and fills context.
Fix: scope investigations narrowly, or run them in a subagent.
Avoid letting the agent invent product copy for regulated domains, mixing feature work with formatting churn, and running package upgrades as part of unrelated fixes.
Reference Docs
- Best practices: https://code.claude.com/docs/en/best-practices
- Common workflows: https://code.claude.com/docs/en/common-workflows
- Plan mode and permission modes: https://code.claude.com/docs/en/permission-modes
- Parallel sessions with worktrees: https://code.claude.com/docs/en/worktrees
- Subagents: https://code.claude.com/docs/en/sub-agents
- Hooks (Stop hook): https://code.claude.com/docs/en/hooks