Work with agents · Step 6 of 14

Working with a coding agent

A coding agent reads your project, edits files, runs commands, and checks its own work. Getting good results from one is a skill of its own — closer to delegating to a capable new teammate than to typing a prompt.

What you are working with

A coding agent — Claude Code, Cursor's agent, Copilot's agent mode, and others — is the agent loop pointed at a codebase, with tools to search, read, edit, and run a shell. The examples here use Claude Code's names; the habits carry over to all of them.

1. Give the project a briefing file

The agent starts every session knowing nothing about your project. An instruction file in the repository root — CLAUDE.md, or the cross-tool AGENTS.md — is loaded automatically each time. Put in it what a new developer would need on day one, and nothing they could read from the code:

# Project notes

- Build: `npm run build`. Tests: `npm test` (run before finishing).
- The API lives in src/api; never edit src/generated (it is rebuilt).
- We use date-fns, not moment. Money is integer cents, never floats.
- Database changes need a migration in db/migrations.

Keep it short. Every line is read on every task, so a long file costs money and buries the lines that matter. When the agent makes the same mistake twice, that is the signal to add a line.

2. Brief the task like a ticket

Everything from Prompting applies, and one thing matters more than the rest: say how the agent can tell it is done.

Weak:
  "Fix the date bug."

Strong:
  "Orders placed after 11pm UTC show tomorrow's date on the
   invoice page. Find the cause and fix it. Add a test that
   fails before your fix and passes after. Don't change the
   database schema."

3. Plan first when the task is big

For anything touching more than a couple of files, ask for a plan before any edits (most tools have a plan mode for this). Reading a plan takes a minute; unwinding a wrong approach across twenty files takes an afternoon. For a one-line fix, skip it.

4. Let it verify its own work

This is the difference between an agent that helps and one that makes work. If it can run the tests, the type checker, the linter, or the app itself, it catches its own mistakes and fixes them before you ever look. If it can't, it will tell you with confidence that code it never ran is working.

  • Make sure the test and build commands are in the briefing file.
  • For a bug, ask for a failing test first, then the fix.
  • For UI work, give it a way to see the page — a screenshot tool or a browser.

5. Set permissions on purpose

Agents ask before running commands, and you can pre-approve the safe ones. Approve reading, searching, and running tests freely. Keep a human in front of anything that is hard to undo: pushing, deploying, deleting, touching production. Approving everything to stop the prompts is how people lose work.

6. Keep sessions short and focused

One task per session. When you switch tasks, start a new session (/clear) — a window full of the last task makes the next one worse, as Context explained. If a session has gone wrong, don't argue with it for ten messages: start over with a better brief. It is faster.

7. Review like it is a colleague's pull request

You are accountable for what you merge. Read the diff, not the summary — the summary says what the agent intended, the diff says what it did. Watch for:

  • Changes outside what you asked for.
  • A test that was weakened or deleted to make it pass.
  • An error swallowed instead of handled.
  • A new dependency you didn't ask for.

Ask for small changes so this stays possible. A two-thousand-line diff does not get reviewed; it gets approved.

Commit before you delegate. With a clean working tree, anything the agent does is one git diff to inspect and one command to undo. It is the cheapest safety net there is.

Going further

  • Sub-agents take a side task — "find every caller of this function" — in a separate context and return just the answer, keeping your main session clean.
  • Background and cloud agents work on a ticket while you do something else and come back with a pull request. The brief matters even more: nobody is there to answer questions.
  • Your own tools — connect an MCP server so the agent can query your database or your ticket system.
  • Your own know-how — package a procedure the agent should follow as a skill. That is the next step.
An agent with a shell can do anything you can. Before pointing one at anything that matters, read Security.