Coding Agents
Coding-agent guidance covers task setup, repo-owned context, tools, workspaces, verification, handoff proof, feedback loops, and maintainer review flow. It treats agents as workers in a system whose output should be reviewable, durable, and easy to integrate.
Core Preference
Treat agents as productive workers in a system, not as magic sessions to supervise line by line. A good agent workflow gives the agent enough objective, context, tools, authority, and validation to produce a reviewable artifact while preserving human attention for ambiguity and judgment.
Optimize for:
- Objectives with boundaries over brittle step lists.
- Durable repo-owned context over transient prompt memory.
- Tools, checks, and workspaces over repeated human steering.
- Review evidence over confidence language.
- Long-term coherence over one prompt's local success.
Objectives and Acceptance
Define the work before delegating it or starting judgment-heavy execution. The useful setup is not a step list; it is a clear objective with boundaries, success criteria, available tools, and expected proof at handoff. For naming, grouping, review-shape, public API, or other taste-heavy work, establish the quality bar before changing the artifact, then leave room for the agent to choose a better route inside safe boundaries.
Use Give Agents Objectives With Boundaries when a task should preserve the user's goal without freezing the implementation route. Use Define Good Before Judgment-Heavy Work when the acceptance criteria, evidence, or remaining human judgment need to be explicit. Use Agent Give Objectives With Boundaries and Agent Define Good Before Judgment-Heavy Work when this guidance needs compact agent-execution wording.
For ambiguous work, spend human attention at the ambiguity boundary. Use Spend Human Attention On Ambiguity before asking an agent to bury product, architecture, security, or public API decisions inside a large diff.
Context and Knowledge
Agents work best when the repo is legible and the relevant context arrives at the point of use. Keep
large or reusable context on disk, keep AGENTS.md as a map, and make accepted artifacts part of
the discovery path.
Use Distill From Blessed Artifacts when existing code, tests, docs, or reviews are denser than the prompt. Use Deliver Context Just In Time and Use Disk As Context Sink when the context is too large or too specialized for one static instruction block.
Use Use AGENTS.md As Map to keep top-level instructions compact and linked. Use Optimize For Agent Legibility when repo structure, docs, commands, and runtime signals should help future agents find and validate the right thing. For ongoing projects whose software doctrine no longer fits in a short map, use Project Operating Manual as the project-owned interpretation layer between the broad catalog and the current repo. Use Agent Keep Durable Context On Disk, Agent Use AGENTS.md As Map, and Agent Distill From Blessed Artifacts when context should live in repo-owned artifacts rather than transient prompt memory.
Tools and Guardrails
Prefer tools and checks over heroic prompting. If a mistake is repeatable, move it into the cheapest enforcement layer: type shape, API design, lint, test, formatter, schema, template, runbook, or review checklist.
Use Prefer Tools Over Prompts, Make Bad Output Mechanically Hard, and Teach Agents Through Tools when feedback points to a missing guardrail or capability. Use Agent Prefer Tools Over Prompts and Agent Make Bad Output Hard when repeated prompt steering should become a tool, check, template, or schema.
Use Make The Change Easy First when the requested change is risky because the repo lacks a harness, test, boundary, or workflow that would make the behavior change straightforward. Use Code Is Memory Of Process and Keep Automations Repo Owned when stable process knowledge should become a checked artifact.
For systems that agents can reload, extend, or self-modify, prefer staged changes with validation and rollback over direct mutation of the live runtime. Generated or guest code should be inspectable after failure without replacing the last known good behavior.
Use Agent Prefer Build Preserving Edits when a long broken state would make recovery and review harder.
Workspaces and Capabilities
Keep agent work isolated by task. Each independent edit should have a clear workspace, source-control change, ownership boundary, logs, and cleanup policy. Do not make a human track five interactive sessions when the work can be represented as durable tasks.
Use Manage Agent Work Not Sessions, Isolate Agent Workspaces, and Preserve Agent Context Coherence when parallel or long-running work would otherwise smear state across threads and checkouts. Use Agent Isolate Workspaces By Task and Agent Preserve Human Work when multiple edits, agents, or human changes share source-control state.
Grant only the authority the task needs. Use Grant Scoped Agent Capabilities and Keep Secrets Out Of Context when credentials, external systems, or privileged tools are involved. Use Agent Grant Scoped Capabilities and Agent Keep Secrets Out Of Context when task authority, credentials, or external systems need explicit limits.
Verification and Review
Agent output should arrive with proof. The right proof depends on the task: failing and passing tests, logs, screenshots, traces, benchmark output, specialist reviews, canaries, or deployment notes.
Review Stance
Review agent output from the perspective of a future maintainer who did not write the code. Prioritize correctness, edge cases, API clarity, documentation truthfulness, rendering behavior, terminal-state behavior, and focused tests for the contract.
When code is hard to read, identify the cause precisely: concept mixing, poor ordering, hidden state, vague names, too much abstraction, or missing tests.
Edit Preparation
Before editing, identify the owning module, local dependencies, existing tests, and narrowest useful validation command. While editing, preserve current user behavior unless the task intentionally changes it. Before handoff, report focused checks, broad checks, skipped checks, residual risk, and follow-up.
Handoff Shape
Handoff notes should say what changed, where the important files are, what validation ran, what did not run, and what risk remains. Avoid long implementation diaries.
Use Review Proof Not Just Code, Produce Review Packets, and Report Verification Honestly when handing work to a maintainer. Use Review Agent Output As Future Maintainer when evaluating whether agent output is maintainable after the session context disappears. Use Agent Produce Review Packets and Agent Report Proof In Handoffs when a handoff needs compact proof-focused wording.
For risky operations, use Verify With Canaries Before Cutover. For security work, use Prove Security Impact so hypotheses, reachability, and concrete impact stay separate.
Feedback Loops
Every repeated correction is a chance to improve the system. Capture reusable feedback in patterns, guides, tools, tests, templates, or runbooks so future sessions do not need the same steering.
Use Turn Feedback Into Guidance, Record Agent Operating Lessons, Close The Agent Loop, and Garbage Collect Agent Drift when agent work exposes a repeated failure mode.
Budget time and tokens for loops that reduce human attention and improve outcomes. Use Budget Tokens For Feedback Loops when evaluating review agents, cleanup loops, security scans, docs checks, or harness evals. Use Agent Budget For Feedback Loops and Agent Turn Feedback Into Guidance when repeated corrections should become durable guidance or automation.
Maintainer Review Loop
After a validated chunk, present concrete next chunks instead of vague continuation prompts. Put
I've reviewed, do the next thing first when the expected path is for the maintainer to accept the
current chunk and continue. Name the actual next thing in that option, and do the appropriate
workflow work behind it: mark reviewed material, update the jj description, start a fresh jj change
when the next unit is separate, and then begin that named next chunk.
Explain why each offered path is worth choosing. Include the tradeoff that matters for review: scope, risk, latency, validation depth, naming, structure, or follow-up cost. If the maintainer gives feedback instead of choosing the next chunk, address that feedback before continuing.
For fast manual review sessions, separate note capture from correction. Capture reviewer notes in a durable queue without applying corrections unless asked, then apply corrections later in scoped batches such as one content type, one page, or one ownership area.
Use Agent Present Concrete Next Options and Agent Separate Notes From Corrections when maintainer review needs clear next choices or a separate review-note queue.
Long-Term Coherence
Agent work should scale to the next many changes. A correct-looking patch can still damage the system if it adds parallel concepts, hides side effects, weakens tests, or loses the repository's shape.
Use Optimize For Long Term Coherence, Preserve Intent Over Literalism, and Encode Nonfunctional Requirements when the prompt is narrower than the actual quality bar. Use Agent Encode Nonfunctional Requirements and Agent Preserve Intent when acceptance depends on compatibility, privacy, performance, determinism, or the user's real goal.
Use Ask What Were You Trying To Achieve when surprising legacy code may be preserving an old intent. Use Choose Good Enough Tools and Prefer In Distribution Tools when selecting tooling for agent-friendly work.
Agent Snippet
For copyable AGENTS.md guidance, use Coding Agent Workflow Instructions. For a
broader repo baseline, use Core Agent Instructions. For a compressed execution pack
generated from reviewed rules, use Reviewed Rule Agent Pack.
Review Questions
Task Setup
- Is the objective clear without overfitting the implementation path?
- Are boundaries, capabilities, and forbidden actions explicit?
- Is the relevant context on disk or linked from a stable owner?
- Can the agent validate the work with tools it can access?
Handoff And Loop
- Does the handoff include proof instead of confidence language?
- Did feedback become a reusable improvement where appropriate?
- Does the next-option list include a reviewed-and-continue path when that is the normal flow?
- Does each option explain why that path would be chosen?
Coherence
- Does this change preserve the repo's long-term concepts and reviewability?