Field note

What Are AI Coding Agents? A Practical Guide

Learn how AI coding agents work, when to use them, and how to build one with tools, repository context, tests, and bounded execution.

An AI coding agent is not just a chat window attached to a repository. It is a system that can inspect a codebase, decide what to do, use tools such as search and shell commands, edit files, run tests, and continue until the task is complete or a boundary stops it.

That distinction matters. A language model can suggest code. An agent turns the suggestion into a sequence of observable actions. The model proposes the next step; the runtime supplies repository context, tools, permissions, and stopping rules; the test suite or acceptance checks decide whether the result is usable.

The simplest useful version is still a loop. It reads the task and repository state, chooses an action, executes that action through a tool, inspects the result, and then continues, revises, or stops.

Everything beyond that loop is an architectural choice.

Workflow or agent?

The term agent gets used for systems that behave very differently. Anthropic draws a useful line between workflows and agents in its guide to building effective agents.

A workflow follows a code-defined path. A model might classify an issue, but the application decides which fixed sequence runs next. This is predictable and easier to test.

An agent lets the model direct its own process and tool usage. That flexibility is useful when the path cannot be known in advance, but it increases latency, cost, and failure modes.

Start with a workflow when the task has clear stages. Add an agent only when model-driven decisions create enough value to justify the extra control surface. A coding assistant that always runs lint, repair, and test is a workflow. One that decides which files to inspect, which experiment to try, and when the task is complete is an agent.

What makes a system a coding agent?

Four capabilities turn an LLM application into a coding agent.

Repository context

The agent needs a map of the code, not every file pasted into the prompt. Mature coding tools use search, file reads, symbols, dependency information, and progressively assembled context.

Aider, for example, describes building a map of an entire codebase so the model can work more effectively in larger projects. The important design choice is selective context. Load the files that explain the current task, then update that set after each meaningful change.

Tools that affect the workspace

A coding agent needs more than text generation. It needs repository search, structured edits, shell commands, test and build execution, version-control inspection, and access to external documentation or issue trackers.

Model Context Protocol standardizes how AI applications connect to external systems and tools. MCP can reduce the amount of custom integration code, but it does not replace permission checks or task-level boundaries.

A controlled action loop

Tool output has to return to the model in a form it can use. The runtime must preserve tool-call identity, arguments, results, and the current conversation state. A failed edit, a timeout, or an unexpected exit code should become explicit feedback rather than disappearing into the next prompt.

This loop is where many apparent agent failures actually live. The model may be capable, while the execution layer loses context or presents ambiguous tool results.

Stop conditions and verification

An agent should stop when it has a concrete reason, not when the transcript feels complete. Strong stopping evidence includes passing tests, a clean type check, a requested diff, or a validated external response.

A production system also needs hard boundaries: maximum steps, maximum spend, allowed directories, command allowlists, timeouts, and human approval for destructive actions. Autonomy is useful only inside boundaries the system can explain.

The main architecture patterns

Anthropic describes five composable patterns. They are useful because they let a team add autonomy only where the task benefits from it.

Prompt chaining

Break a task into fixed stages. A model might create a plan, a checker validates the plan, and an executor applies it. This pattern is slower, but each step is easier to evaluate.

Routing

Classify the request and send it to a specialized path. A coding agent might route documentation questions away from repository edits, or send a failing test to a debugging workflow with different tools and context.

Parallelization

Split independent work across workers. Documentation, test analysis, and code search can run concurrently when they do not depend on one another. Parallelism reduces wall-clock time but requires explicit aggregation rules.

Orchestrator-workers

A model dynamically decomposes work while ordinary code coordinates workers. This is the useful middle ground for open-ended coding tasks: the application owns execution and permissions, while the model decides what subtasks matter.

Evaluator-optimizer

One pass produces a result and another critiques or improves it. For code, the evaluator can be a test suite, static analysis, or a rubric. Keep the loop bounded; self-critique without an external signal often produces confident rewrites rather than better code.

For a concrete implementation of fanout and pipeline coordination, see AI agent orchestration: fanout vs. pipeline patterns. For the production lessons that emerged from running these patterns on a real codebase, see Agentic AI: production patterns that hold up.

How to build a useful AI coding agent

A reliable first version is smaller than most frameworks suggest. Choose one bounded task, such as fixing a failing test, rather than “finish the project.” Expose a small tool set, starting with read, search, edit, and test; every extra tool creates another failure path.

Return structured results: file paths, diffs, exit codes, and bounded output. Keep a compact transcript containing the task, decisions, changed files, and latest tool results instead of preserving an ever-growing raw log. Make verification executable through tests, type checks, and acceptance scripts. Add cost and step budgets, then evaluate accepted outcomes. A lower-priced agent that needs three corrections may cost more than a stronger agent that succeeds once.

Anthropic’s guidance is direct: start with the simplest solution and add complexity only when the task requires it. That is especially important for coding, where an agent can turn an incorrect assumption into a large diff very quickly.

Prompt caching and cost

Repeated repository context is expensive. A coding agent often resends system instructions, tool definitions, repository maps, and recent conversation state. Prompt caching can reuse stable prefixes, but only if those prefixes remain stable.

Do not place timestamps, random IDs, or rapidly changing task status at the front of the prompt. Put stable instructions first and volatile state later. Measure cache hit rate in the actual tool rather than assuming provider-side caching will apply.

The mechanics and refresh-cycle tradeoffs are covered in Prompt caching in practice.

Choosing a coding-agent tool

The best runtime depends on the work. Compare tools on repository indexing, edit behavior, test execution, automation, and observability rather than benchmark claims alone.

My comparison of Claude Code, Aider, Cursor Agent, and Codex CLI covers the tooling layer in detail. The short version is straightforward. Choose a terminal-first agent for repository-native workflows and an editor agent for changes inside an active IDE session. Evaluate cost on accepted work, including retries and supervision, and verify tool permissions before handing an agent a real repository.

The operating model

AI coding agents are not autonomous employees. They are fast, variable systems that need explicit engineering around them.

The reliable pattern is narrow scope, observable actions, deterministic checks, and reversible changes. Start with a workflow. Add model-directed planning only where the path cannot be predicted safely. Add multiple agents only when the work truly decomposes.

That discipline produces better outcomes than adding more frameworks. It also makes the agent cheaper to run, easier to debug, and safer to trust.

FAQ

What are AI coding agents?

Systems that use a model to take actions on a repository rather than only suggest text: they read files, run tools, and change the workspace inside a controlled loop. The loop needs a stop condition and a verification step or it is not usable on real work.

What are AI agents and how do they work?

An agent pairs a model with tools and a goal. The model picks the next action, the harness executes it, and the result feeds back into the next decision, repeating until a stop condition is met. A coding agent is the same shape with repository access and a narrow scope.

Is an AI coding agent the same as a workflow?

No. A workflow follows a path you defined in advance; an agent decides its own next step. Start with a workflow, and add model-directed planning only where the path genuinely cannot be predicted.

Sources

The primary sources are Anthropic’s Building effective agents, the Model Context Protocol documentation, and Aider’s project documentation.