Claude Code is a terminal-native coding agent that reads your repo, edits files, runs commands, and iterates until a task is done. Used well, it compresses hours of grunt work into minutes. Used carelessly, it floods your diff with plausible-looking code you have to unwind. Here is how to run it like a senior engineer, not a slot machine.
Set up Claude Code so it understands your project
Install the CLI and run it from your repository root. The first thing that separates a useful session from a frustrating one is context. Claude Code automatically reads a file called CLAUDE.md at the start of every session, so put the things a new teammate would need to know there.
A strong CLAUDE.md is short and operational, not a wiki dump:
- How to run the app, the tests, the linter, and the typechecker (exact commands).
- Architecture in three or four sentences: where the entry points live, how modules talk.
- Conventions the codebase actually enforces: error handling, naming, the testing framework.
- Hard rules: "never edit generated files in
/dist," "migrations go indb/migrations."
Run /init to have Claude Code draft this file for you, then trim it. Anything stale in CLAUDE.md actively misleads the agent, so treat it like code: review it, keep it current.
How the agent loop actually works
Claude Code runs an agentic loop. You give it a goal, and it cycles: read relevant files, form a plan, make an edit or run a command, observe the result, and decide the next step. It keeps going until the task is complete or it needs your input. This is fundamentally different from autocomplete, the agent gathers its own context instead of waiting for you to paste it.
The practical lesson: feed it a clear goal and let it explore. Vague prompts like "improve this file" produce drift. Specific outcomes work:
- "Add pagination to the
/usersendpoint, 25 per page, with anextCursorin the response. Update the existing tests." - "Find why the auth middleware rejects valid tokens after a refresh, then fix it."
- "Migrate
utils/date.jsfrom Moment to date-fns and update every call site."
For anything non-trivial, ask for a plan first. Use plan mode or simply prompt "outline the approach before writing code." Reviewing a five-line plan is far cheaper than reviewing a 400-line diff built on a wrong assumption.
The tools Claude Code uses, and how to steer them
Under the hood Claude Code works through a small set of tools: it reads and edits files, searches with grep and glob, and runs shell commands. Understanding this lets you direct it precisely.
Let it run your test loop
The single highest-leverage habit is connecting the agent to your feedback loop. Tell it the test command and ask it to run tests after each change. Now the loop becomes self-correcting: it writes code, runs the suite, sees a failure, and fixes it without you in the middle. The same applies to typecheckers and linters, a red typecheck is a signal the agent can act on.
Use subagents and MCP for bigger jobs
For broad investigations, Claude Code can dispatch subagents to search the codebase in parallel and report back, which keeps the main context focused. You can also extend it through MCP servers to reach external systems, your issue tracker, a database, browser automation, so the agent can pull a ticket's details or query real data instead of guessing.
Control permissions deliberately
Claude Code asks before running commands or editing files by default. Keep that on while you learn a project. Once you trust the workflow, allowlist safe, repetitive commands (your test runner, git status) so you stop approving the same thing twenty times. Reserve broad autonomy for sandboxed or throwaway environments.
Review habits that keep AI code shippable
The agent is fast, which means it generates review surface faster than ever. Your job shifts from typing to judging. Build these habits in:
- Read every diff before you commit. Use
git diffand actually read it. Speed at writing is worthless if you ship a subtle bug. - Watch for invented APIs. Agents occasionally call functions or config keys that look right but do not exist. Your typecheck and tests catch most of this, so make sure they run.
- Reject silent scope creep. If you asked for a bug fix and got a refactor of three unrelated files, push back: "revert the changes outside
auth.js." - Keep changes small. One focused task per session is easier to review and easier to revert. Commit working states often so you always have a clean point to return to.
- Make it explain. When a fix looks like magic, ask "why did the original code fail?" If the explanation is hand-wavy, the fix probably is too.
A repeatable workflow
Put it together and a session looks like this: state a specific goal, ask for a plan, let the agent implement while running tests, then read the diff and commit. When something goes sideways, the fastest recovery is usually to reset to your last commit and re-prompt with sharper instructions, not to argue the agent into untangling its own mess.
Treat Claude Code as a fast, tireless junior engineer with perfect recall of your repo and zero ego about being corrected. Give it clear goals, wire it to your tests, and review like you mean it. That combination is where the real speed comes from.