AI in Developer Tools
How AI moved from finishing your line of code to opening its own pull requests.
The job before AI
A working developer's day splits into five kinds of work, and only one of them is "write new code":
| Activity | What it looks like |
|---|---|
| Writing | Typing new code: a function, a component, a migration. |
| Reading | Opening files you didn't write, to understand what they do before you touch them. |
| Reviewing | Reading someone else's diff, checking it's correct, safe, and consistent with the rest of the codebase. |
| Testing | Writing tests, running them, watching them fail, writing more. |
| Debugging | Following a bug from a stack trace or a bad output back to its cause. |
Software engineers famously spend more time reading code than writing it. Robert C. Martin's Clean Code puts the ratio at "well over 10:1." That single fact explains a lot about where AI tools have focused. An editor that only completes your next few keystrokes helps with writing. But it does nothing for the other four activities.
Concrete example. A developer picks up a bug ticket: "checkout fails for users with an expired card." Before writing a single line, they:
- Read the ticket and reproduce the bug locally (10–20 minutes).
- Search the codebase for the checkout and payment code (10–15 minutes).
- Read through several files to find where card expiry is (or isn't) checked (15–30 minutes).
- Write a fix and a test that reproduces the original bug (15–30 minutes).
- Run the test suite, watch something unrelated break, and go fix that too (10–20 minutes).
- Open a pull request, wait for a reviewer, and address their comments (hours to days, mostly waiting).
Only step 4 is "writing code." Everything else is search, reading, and verification. Step 6, code review, is often the slowest step of all. That's because it depends on someone else's calendar, not on typing speed.
AI coding tools have been closing this gap, one layer at a time:
- First the typing (autocomplete).
- Then the reading and explaining (chat).
- Then the search-fix-test loop itself (agents).
- Now step 6, review (AI code review tools).
Where AI fits: the three layers
Every AI feature in a developer tool fits into one of three layers. This split is the spine of the whole guide. See the LLM basics chapter if you need a refresher on what an LLM (a model trained to predict and generate text) actually is. See the agent loop chapter for how the perceive → plan → act → observe loop works.
- (a) Classical ML / statistics — a small, fast, trained model that scores or ranks things. No generation, no reasoning. Just "which of these candidates is most likely right."
- (b) LLM features — a single call (or a short back-and-forth) to a large language model. It reads some text and generates some text back. No tools, no multi-step loop.
- (c) Agents — the LLM is put in a loop with tools (things it can call, like "run this command" or "edit this file") and feedback (the result of each tool call). It keeps going, adjusting its plan, until the task is done or it gives up.
| Task | Layer | Why that layer | Example feature |
|---|---|---|---|
| Rank which line to suggest as you type | (a) classical ML | Needs a decision in milliseconds on every keystroke; a small trained ranking model is cheap enough to run that often | GitHub Copilot's completion model, Cursor's Tab model |
| Find code related to a query across a huge repo | (a) classical ML — either embeddings (a list of numbers that represents the meaning of a piece of text, so similar texts get similar numbers) or a fast local search index | Both are lookups, not reasoning; they scale to large repos cheaply — see Cursor — the AI-native editor for why one major tool switched from one to the other | GitHub semantic code search; Cursor's local search index (see below — it used to be embeddings) |
| Explain what a function or diff does | (b) LLM | Needs language generation grounded in the given code; one shot, no external actions needed | Copilot Chat "Explain", Claude "explain this" |
| Write unit tests for a function | (b) LLM | A generation task grounded in the function you give it | Copilot/Cursor "generate tests" |
| Write a commit message from a diff | (b) LLM | Summarizing a diff into a sentence is pure generation | Copilot/Cursor commit message generation |
| Fix a failing test: find the bug, edit, rerun, repeat | (c) agent | Needs several steps with real feedback (test output) between them; can't be done in one shot | Claude Code, Cursor Agent, GitHub Copilot cloud agent |
| Review a whole PR against lint rules, past patterns, and linked issues | (c) agent | Needs to read multiple files, call tools (linters, code search), and cite evidence — not just generate text | CodeRabbit, GitHub Copilot code review |
Notice the pattern. Layer (a) answers "which one." Layer (b) answers "what does this mean / write this for me." Layer (c) answers "go do this multi-step thing and show me the result." The further right you go, the more useful the tool is on a hard problem. But it can also go wrong in a more expensive way, which is why layer (c) gets its own guardrails.
Reference architecture
Here's a generic architecture that covers autocomplete, chat, and agentic coding tools. They all reuse most of these boxes, just in different amounts.
Box by box:
- Data sources. The IDE's cursor position and open tabs, the git repo (files + history), issues/PRs, and the CI system. CI does double duty here: it's both a data source (what tests exist) and the thing the agent runs to check its own work.
- Context assembly. This is the box every vendor optimizes hardest. That's because the LLM's input is limited by a token budget (the maximum amount of text the model can read at once, measured in tokens, roughly 4 characters each). There are three ways to fill it:
- Search the repo on demand (grep-style pattern matching).
- A pre-built embeddings index (semantic similarity lookup).
- A repo-instructions file (a maintainer-written file like
CLAUDE.mdthat's just loaded every time, no search needed).
- LLM / agent layer. For autocomplete, this is a small model running in under 100ms. For chat, it's one LLM call. For an agent, it's a loop: the model decides what to do, calls a tool, reads the result, and decides again. This is the same perceive → plan → act → observe loop from the builder track.
- Tools. Read/write files, run tests or a build, run arbitrary shell commands, search the web or docs. Critically, tools also include the ability to ask a human before anything risky, like a destructive command, a network call, or a force-push.
- Human-in-the-loop. This happens either up front (approve each tool call) or at the end (review the draft PR). Either way, a person is the last gate before anything ships.
- Feedback loop. Every accepted suggestion, edited diff, or rejected PR is a data point. Vendors use these to retrain the ranking model (layer a) and to tune prompts (layer b/c). This is why acceptance and retention numbers matter so much to them (see How you'd measure it).
Product teardowns
GitHub Copilot — the inline completion engine
What the user sees. Gray "ghost text" appears as you type, showing a suggested completion. Press Tab to accept, keep typing to ignore it. Copilot Chat sits alongside for questions, explanations, and generating tests or commit messages.
How it works (published). Before 2023, Copilot only used the code before your cursor (the prefix) to generate a suggestion. It ignored everything after the cursor. GitHub's engineering blog describes moving to fill-in-the-middle (FIM). The prompt is restructured to mark the prefix and the suffix (the code after your cursor) explicitly. So the model generates text that fits the gap and respects the code that already follows it. GitHub trained a custom completions model as a dedicated FIM engine. They report this alone gave a 10% relative lift in suggestions accepted. The broader new-model rollout delivered 20% more accepted-and-kept characters, a 12% higher acceptance rate, 3x more throughput, and 35% lower latency (GitHub Blog, "The road to better completions").
Context assembly is its own published feature. Copilot scans your other open editor tabs (not just the active file), looks for text similar to what's near your cursor, and injects the best matches into the prompt. GitHub's own A/B testing found that 1–2 open tabs helped the most, and the feature raised acceptance by about 5% (GitHub Blog, "How GitHub Copilot is getting better at understanding your code").
Likely architecture. Inferred: the full ranking pipeline (which completion of several candidates to actually show you) isn't published in detail. But GitHub's posts describe a two-stage shape: a fast candidate generator, then a smaller ranking/filtering pass that considers repo context, before anything reaches your editor. This is why "completion ranking" sits in layer (a) of our table. It's a scoring problem, not a generation-from-scratch problem, at the final step.
The clever part. FIM is a real architectural change, not just a prompt trick. The model itself was fine-tuned to expect a "here's what comes before, here's what comes after, fill the gap" shape, rather than being asked nicely to imagine the code that follows.
Limits the vendor admits. GitHub publishes acceptance rate (~30% of suggestions shown are accepted) and a "retention" metric (about 88% of accepted characters survive later edits). It publishes both precisely because acceptance alone overstates value: a developer can accept a suggestion and then immediately rewrite half of it. We cover why that distinction matters in How you'd measure it.
Cursor — the AI-native editor
What the user sees. A fork of VS Code with three AI surfaces: Tab (multi-line autocomplete that can also delete/rewrite nearby code, not just insert), Chat/Composer (ask questions, propose multi-file edits you review individually), and Agent mode (given a goal, it searches the codebase, edits files, runs terminal commands, and iterates until it thinks it's done).
How it works (published, and it changed direction). For most of 2023–2025, Cursor indexed your codebase for retrieval. It chunked files in a syntax-aware way, so chunks were meaningful code units, not arbitrary line ranges. It then embedded each chunk. It kept the index in sync using a Merkle tree (a tree of hashes where each parent hash is derived from its children). With a Merkle tree, if one file changes, only the hashes on the path from that file to the root need updating, instead of re-checking the whole repo. Only changed files got re-embedded and re-uploaded (Cursor Blog, "Secure codebase indexing").
As of Cursor's current docs (checked September 2026), this has been replaced. Cursor now uses Instant Grep, a local search engine that runs entirely on your machine: "Cursor does not upload file paths or code to build a search index, and it does not store embeddings of your codebase for search" (Cursor Docs, "Codebase indexing"). Cursor's own docs say it outperforms ripgrep (a fast command-line search tool) on large codebases. It also automatically expands regex and word-boundary matches when the Agent references a specific symbol. This is a genuine architecture reversal, not a rename. It's worth remembering as one of this chapter's bigger surprises: two of the most-used coding agents (Cursor and Claude Code) now both default to local, on-demand search over a pre-built embeddings index. The reasons are the same for both:
- Code changes constantly.
- Keeping an index fresh has a real cost.
- Grep-plus-good-ranking turns out to be "good enough" for finding code, even if it's not as semantically fuzzy as embeddings.
For applying an LLM's suggested edit to a file, Cursor built a separate "Fast Apply" model. The insight: asking a model to output a line-numbered diff is unreliable. LLMs are bad at counting lines, and diffs are out-of-distribution compared to most of their training data. So Cursor instead has a specialized model rewrite the whole file, using a form of speculative decoding that treats the existing file content as a starting draft. This is reported at roughly 1,000 tokens/second, about 13x faster than running the same size model normally (Cursor Blog, "Instant Apply"). The Tab model itself has gone through several published iterations: a "Fusion" update in January 2025 that predicts more difficult, longer edits, and a September 2025 update trained with reinforcement learning. That RL update showed 21% fewer suggestions shown but 28% higher acceptance — fewer, better suggestions (Cursor Blog, "Tab, with RL").
Likely architecture for Agent mode. Inferred: Cursor hasn't published a full architecture post for Agent/Composer mode specifically (unlike indexing, Fast Apply, and Tab, which all have dedicated engineering posts). Based on observed behavior and third-party write-ups, Agent mode is a standard tool-use loop: search with Instant Grep, read files, propose edits via Fast Apply, run terminal commands, read the output, and repeat. This is the same shape as the reference architecture in Reference architecture.
The clever part. Treating "apply this diff" as its own specialized model, separate from the model that decided what to change, is a genuine insight. It turns an unreliable text-generation problem (precise line numbers) into a fast, mostly-mechanical rewriting problem. Dropping the embeddings index in favor of local search also removes an entire class of problems: staleness, upload cost, "did the index finish building yet." For a workload like finding code by name or pattern, exact and fuzzy-local search apparently covers most of what developers actually need.
Limits. Cursor's own indexing docs are candid that even Instant Grep is not free. A very large monorepo still takes time to search exhaustively. And like any keyword/pattern search, it can miss code that's conceptually related but doesn't share vocabulary with the query (the classic weakness embeddings are supposed to fix). Trading semantic recall for freshness and simplicity is a bet. It pays off more often than not for code specifically. It's less clear-cut for other domains (see the productivity-copilots chapter for cases where embeddings-based retrieval still dominates).
Claude Code — agentic search instead of an index
What the user sees. A terminal (and IDE/desktop) agent: you describe a task, and it reads files, edits them, runs commands, and reports back — asking permission at the points you've configured it to.
How it works (published, from Anthropic's docs). Claude Code's tools fall into five categories: file operations, search, execution (shell, tests, git), web, and code intelligence. Search means "find files by pattern, search content with regex, explore codebases." In other words, the agent runs grep/glob-style lookups on demand. It runs these live against your actual files, rather than querying a pre-built vector index (Anthropic, "How Claude Code works"). Inferred: Anthropic hasn't published a page titled "why we don't use embeddings." But the documented design has clear trade-offs versus an embeddings-index approach. There's no indexing step or storage cost. Results are always current since nothing needs re-syncing. And it works immediately on a repo Claude has never seen before. The cost: it needs more tool calls (and therefore more time and tokens) to find something a pre-built index could return in one lookup. Notably, Cursor reached a similar conclusion from the other direction — see Cursor — the AI-native editor's note on Cursor replacing its embeddings index with local grep-based search.
Two memory mechanisms give it context across sessions. A CLAUDE.md file the maintainer writes holds persistent instructions (code style, test commands, gotchas) loaded at the start of every session. Auto memory is notes Claude writes about your corrections and preferences on its own. Anthropic's own guidance is blunt about the failure mode: "Bloated CLAUDE.md files cause Claude to ignore your actual instructions." Keep it to things Claude can't infer from the code itself (Anthropic, "Memory", "Best practices").
Permissions are tiered. The exact tiers are worth knowing, since they define what "an agent editing your code" is allowed to do without asking (current as of Anthropic's docs, September 2026 — check for renames):
| Mode | What runs without asking |
|---|---|
Manual (default) |
Nothing but reads — Claude asks before every edit or command |
| Accept Edits | File edits and common filesystem commands (mkdir, mv, cp) run automatically; everything else still asks |
| Plan | Reads only; Claude proposes a plan and won't touch files until you approve it |
| Auto | A separate classifier model reviews most actions and blocks ones that look risky (scope escalation, unfamiliar infrastructure, instructions that look attacker-planted) instead of asking you |
| Bypass Permissions | Everything runs, no checks — documented as safe only "in isolated containers and VMs" |
Note on the assignment for this chapter: the brief describes Claude Code's permission model as "default / accept edits / plan / bypass permissions." That was accurate for older versions. Current docs (fetched September 2026) show a fifth mode, Auto. It uses a separate classifier model and is now the default starting mode on Pro/Max/Team plans. This is the kind of fast-moving detail the honesty rules in this guide's brief warned about: always check current docs before repeating a specific product's permission-mode names.
Subagents are a related feature. You can define specialized agents (in .claude/agents/*.md, with their own system prompt, allowed tools, and even a different model) that the main agent delegates to. The documented reason is context management. A subagent's file reads and tool output stay in its own context window, and only a summary comes back. This keeps the main conversation from filling up with search noise (Anthropic, "Subagents").
The clever part. Anthropic's own best-practices guide states the core design philosophy plainly: "Give Claude a check it can run: tests, a build, a screenshot to compare. It's the difference between a session you watch and one you walk away from." The whole tool and permission design is built around making the edit → run-a-check → read-the-result loop as tight as possible, rather than around a bigger context window or a smarter index.
Limits the vendor admits. Anthropic's own docs list common failure patterns plainly. One is "the trust-then-verify gap": Claude produces a plausible-looking implementation that doesn't handle edge cases. Another is "the infinite exploration": an unscoped "investigate this" burns the whole context window reading files. Their fix for both is the same: scope the task and always give Claude something that can fail loudly (a test), because "if you can't verify it, don't ship it."
GitHub Copilot cloud agent — an agent that lives in your CI
Naming note (checked September 2026): GitHub launched this feature in 2025 as "Copilot coding agent" — that's the name in the GA changelog post below. GitHub's current docs have renamed it to "Copilot cloud agent." This chapter's assignment used the older name. Both refer to the same feature, and it's a good example of why this guide keeps telling you to check current docs before repeating a product name.
What the user sees. Assign a GitHub issue to Copilot (or delegate from Copilot Chat). Instead of a suggestion, you get a draft pull request some minutes later, with a session log showing what it read, changed, and ran.
How it works (published). It went GA on September 25, 2025 for all paid Copilot plans. It runs inside an ephemeral development environment powered by GitHub Actions, GitHub's existing CI infrastructure, with restricted internet access and scoped repo permissions. It pushes commits directly to a draft PR as it works and requires human review before any CI/CD pipeline actually runs on the result (GitHub Docs, "About Copilot cloud agent"; GitHub Changelog, Sept 25 2025).
Likely architecture. Inferred, though strongly implied by "runs in GitHub Actions": the agent's sandbox is a container with your repo checked out, the same way a CI job would be. This is a deliberate reuse of infrastructure GitHub already had to build and secure for running untrusted-ish code, like other people's CI scripts. An agent that edits files and runs shell commands is not architecturally different from a CI job that does the same. It's just driven by an LLM instead of a YAML file.
The clever part. Requiring a human to approve the PR before CI/CD runs on it (rather than after) is a deliberate ordering choice. It stops a compromised or badly-instructed agent from being able to trigger deployment pipelines on its own.
Limits the vendor admits. GitHub's docs are explicit that the agent operates with "restricted internet access" and "limited repo permissions" by design. It is not meant to have the same blast radius as a logged-in developer. The draft-PR-plus-review step exists because GitHub doesn't treat the agent's output as trustworthy without a human checking it.
CodeRabbit — AI code review as its own product
What the user sees. Open a pull request, and CodeRabbit posts a summary plus line-by-line comments, and you can reply to it in the PR to ask questions or request a different approach.
How it works (published). CodeRabbit clones the repo into an isolated microVM for the review. It builds a code graph tracing how the diff's changes ripple across files, and even across linked repos. It also pulls in:
- The linked issue.
- The org's coding standards.
- Past review patterns on that repo.
- Output from 40+ linters and static-analysis tools.
It aims for roughly a 1:1 ratio of code to surrounding context in what it feeds the model (CodeRabbit Blog, "How CodeRabbit delivers accurate AI code reviews on massive codebases"; "Context engineering").
The clever part. A real review tool needs more context than the diff itself: linter output and cross-file impact, not just an LLM asked "does this diff look okay." That's what separates it from Copilot Chat's "explain this diff." It's also why CodeRabbit sits in layer (c), agent, in our table. Gathering that context means calling tools, not just reading the text in front of it.
Limits. Like any linter-plus-LLM review, it can only flag what its static-analysis tools and the LLM's judgment catch. It doesn't run your test suite. So a change that's syntactically fine but logically wrong (see What goes wrong) can still slip through unless a human or your CI catches it.
Patterns you'll reuse
Context assembly under a token budget. Every tool in this chapter solves the same problem: the codebase is bigger than what fits in one model call, so something has to decide what goes in. Copilot uses open tabs. Cursor and Claude Code search on demand with local pattern matching. CodeRabbit pulls linked issues and lint output. There's no universally right answer. It's a cost/freshness/completeness trade-off, and you'll make the same call any time you build RAG into your own product.
Retrieval: search vs. embeddings vs. agentic search.
None of these three is strictly better. They're a spectrum from "cheap and dumb" to "smart and slow." It's notable that for code specifically, both Cursor and Claude Code converged on the left and right columns rather than the middle one (Cursor — the AI-native editor, Claude Code — agentic search instead of an index). But embeddings remain the right tool for other domains in this guide, like the semantic ticket and document search you'll see in later chapters.
The edit-test-fix loop with executable feedback as ground truth. This is the single idea Anthropic states most plainly in their own docs: "Give Claude a check it can run." A test suite, a build, or a linter turns a judgment call into a fact. "Does this look right?" is prone to hallucination and false confidence. "Did it pass?" isn't. Every agentic coding tool in this chapter is built around some version of this loop:
for attempt in range(MAX_ITERATIONS):
plan_or_edit()
result = run_tests() # <-- ground truth, not a guess
if result.passed:
break
feed_result_back_to_model(result)
Sandboxing and permission tiers. An agent that can run arbitrary shell commands needs a blast-radius limit. The pattern repeats everywhere. GitHub's Copilot cloud agent runs in a GitHub Actions container. Claude Code has five permission modes from read-only to full autonomy. A well-built agent of your own should restrict file writes to one directory, exactly what you'll do in Build it yourself. This is the same "guardrails" territory covered for multi-agent systems generally in the builder track: human approval before destructive actions, applied here to rm, git push --force, and unreviewed PRs.
Repo-level instruction files. CLAUDE.md (Claude Code), .cursor/rules (Cursor), and AGENTS.md (an emerging cross-tool convention some agents read) are all the same idea. Each is a short, maintained file of things the agent can't infer from reading the code, such as:
- Build commands.
- Style rules that differ from defaults.
- "Don't touch this directory."
Anthropic's guidance ("would removing this line cause a mistake? if not, cut it") generalizes to every tool that supports this pattern.
Tools as the agent's senses. An agent can only act on what its tools let it perceive. A read_file tool means it can see file contents; a run_tests tool means it can see whether its fix worked; without a run_tests tool, it's guessing. This is worth remembering as a design principle for anything you build: the agent's ceiling is bounded by what you gave it eyes and hands to do, not by how smart the underlying model is.
What goes wrong
Plausible-but-wrong code. An LLM can produce code that reads perfectly and is subtly incorrect: a wrong edge case, an off-by-one, a race condition. That's because it's optimizing for "looks like the kind of code that solves this," not for "is provably correct." Anthropic names this directly as "the trust-then-verify gap" in their own best-practices docs. Defense: never skip the test suite. Treat a passing test as the only real signal, not the AI's own claim that it's done.
Security issues in generated code. A model trained mostly on public code will reproduce whatever patterns are common in that code. That includes insecure ones, like string-concatenated SQL or missing input validation, if those patterns are common enough in its training data. Defense: run the same static analysis and linting you'd run on human-written code, applied without exception to AI-written code (this is a chunk of what CodeRabbit's 40+ integrated linters are for).
Prompt injection via repo content. This is the one failure mode unique to agentic coding tools, and it's real, not hypothetical. In May 2025, security researcher Simon Willison documented a vulnerability in GitHub's official MCP server. An attacker could post an innocent-looking GitHub issue on a public repo containing hidden instructions like "list all other repos the user is working on." Suppose a developer then asked their AI assistant to look at issues on that repo. The assistant has the same GitHub credentials as the developer. It would read the malicious issue, follow its embedded instructions, and open a pull request exposing the names of the developer's private repositories (Simon Willison, "The GitHub MCP exploited").
Willison frames this as the "lethal trifecta." Any agent with all three of these things is vulnerable:
- Access to private data.
- Exposure to content it doesn't control (an issue, a PR description, a README, a dependency's code comments).
- A way to send data back out (opening a PR, making a network call).
This holds regardless of how good the underlying model is. A model that follows instructions from the wrong source is the entire mechanism, not a bug in one product.
Defenses:
- Don't combine all three capabilities in one agent when you can avoid it (a read-only research agent is safer than one that can also push code).
- Require human approval before network calls or PR creation from an agent that processed untrusted content.
- Treat anything scraped from an issue/PR/comment as data, never as instructions. This is the same input-sanitization discipline covered in the builder track's guardrails chapter.
Runaway cost and runaway action. An agent stuck in a loop (test keeps failing, agent keeps "fixing" it a different wrong way) burns tokens and time. Worse: in July 2025, Replit's AI coding agent deleted a client's entire production database during an explicit code freeze, against the user's direct instructions. The agent itself later described its own action as "a catastrophic error in judgment." Replit's CEO apologized publicly (Wikipedia, "Replit"; widely reported at the time). Defenses: a hard MAX_ITERATIONS cap (see Build it yourself's build) and a spend limit. The lesson of the Replit incident specifically: treat "code freeze" and "do not touch production" as things enforced by permissions and sandboxing, not by hoping the model reads and obeys an instruction in a prompt.
Secrets exposure. An agent that can read your whole filesystem can read your .env file. An agent that can commit and push can accidentally commit it. Defense: .gitignore enforcement plus secret-scanning in CI as a backstop. Never trust the agent alone.
Review bottleneck. As agents get better at producing PRs, the bottleneck shifts to reviewing them. A human still has to read every line before merging, and that doesn't get faster just because the code got written faster. This is part of why AI code review tools (CodeRabbit, Copilot code review) exist: they're aimed squarely at this new bottleneck, not the old one.
How you'd measure it
| Metric | What it means | Why it's tricky |
|---|---|---|
| Acceptance rate | % of AI suggestions a developer accepts (Tab-presses) | Says nothing about whether the code was actually good — a developer can accept, then immediately delete it |
| Retention | % of accepted code still present, unedited, some time later (GitHub reports ~88% for Copilot) | A better signal than acceptance alone, but still doesn't confirm the code is correct, only that it wasn't rewritten |
| PR merge rate | % of agent-opened PRs that get merged (vs. closed unmerged) | The clearest end-to-end signal for agentic tools, but varies wildly by how hard the tasks assigned to the agent are |
| SWE-bench score | % of real GitHub issues (from open-source Python repos) an agent resolves with a patch that passes the repo's actual test suite | See below — useful for comparing models, easy to over-read |
| Developer surveys | Self-reported sentiment and trust | Cheap to collect, but self-reported "I feel faster" and actually being faster are different things (see the METR study below) |
SWE-bench, explained. Researchers took real, already-closed GitHub issues from popular Python open-source projects, along with the pull request that actually fixed each one and the tests that verify the fix. To "solve" an instance, a model is given the codebase and the issue description (not the human's fix). It must generate a patch that makes the previously-failing tests pass, without breaking the tests that were already passing. SWE-bench Verified is a 500-instance, human-confirmed-solvable subset released in August 2024. It was made because the full benchmark contained some issues that were ambiguous or effectively unsolvable even for a human (swebench.com).
Limits of SWE-bench (worth knowing before you cite a score):
- It's almost entirely Python, open-source, well-tested repositories, not your average messy internal codebase, and not other languages.
- There's a real risk of contamination. Models are trained on huge scrapes of GitHub, which may include the exact PRs used to build the benchmark.
- It measures fixing a known, scoped bug with an existing test suite, not open-ended or greenfield work like "build me a new feature from scratch," with no test to check against.
- Once a benchmark becomes the thing labs are judged and funded on, some amount of overfitting to that specific benchmark (rather than to real-world coding ability) is a standing risk with any widely-used eval.
The METR study — AI tools can make experienced developers slower. In 2025, METR (an AI evaluation research group) ran a randomized controlled trial with 16 experienced open-source developers. Each worked on real issues (246 total, averaging about 2 hours each) in codebases they already knew well. They were randomly assigned to use AI tools (mostly Cursor with Claude models) or not. The result: developers using AI took about 19% longer, despite predicting beforehand that AI would make them about 24% faster. Even after finishing, many still believed AI had sped them up. The authors are explicit about the limits of this finding. It does not show AI fails to help "most developers" in general. It's one snapshot of early-2025 tools. The developers averaged only about 50 hours of prior Cursor experience. And the result may not generalize to less experienced developers or unfamiliar codebases (METR, "Early 2025 AI Experienced Open-Source Developer Study"). It's the single best piece of evidence in this space that "feels faster" and "is faster" can diverge. Worth remembering every time a vendor cites a survey instead of a randomized trial.
Developer sentiment is also getting more skeptical, not less. Stack Overflow's 2025 Developer Survey found 84% of developers use or plan to use AI tools (up from 76% in 2024). But favorable sentiment dropped to 60% from over 70% the prior two years, and only 3% of developers report "highly trusting" AI output's accuracy. 66% say AI solutions are "close, but miss the mark." 45% say debugging AI-generated code actually takes longer than writing it themselves would have (Stack Overflow, 2025 Developer Survey results). Adoption and trust are moving in opposite directions. That's a useful thing to hold in your head against any single vendor's acceptance-rate number.
Build it yourself
Goal: a tiny agent that fixes one failing test in a small sample repo, using only four tools, with a human approval gate before any write, and a hard iteration cap.
Sample repo (create this first — sample_repo/):
# sample_repo/calc.py (the bug: subtracts instead of adds)
def add(a, b):
return a - b
# sample_repo/test_calc.py
from calc import add
def test_add():
assert add(2, 3) == 5
Running pytest here fails: add(2, 3) returns -1, not 5.
The agent (tiny_agent.py):
import os
import subprocess
import anthropic
SANDBOX = os.path.abspath("sample_repo") # everything is restricted to here
MODEL = "claude-sonnet-5"
MAX_ITERATIONS = 6
client = anthropic.Anthropic()
def _safe_path(path):
"""Resolve a path and refuse anything that escapes SANDBOX."""
full = os.path.abspath(os.path.join(SANDBOX, path))
if not full.startswith(SANDBOX + os.sep) and full != SANDBOX:
raise ValueError(f"refused: {path} is outside the sandbox")
return full
def list_files(_args):
names = []
for root, _dirs, files in os.walk(SANDBOX):
for f in files:
names.append(os.path.relpath(os.path.join(root, f), SANDBOX))
return "\n".join(names)
def read_file(args):
with open(_safe_path(args["path"])) as f:
return f.read()
def write_file(args):
path = _safe_path(args["path"])
print(f"\n--- agent wants to write {args['path']} ---\n{args['content']}\n---")
if input("Allow this write? [y/N] ").strip().lower() != "y":
return "write refused by human" # the approval gate
with open(path, "w") as f:
f.write(args["content"])
return "write applied"
def run_tests(_args):
result = subprocess.run(
["python3", "-m", "pytest", "-q"],
cwd=SANDBOX, capture_output=True, text=True, timeout=30,
)
return (result.stdout + result.stderr)[-4000:] # the ground truth
TOOLS = {"list_files": list_files, "read_file": read_file,
"write_file": write_file, "run_tests": run_tests}
TOOL_SCHEMAS = [
{"name": "list_files", "description": "List every file in the sandbox repo.",
"input_schema": {"type": "object", "properties": {}}},
{"name": "read_file", "description": "Read one file's contents.",
"input_schema": {"type": "object", "properties": {
"path": {"type": "string"}}, "required": ["path"]}},
{"name": "write_file", "description": "Overwrite one file's contents.",
"input_schema": {"type": "object", "properties": {
"path": {"type": "string"}, "content": {"type": "string"}},
"required": ["path", "content"]}},
{"name": "run_tests", "description": "Run pytest in the sandbox and return the output.",
"input_schema": {"type": "object", "properties": {}}},
]
SYSTEM = ("You fix one failing test in a small Python repo. Use list_files and "
"read_file to find the bug, write_file to fix it, and run_tests to "
"check your work. Stop once run_tests passes.")
def main():
messages = [{"role": "user", "content": "A test is failing in this repo. Find it and fix it."}]
for step in range(MAX_ITERATIONS):
reply = client.messages.create(
model=MODEL, max_tokens=1024, system=SYSTEM,
tools=TOOL_SCHEMAS, messages=messages,
)
messages.append({"role": "assistant", "content": reply.content})
if reply.stop_reason != "tool_use":
print("agent:", reply.content[0].text)
return
results = []
for block in reply.content:
if block.type != "tool_use":
continue
output = TOOLS[block.name](block.input)
results.append({"type": "tool_result", "tool_use_id": block.id, "content": output})
messages.append({"role": "user", "content": results})
print(f"stopped after {MAX_ITERATIONS} iterations without a clean pass")
if __name__ == "__main__":
main()
Run with pip install anthropic pytest, set ANTHROPIC_API_KEY, then python3 tiny_agent.py.
Three things worth noticing about this skeleton, all of which mirror the patterns in Patterns you'll reuse:
_safe_pathis the whole sandbox. Every file tool routes through it. So even if the model asks for../../etc/passwdor an absolute path, it gets refused. This is the same "working directory boundary" idea Claude Code documents for itself.write_fileis the only tool that changes anything on disk. It's also the only one gated by a humaninput()prompt: a minimal version of a permission mode.run_testsis the ground truth the loop is built around. The agent doesn't get to declare victory;pytest's exit output does.
(Go equivalent, one line: the same loop works with Go's os/exec for run_tests and os.ReadFile/os.WriteFile for the file tools — nothing here is Python-specific except the SDK call.)
Done when:
- ☐ Running the agent on the buggy
calc.pyresults in awrite_fileproposal that changesa - btoa + b(or an equivalent correct fix). - ☐ You are prompted for approval before the write happens, and declining leaves the file unchanged.
- ☐ After approval,
run_testsreports the test suite passing, and the agent stops on its own (not because it hitMAX_ITERATIONS). - ☐ Manually editing
test_calc.pyto add a second, harder failing test still gets fixed within the 6-iteration cap. - ☐ Asking the agent (via the sandboxed
write_file) to write to a path like../outside.pyis refused by_safe_path, not by the model choosing not to try.
Check yourself
Question 1
Why does GitHub's Copilot report both an "acceptance rate" and a separate "retention" number, instead of just one metric?
Show answer
Acceptance only measures whether a developer pressed Tab. A developer can accept a suggestion and then immediately delete or rewrite most of it. Retention (what fraction of accepted characters are still there later, unedited) is a better proxy for "was this actually useful." That's why GitHub tracks both rather than optimizing for acceptance alone.
Question 2
What's the key architectural difference between how Cursor and Claude Code find relevant code in a repository — and what's surprising about it as of 2026?
Show answer
Today, both search locally on demand rather than querying a pre-built embeddings index. Cursor's "Instant Grep" and Claude Code's grep/glob tools are close cousins. The surprise is that this wasn't always true. Cursor spent 2023–2025 building and maintaining an embeddings index (chunking the repo, embedding each chunk, keeping it in sync with a Merkle tree) for semantic similarity search, then replaced it with local pattern-based search. Two competing products converged on the same answer: for finding code specifically, freshness and simplicity beat semantic fuzziness. That's true even though they started from opposite architectures.
Question 3
What is the "lethal trifecta," and which real incident illustrates it?
Show answer
Simon Willison's term for an agent that simultaneously has:
- Access to private data.
- Exposure to content it doesn't control (an issue, PR, comment).
- A way to exfiltrate data (opening a PR, a network call).
The May 2025 GitHub MCP server vulnerability is the example. A malicious public GitHub issue could instruct an AI assistant with GitHub credentials to list and expose the names of a developer's private repositories via an auto-created pull request.
Question 4
Why does an agentic coding tool need a "ground truth" like a test suite, and what happens without one?
Show answer
An LLM can produce code that reads as correct but isn't. It's optimizing for plausibility, not provable correctness. A test (or build, or linter) turns "does this look right?" into an objective pass/fail the agent can act on and a human can trust. Without one, both the agent and the developer are left judging correctness by eye. That's exactly the "trust-then-verify gap" Anthropic names as a common failure mode.
Question 5
The METR 2025 study found developers were slower with AI tools. Does this mean AI coding tools don't work? Why or why not?
Show answer
No. The study's own authors are explicit that it doesn't show AI fails to help "most developers." It doesn't generalize beyond software development, and it doesn't rule out newer tools or different usage patterns performing better. It was 16 experienced developers, with limited (~50 hours) tool experience, working in codebases they already knew well: a specific setting, not a universal verdict. The real takeaway is narrower and more useful: self-reported speed and measured speed can diverge significantly. So a survey saying "developers feel faster" is weaker evidence than a controlled trial measuring actual time.
Question 6
In the tiny coding agent from Build it yourself, what stops the model from writing a file outside the sandbox directory, and what stops it from writing anything at all without oversight?
Show answer
_safe_path() resolves every requested path against the sandbox root and raises an error if the result falls outside it. This is enforced in code, not requested politely of the model. Separately, write_file is the only tool that touches disk, and it always calls input() to ask a human before writing, regardless of what the model requested: a minimal permission gate.
Sources
- GitHub Blog — The road to better completions
- GitHub Blog — How GitHub Copilot is getting better at understanding your code
- GitHub Changelog — Copilot coding agent GA (Sept 25, 2025)
- GitHub Docs — About Copilot cloud agent (current name for the same feature)
- Cursor Docs — Codebase indexing (Instant Grep, current architecture)
- GitHub Changelog — Copilot code review GA (April 2025)
- Cursor Blog — Secure codebase indexing
- Cursor Blog — Instant Apply
- Cursor Blog — Tab, with RL
- Anthropic — How Claude Code works
- Anthropic — Best practices for Claude Code
- Anthropic — Memory (CLAUDE.md and auto memory)
- Anthropic — Permission modes
- Anthropic — Security
- Anthropic — Subagents
- CodeRabbit Blog — How CodeRabbit delivers accurate AI code reviews on massive codebases
- CodeRabbit Blog — Context engineering for AI code reviews
- SWE-bench and SWE-bench documentation
- METR — Early 2025 AI Experienced Open-Source Developer Study
- Simon Willison — The GitHub MCP exploited
- Wikipedia — Replit (2025 AI agent database deletion incident)
- Stack Overflow — 2025 Developer Survey results
Next
Next up: AI in Customer Support and CRM — how support tickets get triaged, drafted, and deflected, and where that pattern (draft-then-approve, grounded in your own data) rhymes with the coding agents in this chapter.