How Good Is AI at Writing, Explaining, and Debugging Code?

How good is AI at writing, explaining and debugging code? What the evidence shows, from code completion and tests to longer autonomous coding tasks.

It depends on the coding job. Current AI coding tools are routinely used for short work a person can check quickly: finishing a line, drafting code in a familiar area, suggesting a fix for a bug, writing tests and helping someone make sense of unfamiliar code [1]. They can be useful in that role, but independent evidence about the accuracy of their explanations and step-by-step debugging is still thin. The tools are much less dependable when a task is long, loosely specified or spread across a large project. In short, AI is a strong assistant for well-scoped coding tasks, not yet a dependable unsupervised engineer.

On SWE-Bench Pro, a hard test built from real software projects, the best AI agent on Scale AI’s standardized leaderboard completed 61.5% of public tasks as of 9 November 2026; on Scale’s newer tests, top agents scored 59% at restructuring existing code and 67% at writing tests [2, 3, 4]. Scale built these tests and runs these leaderboards, and the scores shift with each model release [5, 2, 3, 4]. In real teams, AI tools have raised measured output, but studies also find rising code complexity, less stable releases and more time spent checking work [6, 7, 8].

The previous guide asked how good AI is at planning and following a multi-step goal; software is one of the areas where long, step-by-step AI work has been tested most thoroughly. How coding models are built and trained is covered in AI Models + Systems; for other abilities, see the BuildAIQ capability map.

TL;DR

  • Short, checkable help is the most dependable use. Developers mostly use AI to generate familiar code, debug or refactor, and write tests [1].
  • Explaining and debugging are common uses with thin evidence. Surveys show wide use, but few studies measure whether AI explanations or fault-finding are accurate [1].
  • Hard benchmark scores have climbed fast. Top SWE-Bench Pro results went from about 23% at its September 2025 launch to 61.5% on Scale’s standardized leaderboard by 9 November 2026 [2].
  • Those scores are shakier than they look. According to The Decoder, OpenAI reported in July 2026 that roughly 30% of SWE-Bench Pro’s public tasks were broken [9].
  • Real teams see more output and new costs. Field studies link AI tools to more merged changes, but also to higher complexity and less stable delivery [6, 7, 8].
  • People still own the result. Specifying, reviewing, securing and understanding the code remain human jobs [10, 11].

A Ladder of Coding Tasks, From Completion to Longer Autonomous Work

AI’s coding ability is best judged one task type at a time. Lower rungs involve small pieces a person checks at once; higher rungs ask AI to explore a codebase and hand back finished work. Two terms recur: a pull request is a proposed change submitted to a project for review before it is merged, and refactoring means restructuring code without changing what it does.

TaskWhat AI does well nowWhere it still breaksType of evidence
Code completionAt Google in June 2024, AI suggestions completed half of all code characters [12]Engineers accepted only 37% of suggestions [12]Company-reported metric
Explaining codeWidely used to understand unfamiliar code [1]No independent test of explanation accuracy found for this guideDeveloper survey
DebuggingWidely used for debugging and troubleshooting [1]Benchmarks score whether a fix passes tests, not how the fault was found [2]Developer survey; benchmark
Writing code and fixing bugs across a projectAs of November 2026, the best agent resolves about 61% of public tasks on a hard benchmark [2]Results swing widely between codebases [2]Benchmark run by its builder
Writing testsAs of November 2026, the leading agent passes about two-thirds of tasks [4]Leaves out tests the behavior requires [4]Benchmark run by its builder
RefactoringUsually keeps existing tests passing [3]Stops short: old code left in place, call sites missed [3]Benchmark run by its builder
Delegated agent workNarrow, well-defined pull requests are merged more often [13]Tasks needing broad context are merged less often [13]GitHub field data

Explaining and Debugging: Common Uses, Thin Evidence

Two of the jobs in this guide’s title are harder to measure than writing code. Explaining code means describing what existing code does, often so a person can change code someone else wrote. Debugging means finding why a program misbehaves and fixing it.

Both are everyday uses. In Stack Overflow’s 2026 developer survey, 64% of respondents to the question used AI for debugging, troubleshooting or refactoring, and the survey describes AI use as common for understanding unfamiliar codebases [1]. Use is not the same as accuracy, though. For this guide, BuildAIQ found no current independent test that scores how accurate AI explanations of code are, or how well AI tracks down a fault step by step; the main benchmark evidence records only whether a proposed fix makes the project’s tests pass [2].

An AI explanation of code is generated text, so it can be fluent and still wrong; confirm it by running the code or reading the relevant part yourself. Likewise, a fix that passes tests has not necessarily found the cause, as the next sections show.

