AI agents › AI coding
What is an AI coding agent? An AI that edits and tests code
What an AI coding agent is, how it differs from autocomplete and chat, how tools and test results drive it, and where it helps, shown with a real run.
If you’ve read about software development lately, you’ve almost certainly met the phrase AI coding agent. It turns up in product launches and in editor release notes alike. Perhaps you already use an editor that suggests the next line as you type, or you’ve pasted code into a chat window and asked what’s wrong with it. If so, you may be wondering what makes an agent different.
An AI coding agent is an AI agent that works inside your code repository. It reads and searches files, edits them, runs commands and tests, and keeps repeating those steps on its own until the job is done. Autocomplete proposes the next few lines and a chat assistant hands you an answer, but either way you’re the one who puts the code in place and checks whether it works. An agent takes that cycle of trying, checking, and fixing into its own hands. You hear the term far more often now because, during 2025, the major tools started working this way in the terminal, inside the editor, and in the cloud.
From autocomplete to agents
When GitHub opened a technical preview of Copilot on June 29, 2021, it introduced it as an AI pair programmer that draws context from the code you’re working on and suggests whole lines or entire functions. It was autocomplete, a far smarter kind. With the chat tools that spread next, you described a problem in words and got code back. In both cases, though, putting that code into your files and running it was still your job.
In 2025, tools that do the running themselves arrived one after another. On February 6, GitHub announced agent mode for Copilot in VS Code, which iterates on its own code, recognizes errors, and fixes them. On February 24, Anthropic released Claude Code as a research preview, a command line tool that can search and read code, edit files, write and run tests, and commit and push to GitHub. And on May 16, OpenAI introduced Codex, a cloud agent that runs each task in its own sandbox preloaded with your repository. They work in different places, but all three gather what they need, make changes, and check them before reporting back.
Tools, feedback, and permissions
Underneath, a coding agent is a language model with a set of tools. The Claude Code docs sort its built-in tools into five categories: file operations, search, execution, web, and code intelligence. The model picks a tool, Claude Code runs it and hands back the result, and the model picks again. The docs describe this loop as gathering context, taking action, and verifying results.
Code suits this loop because the result can be checked. In the appendix to Building effective agents, Anthropic notes that code solutions are verifiable through automated tests and that agents can iterate on solutions using test results as feedback. A failing test or a stack trace tells the agent where to look next, in text it can read.
Of course, an agent that can run commands can also run the wrong ones, so its tools come with permissions. In Claude Code’s Manual mode, for example, the agent reads and searches freely but asks before edits and most shell commands. The sandbox, which is off by default, has the operating system limit which files and network hosts shell commands can reach. Shaping this whole environment, including instruction files in the repository such as CLAUDE.md or AGENTS.md, is a subject of its own called harness engineering.
Handing an agent a failing test
To watch the loop for real, I made a small Python repository with four files. The README states the rule: shipping costs $4.99, and orders of $50.00 or more ship free. cart.py adds the fee from shipping.py to a cart’s subtotal, and test_cart.py holds three unittest cases for it. The bug sits in shipping.py, one file away from the test that fails.
FREE_SHIPPING_FROM = 5000 # cents
FLAT_FEE = 499
def shipping_fee(subtotal):
if subtotal > FREE_SHIPPING_FROM:
return 0
return FLAT_FEE
So running python3 -m unittest fails the test for an order of exactly $50.00 with AssertionError: 5499 != 5000. I committed this state with git so that any change would show up in a diff, and then gave Claude Code the job from inside the repository.
claude -p "Running python3 -m unittest fails. Find the cause and fix it so the tests pass. Do not change the tests." \
--model haiku --allowedTools "Read,Grep,Glob,Edit,Bash(python3 -m unittest *)" \
--output-format stream-json --verbose < /dev/null > ../run.jsonl
claude -p is a headless run that does the work once, without opening a chat, and exits. Notice that the prompt doesn’t say which file is wrong. --allowedTools lets the agent read, search, and edit files and run the tests without asking, and in this run any other call that needs approval is refused. --output-format stream-json --verbose records every step as a line of JSON, which I saved one folder up so it would stay out of the agent’s working folder. < /dev/null keeps it from waiting for keyboard input.
The log is long, so I wrote a short script that pulls out the tool calls and the unittest summary lines that the shell commands returned.
import json
import os
import sys
# List the tool calls in a stream-json log, and what each Bash call reported.
names = {}
for line in open(sys.argv[1]):
event = json.loads(line)
if event["type"] not in ("assistant", "user"):
continue
for block in event["message"]["content"]:
if block["type"] == "tool_use":
names[block["id"]] = block["name"]
args = block["input"]
detail = args.get("command") or os.path.basename(args.get("file_path", ""))
print(f"{block['name']:<5} {detail[:60]}")
elif block["type"] == "tool_result" and names[block["tool_use_id"]] == "Bash":
lines = block["content"].splitlines()
# Keep the unittest summary lines, or the last line if there are none.
for kept in [l for l in lines if l.startswith(("FAIL", "OK"))] or lines[-1:]:
print(" |", kept[:58])
Running python3 steps.py run.jsonl printed this.
Bash python3 -m unittest 2>&1 | tail -60; echo; git status --shor
| FAIL: test_order_of_exactly_50_ships_free (test_cart.Check
| FAILED (failures=1)
Bash for f in cart.py shipping.py test_cart.py README.md; do echo
| A variable in this command can't be checked before it runs
Read cart.py
Read shipping.py
Read test_cart.py
Read README.md
Edit shipping.py
Bash python3 -m unittest -v 2>&1 | tail -10
| OK
Read from the top, it’s the loop in action. The first command ran the tests while also checking git status and listing the files with find, and it learned that one test had failed. Its next command, a shell loop to print all four files at once, held a variable that couldn’t be checked before running, so Claude Code’s permission check refused it. The agent then opened the files one by one with the Read tool instead. Just before editing, it wrote down the cause: the README promises free shipping from $50.00, but shipping.py uses >, so an order of exactly 5000 cents still pays the fee. Then it edited shipping.py and ran the tests again to confirm they passed. None of these steps were in my prompt.
Here’s git diff afterward.
diff --git a/shipping.py b/shipping.py
index 70a4e94..c01293a 100644
--- a/shipping.py
+++ b/shipping.py
@@ -3,6 +3,6 @@ FLAT_FEE = 499
def shipping_fee(subtotal):
- if subtotal > FREE_SHIPPING_FROM:
+ if subtotal >= FREE_SHIPPING_FROM:
return 0
return FLAT_FEE
One character changed, and all three tests passed when I ran them myself. The run took 9 turns and 14.4 seconds. In its final message, the agent added that it hadn’t touched the tests or the README and hadn’t committed anything, so the review was left to me. A second run on a fresh copy called the tools in nearly the same order and fixed the same line.
How it differs from autocomplete and chat
All three kinds of tools often run on the same models. That’s why what sets them apart is mostly how much of the work each one takes on.
| Autocomplete | Chat assistant | Coding agent | |
|---|---|---|---|
| What you get | The next line or function | An answer with code to copy | Changes made in your files |
| What it looks at | Code around the cursor | Mostly what you paste in | The repository, searched on its own |
| Who runs and checks it | You | You | The agent first, then you |
| Size of the job | A few keystrokes | One question | One task, such as a bug fix |
The lines are blurring as chat apps and editors add agent modes. Still, if you ask who runs the code and reads the errors, you can usually tell which one you’re using. Vibe coding, which you may also have heard of, is one way of using these tools, where you accept the AI’s code without reading it.
How coding agents are measured
The best-known yardstick is SWE-bench, which Carlos E. Jimenez and colleagues released in October 2023 and presented at ICLR 2024. It turns real GitHub issues from 12 popular Python repositories, along with the pull requests that resolved them, into 2,294 tasks. A model gets the codebase and the issue and has to produce a patch, which counts as a fix only if the tests that the original pull request made pass now pass, and the tests that passed before still do. In the paper’s experiments, Claude 2 resolved under 2% of the issues.
Some tasks, though, were hard to solve fairly, because the issue was vague or the tests were overly specific. So on August 13, 2024, OpenAI released SWE-bench Verified, 500 tasks screened by hand by developers experienced in Python. On February 23, 2026, however, OpenAI wrote that it no longer measures frontier coding capabilities. In the tasks it audited, it found many tests that reject correct fixes, and the benchmark had become increasingly contaminated, meaning its tasks had found their way into training data. So OpenAI stopped reporting the score and recommended SWE-bench Pro instead. When you see a coding score, then, it’s worth checking which benchmark it comes from, when it was measured, and what agent setup produced it.
Where it helps and where to be careful
Coding agents tend to do best when the task has clear edges and a way to check the result. A bug that a failing test points to, as above, is a good fit, and so is repetitive work such as renaming a function across many files. They also help with reading an unfamiliar codebase, where you ask where a feature lives and how a request flows through it.
There are things to watch, though. The first is code that looks plausible but is wrong. Passing tests prove only what the tests check, and in the example, three tests were all the agent had to decide that it was done. The second is security. Instructions hidden in the files, web pages, or issue text an agent reads can steer it the wrong way, which is called prompt injection. The third is commands that are hard to undo. Claude Code’s checkpoints can rewind edits made with its file tools, but a file that only shell commands changed isn’t tracked, and the docs point you to version control such as Git for that. That’s why it’s safer to grant only the commands a task needs, as the example did. The last is merging without review. Anthropic’s appendix adds that while automated testing helps verify functionality, a person still needs to review whether a solution fits the broader requirements of the system.
Trying one for the first time
If you’re new to this, I’d suggest starting the way the example did, with a small repository, one failing test, and only the tools the job needs. Commit before you hand over the task, read git diff when it’s done, and run the tests once more yourself. The Claude Code quickstart walks you through installing it and a first task. The best practices page recommends giving the agent a check that comes back pass or fail and asking it for evidence, meaning the command it ran and its output. I ran this example on October 28, 2026, on macOS with Claude Code 2.1.304 and Python 3.13.12, and --model haiku resolved to claude-haiku-5-5.
AI tools helped with the research for this post.