Turn Claude Code into a Senior Engineer with a 9‑Step Loop
The article outlines a disciplined nine‑step workflow—exploration, plan mode, project‑wide CLAUDE.md rules, incremental builds, enforced hooks, automated testing, a review sub‑agent, iterative fixes, and a final slash‑command ship—to make Claude Code operate like a senior software engineer rather than a junior assistant.
Most developers treat Claude Code as a junior engineer that they constantly supervise: they feed a requirement, watch it edit files, glance at the result, and move on. While functional, this is not the intended usage.
A senior engineer first understands the codebase, creates a plan, writes changes, runs tests, follows team standards, conducts reviews, and finally ships. Claude Code already provides the primitives to replicate this disciplined loop.
1. Explore First
Claude Code includes an Explore sub‑agent that reads the code in read‑only mode within its own context window, preventing accidental modifications. This step ensures the model grasps the code structure before any changes.
START WITH EXPLORATION
# 先让 Explore subagent(探索子智能代理)摸清地形
"Explore how authentication works across this codebase.
Map the files involved, the data flow, and anything that
looks fragile. Don't change anything yet."2. Use Plan Mode
Before writing code, activate Plan mode so Claude can outline the implementation without executing actions. The generated step‑by‑step plan is reviewed and approved, preventing bad designs from being materialized.
PLAN MODE
# 进入 plan mode(计划模式),让它先说明方案
"In plan mode: lay out exactly how you'd add rate limiting
to the API. List the files you'll touch, the order, and the
risks. Wait for my approval before writing code."3. Define Project Standards with CLAUDE.md
Write a CLAUDE.md file at the repository root that encodes conventions, commands, and rules (e.g., TypeScript strict mode, no any, test on every new function). Claude reads this file each session, aligning its behavior with team standards.
CLAUDE.md // PROJECT ROOT
# Project Standards
## Conventions
- TypeScript strict mode, no `any`
- Functions over classes where possible
- Every new function gets a test
## Commands
- Test: `npm run test`
- Lint: `npm run lint`
- Build: `npm run build`
## Rules
- Never edit files in /generated
- Match the existing file's style before adding code
- If unsure about an approach, ask before building4. Build in Small, Reviewable Chunks
After plan approval, Claude makes incremental changes rather than a massive diff, making verification and rollback easier.
BUILD INSTRUCTION
"Implement step 1 of the approved plan only. Keep the change
small and self-contained. Follow the conventions in CLAUDE.md.
Stop after step 1 so I can verify before you continue."5. Enforce Non‑Negotiable Rules with Hooks
Hooks are deterministic shell commands that run at specific points, turning advisory rules in CLAUDE.md into guarantees (e.g., run lint and tests after every edit, block commits on test failures).
EXAMPLE HOOK // RUN LINT + TESTS AFTER EVERY EDIT
# .claude/settings.json (PostToolUse hook)
{
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"command": "npm run lint && npm run test"
}]
}
}6. Prove Changes with Tests
Never accept a change based on appearance alone. Require Claude to write tests covering the modification, including edge cases, and run the full suite before proceeding.
TEST INSTRUCTION
"Write tests that cover this change, including the edge case
where the token is expired. Run the full suite and show me
the results. If anything fails, fix it before continuing."7. Launch a Review Sub‑Agent
Instantiate a second sub‑agent with a clean context to critically review the diff, checking for security issues, missed edge cases, and violations of CLAUDE.md. The reviewer reports problems without fixing them.
REVIEW SUBAGENT
"Launch a review subagent. Its job: review the diff I just
made as a skeptical senior engineer. Check for security
issues, missed edge cases, and anything that violates
CLAUDE.md. Report problems, do not fix them yet."8. Fix, Retest, and Re‑review Until Clean
Iteratively address every reviewer comment, rerun tests, and relaunch the review sub‑agent. The loop closes only when the review returns clean.
CLOSE THE LOOP
"Address every issue the reviewer raised. After fixing,
re-run the tests AND launch the review subagent again on
the updated diff. Repeat until the review comes back clean.
Show me the final review verdict."9. Ship with a Slash Command
Package the entire nine‑step loop into a custom slash command (e.g., /ship) so the whole pipeline can be triggered with a single command, committing with a clear message and opening a PR.
.claude/commands/ship.md // YOUR WHOLE LOOP, ONE COMMAND
# /ship : run the full senior-engineer loop
1. Explore the relevant code (Explore subagent)
2. Plan the approach and wait for my approval
3. Build per CLAUDE.md, in small pieces
4. Write + run tests (hooks enforce this)
5. Launch a review subagent on the diff
6. Fix issues, re-test, re-review until clean
7. Commit with a clear message and open a PRThese steps map the disciplined workflow of senior engineers onto Claude Code’s built‑in primitives, turning a simple code‑generation tool into a repeatable, high‑quality development pipeline.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