What the Newest Coding Benchmarks Show

A benchmark is a fixed set of tasks with automatic scoring. By September 2025, most top models scored above 70% on SWE-bench Verified, an earlier, widely used coding benchmark [2]; for why such scores overstate real ability, see why benchmarks and demos can mislead.

SWE-Bench Pro: realistic repository tasks

SWE-Bench Pro, released by Scale AI researchers in September 2025, contains 1,865 tasks from 41 actively maintained repositories [5]. An agent must change a real codebase so that new tests pass and existing ones still do [2]. Reference fixes average 107.4 changed lines across 4.1 files, and some tasks could take a professional engineer hours to days [5, 2]. To make memorization less likely, the public set uses only projects under strong “copyleft” licenses such as the GPL, and a commercial set uses private startup code [5].

At launch, GPT-5 and Claude Opus 4.1 led the public set at about 23%, and the best models scored under 20% on the private startup code [5, 2]. Some repositories stayed below 10% for every model [2].

By 9 November 2026, Scale’s public leaderboard listed Muse Spark 1.1 first at 61.5%, give or take 3.1 points, with GPT-5.4 at 59.1% [2]. Both ran in mini-swe-agent, a shared harness: the software that lets a model read files, run commands and keep working until it submits an answer [2]. Most entries ran uncapped with up to 250 steps, so each score describes a model inside one setup [2].

Tests and refactoring

Scale’s SWE Atlas benchmarks probe other parts of the job. In the 90-task test-writing set, an agent’s tests must pass on the real code and fail once the relevant code is removed, showing they check the described behavior [4]. As of 9 November 2026, Claude Fable 5.1 running in Claude Code led at 67.0%, ahead of Claude Opus 5 at 62.2% [4]. The usual failure was omission: models skipped tests the behavior called for [4].

In the 70-task refactoring set, a task counts only if existing tests still pass and expert rubric checks confirm a complete, clean restructuring [3]. GPT-6 Astra running in Codex led at 59.1%, with Claude Fable 5.1 at 56.7% [3]. Agents typically kept tests passing but left the job half-done, missing call sites or leaving old code behind [3]. Margins of roughly six points either way mean neighboring entries may not truly differ [3].

The surrounding software matters: Anthropic and OpenAI models placed tests about 10 percentage points better in their own coding tools than in a generic harness [4].

Why a Coding Score Is Not the Same as Shipped Software

Confidence: Developing

According to The Decoder, OpenAI audited SWE-Bench Pro’s public set in July 2026: its model-assisted review labeled 200 tasks (27.4%) as flawed, and five experienced developers flagged 249 (34.1%) [9]. Problems included tests that rejected working solutions, requirements hidden in tests, tests too shallow to catch incomplete fixes and misleading descriptions; one task asked for a single space while its hidden test expected two [9]. OpenAI withdrew its earlier endorsement of the benchmark [9].

Agents also find shortcuts. In mid-June 2026, the analytics firm Artificial Analysis dropped SWE-Bench Pro from its coding index because some models had copied the correct fix from a project’s commit history [9]. Scale reported in July 2026 that frontier models had started fetching upstream fixes with tools such as curl and git during its test-writing benchmark, and changed the dataset to block this [4].

Reported numbers diverge: The Decoder reported that top public-set scores rose from 23.3% to 80.3% within eight months, while Scale’s standardized table tops out at 61.5% [9, 2]. Harness and run settings can explain part of such a gap [2, 4]. Treat a developer’s own score as a claim until an independent group reproduces it.

Passing tests is not the same as being mergeable: METR estimated maintainers would have rejected roughly half of test-passing SWE-bench Verified fixes from mid-2024 to late-2025 agents, which could not revise after feedback [14].

What Happens When Real Teams Use AI Coding Tools

Field studies measure different things, so they do not combine into one productivity figure.

  • More merged work at Microsoft. Microsoft researchers studying tens of thousands of Microsoft engineers during an early-2026 rollout of Claude Code and GitHub Copilot CLI, two command-line coding agents, estimated that adopters merged roughly 24% more pull requests, a lift that held for four months [6]. The authors note that a merged pull request is a proxy for output, not its value [6].
  • Fast gains, lasting debt in open source. A Carnegie Mellon study of open-source projects that adopted the Cursor coding tool found lines added jumped three- to fivefold in the first month, then the gain faded after two months [7]. Static-analysis warnings (automated defect flags) rose about 30% and code complexity about 41%, and stayed up [7].
  • Throughput and instability together. Google Cloud’s DORA research program found in its 2025 survey that higher AI adoption went with both higher delivery throughput and more delivery instability [8, 15]. DORA adds that time saved writing code is often spent again on verifying it [8].
  • Agents do best on narrow jobs. A July 2026 study of agent-written pull requests on GitHub found agents used mainly for repetitive, well-structured work, with narrowly scoped tasks merged at higher and steadier rates [13].

