Skip to content

Working with AI Coding Agents

Nov 2026

A coding agent knows only what is in its context window: the code it chose to read, the files you pointed it at, and your instructions. It cannot see the meeting where you decided something, and it stops when the work looks done. Your job is therefore three things: supply the context it cannot find, specify what done means, and make it prove the result. Instructions are requests the model may weigh; hooks, permissions and CI are rules the harness enforces.

Put inLeave out
Build, test, lint commandsDirectory tours
Decisions not visible in codeStyle a linter enforces
Traps: generated dirs, env varsAnything found by reading code
Links to specs and ADRsPasted docs (link instead)

AGENTS.md is a README for agents, an open format now stewarded by the Agentic AI Foundation under the Linux Foundation; in a monorepo the nearest file to the edited code wins. Claude Code reads CLAUDE.md, falls back to AGENTS.md when no CLAUDE.md exists, and its docs recommend under 200 lines. Before writing a line, ask: could the agent find this by reading the repo, and would it look?

AGENTS.md
- Test: `npm test`; lint: `npm run lint`
- Never edit `src/gen/`; run `npm run gen`
- Integration tests need `DATABASE_URL`
- Money is integer cents; see docs/adr/0007.md

Gotcha: Do not let the agent write this file for you. An ETH Zurich study (2026) found LLM-generated context files slightly lowered task success while raising cost over 20%; agents obey every line, so needless instructions make tasks harder.

Instead ofWrite
“fix the login bug”Symptom, location, failing test first
“add a widget”The pattern file to copy, the limits
Prose about outputThe command that proves it works
An implied scope“Be ambitious: empty and error states”

A specific prompt gives the agent facts it cannot get elsewhere: the symptom, where to look, what “fixed” means, and your preference between two reasonable designs. Hand over artifacts — the failing log, the screenshot, the file path — rather than describing them.

Users report login fails after session timeout.
Look at token refresh in src/auth/. Write a
failing test that reproduces it, then fix it.
Done = `npm test -- auth` passes; no new deps.
PhaseOutput
SpecifyWhat and why: user stories, acceptance criteria
PlanTech choices, design, data model
TasksSmall ordered steps, each checkable
ImplementCode against one task at a time

For anything larger than a bug fix, separate deciding from doing: have the agent interview you or draft a spec, review it, then build from it in a fresh session with a clean context. GitHub’s Spec Kit scripts this as constitution, specify, plan, tasks, implement; Kiro writes requirements.md, design.md and tasks.md. The spec doubles as the yardstick for review.

/speckit-constitution Principles: tests first
/speckit-specify Album view grouped by date
/speckit-plan Vite, vanilla JS, SQLite metadata
/speckit-tasks
/speckit-implement

Warning: Thoughtworks’ Radar (Vol. 33) rates spec-driven development “Assess” and warns of drift back to heavy up-front specification and big-bang releases. Keep specs per feature, not per quarter.

TaskApproach
One-file fix with a testDelegate directly
Feature across layersSpec, then one task per session
Unclear problemExplore together; no edits yet
Novel design, security coreWrite it yourself; agent assists
Output you cannot verifyDo not delegate

Small batches are one of DORA’s seven capabilities that amplify AI’s benefit: a small diff is cheap to review and cheap to throw away. Start a fresh session per task so earlier dead ends do not ride along in the context. If you could not tell a correct result from a plausible one, the agent will not save you time.

Task 3 of 7: add rate limit to POST /login
Scope: src/auth/limit.ts and its test only
Check: npm test -- limit && npm run lint
Out of scope: refactors, dependency changes
NeedMechanism
Never touch a pathDeny rule, e.g. Edit(src/gen/**)
Never read secretsDeny Read(./.env)
Run a check every timeHook (e.g. Stop, PostToolUse)
Allow safe commands silentlyAllow rule Bash(npm test *)

Anything that must happen every time belongs in configuration the harness enforces, not in a prompt. Claude Code checks hooks and deny rules before allow rules, and a deny wins even when everything else is auto-approved. If you keep adding emphasis to a context-file line and the agent still misses it, make it a hook.

{
"permissions": {
"allow": ["Bash(npm test *)"],
"deny": [
"Read(./.env)",
"Edit(src/gen/**)",
"Bash(git push *)"
]
}
}

Gotcha: In Claude Code, Write(path) rules never match and .claudeignore has no effect. Path rules are checked only for Edit(...) (which covers Write) and Read(...).

Pays offCosts
Parallel independent workTokens for every subagent
Long output kept out of main contextTime re-gathering context
A reviewer that never saw the codeSame model: not a smarter answer
Fewer tools, e.g. read-onlyOnly its summary comes back

A subagent runs in a fresh context and returns only its final message. Use one to fan out a wide search, run a noisy test suite, or review a diff with read-only tools enforced by the harness rather than requested in a prompt. Point simple jobs at a cheaper model.

---
name: reviewer
description: Reviews a diff against its spec.
tools: Read, Grep, Glob
model: haiku
---
Compare the changed files to the spec given.
Report only gaps that affect correctness.
Skip style.
CheckStrength
“Run the tests” in the promptAgent decides when it is satisfied
Stop hook that runs the checkHarness refuses to finish on failure
Fresh-context reviewerNot swayed by its own reasoning
CI and branch protectionFinal gate, outside the agent

An agent with nothing to run that says pass or fail stops when the code looks right, which makes you the test suite. Give it a test, a build exit code, a linter or a fixture diff, and ask for evidence: the command it ran and the output, not “all tests pass”.

{
"hooks": {
"Stop": [{ "hooks": [{
"type": "command",
"command":
"npx tsc --noEmit 1>&2 || exit 2"
}] }]
}
}

Tip: Exit code 2 blocks the stop and feeds stderr back to the agent as the reason, so it keeps fixing until the check passes — Claude Code caps repeated blocks to prevent an endless loop.

Look forWhy
Invented APIs or optionsPlausible names that do not exist
Scope creepUnasked refactors hide the real change
Deleted, skipped or loosened testsThe easy way to “pass”
New dependenciesSupply-chain and licence risk
Secrets, logs, broad permissionsLeaks the agent did not notice

Review the diff against the spec, not against the agent’s summary of it. Thoughtworks puts “complacency with AI-generated code” on Hold: agents produce larger change sets that are harder to review, and duplication and churn rise. Read the test changes first — they show what the agent decided “correct” means.

Terminal window
git diff --stat main...HEAD
git diff main...HEAD -- '*test*' '*spec*'
git diff main...HEAD -- package.json