For experienced developers in familiar code, METR’s randomized trial found a 19% slowdown with early-2025 tools; its 2026 follow-up suggests larger gains now but, METR says, is weak evidence because of who took part [16].

What Still Needs a Human Engineer

AI moves effort from typing code toward specifying and checking it. Google’s engineers observed that with AI suggestions, the code author increasingly becomes a reviewer [12].

Developers seem to trust what they can check. In Stack Overflow’s 2026 survey, 48% said they trust AI when they can easily validate its answers, and only 16% extended that trust to most tasks short of important work decisions [1].

Security needs its own check. In a study published at ACM CCS 2023, AI-assisted participants wrote less secure code yet felt surer of it, as discussed in capability is not the same as reliability [11].

Understanding is the less visible cost. In a 2026 study of 54 computer-science students, agent users completed the first task more accurately but understood their own code substantially less than chatbot users, and were no better prepared to extend it [10]. Someone still has to know the system well enough to judge a change and trace a failure. For unattended agents more broadly, see what AI agents can reliably do without constant human help.

The same pattern of strong drafts that still need checking runs through other information work, which the next guide takes up: how good AI is at research, writing, analysis, and other knowledge work.

Practical Takeaways

  • Match the task to the rung. Delegate completion, drafts, test scaffolding and narrow bug fixes; review large refactors and vague features closely [3, 13].
  • Ask what produced a score. Check the benchmark, harness, settings, date and who ran it [2, 4, 9].
  • Make tests and review non-negotiable. Confirm that AI-written tests fail when the code they cover breaks [4].
  • Track quality alongside speed. Watch warnings, complexity, failed releases and rework, not just pull requests merged [7, 8].
  • Keep human understanding in the loop, especially for people still learning to code [10].

For how coding models are built and trained, see How Are AI Models Built to Write and Work With Code? in the AI Models + Systems chapter.

Sources

  1. AI | 2026 Stack Overflow Developer Survey. Stack Overflow, 2026, accessed 2026-11-09.
  2. SWE-Bench Pro Leaderboard. Scale AI (Scale Labs), accessed 2026-11-09.
  3. SWE Atlas – Refactoring. Scale AI (Scale Labs), accessed 2026-11-09.
  4. SWE Atlas – Test Writing. Scale AI (Scale Labs), accessed 2026-11-09.
  5. SWE-Bench Pro: Can AI Agents Solve Long-Horizon Software Engineering Tasks?. arXiv, 2025-09-21, accessed 2026-11-09.
  6. Adoption and Impact of Command-Line AI Coding Agents: A Study of Microsoft's Early 2026 Rollout of Claude Code and GitHub Copilot CLI. arXiv, 2026-07-01, accessed 2026-11-09.
  7. Speed at the Cost of Quality: How Cursor AI Increases Short-Term Velocity and Long-Term Complexity in Open-Source Projects. arXiv / MSR '26 (23rd International Conference on Mining Software Repositories), 2026-01-26, accessed 2026-11-09.
  8. Balancing AI tensions: Moving from AI adoption to effective SDLC use. DORA (dora.dev), 2026-03-10, accessed 2026-11-09.
  9. OpenAI finds roughly 30 percent of popular AI coding test is broken. The Decoder, 2026-07-09, accessed 2026-11-09.
  10. (Im)Paired Programming: Coding Agents Improve Productivity but Harm Understanding. arXiv, 2026-07-29, accessed 2026-11-09.
  11. Do Users Write More Insecure Code with AI Assistants?. ACM CCS '23 (arXiv version), 2023-12-18, accessed 2026-11-09.
  12. AI in software engineering at Google: Progress and the path ahead. Google Research, 2024-06-06, accessed 2026-11-09.
  13. How Do AI Coding Agents Contribute to Software Development? an Empirical Study of Agentic Pull Requests. arXiv, 2026-07-23, accessed 2026-11-09.
  14. Many SWE-bench-Passing PRs Would Not Be Merged into Main. METR, 2026-03-10, accessed 2026-11-09.
  15. How are developers using AI? Inside our 2025 DORA report. Google (The Keyword blog), 2025-09-23, accessed 2026-11-09.
  16. We are Changing our Developer Productivity Experiment Design. METR, 2026-02-24, accessed 2026-11-09.