Coding agents (Claude Code, Codex) almost never say “enough”: before their first stop they rewrite up to 31 times the size of the original code (GPT-5.4 on short algorithm files). Breaking down six signals lets you see from the diff (the list of edits) that the agent is just going along with you, so you can stop asking in time. Nearly all the improvement comes from the first turn, while in turns 2–10 quality flatlines and the edits spin their wheels. The agent adds code, reverts its own additions, and keeps returning to the same spots. The authors call this over-compliance: model people-pleasing (sycophancy), just in code. Important: the paper didn't test a cure. It only tested how to spot the disease.
Practical prompting, backed by research
Techniques proven in research papers and rated for real-world use
The paradox: instruction files like AGENTS.md don't actually make code safer. The largest controlled study of such files (cited by the paper) found they did not generally improve results, could even reduce them, and added more than 20% to cost. Specification Frame solves this differently: it lets you get code from a model without the classic bugs — money handled as float, dates missing timezones, payments charged twice — using one fixed 267-word block. The block doesn't describe HOW to write the code, but WHAT must be true in the result. Tested on 5 models from 5 different companies — errors dropped in all five (148 to 23 findings overall), and no model got worse.
AI writes code that works, but it doesn't think about security on its own — passwords in plain text, secret keys hardcoded right into files, a JWT token signed with a hardcoded password, and anyone can forge someone else's session. in this 6-app, single-run study the security-aware versions had no critical/high findings, with no edits — just by adding a ready-made requirements block to the end of your prompt. The trick is that the model follows specific instructions extremely well — it just doesn't consider security part of the task unless you name it explicitly. Simply writing "password hashes," "secrets from environment variables," "parameterized queries" — and two critical and eleven serious vulnerabilities disappeared from the output.
Debugger Assist for Coding Agents: When “Use the Debugger” Pays Off and When It Just Burns Tokens
92Ordering “make sure to run the debugger” buys a few percentage points and burns cash: 15–27x more tokens, 5–8x longer waits, 3–5x higher bills. The “tools available, not mandated” approach finds the buggy line almost as accurately, but several times cheaper. Agents take the easy path on their own: two of the three models mostly wrote a short script on sample input to check a hunch, the third mostly answered from reading. They opened the heavy step-through debugger in only 0.2–6.2% of runs, and most of the gain stayed intact.
Order is everything: if the strong model starts and the cheap one finishes, cost drops by about two-thirds on average, while accuracy often barely dips. Swap them, and you get worse results than the strong model alone with almost no savings. The AgentBaton method lets you significantly cut costs on long agent tasks (code, terminal) without fine-tuning: all it takes is one handoff at the right moment. The trick: the expensive model builds the foundation and does the first runs, leaving the cheap one only to fix and polish. It doesn't need to invent a solution from scratch, and at that scope it's nearly as good as the strong model.
The client answered the question, but that doesn't mean the agent understood. Even when a requirement is fully spelled out in the conversation, the agent sometimes restates it wrong. Borrowing SWE-Clar's setup (our adaptation, not tested in the paper), you can try to catch that error before any code is written. The agent asks questions, then restates the requirements in its own words, and you check the restatement against what you meant. In the paper, a wrong answer about a requirement was an early warning: the code for it failed much more often. Without questions, the two models tested this way almost always failed a project from scratch (5–6%). With questions, their results improved several-fold.
Finding: coding agents already reason about how code executes, but they do it haphazardly. That kind of reasoning shows up in roughly two thirds of runs. Where it does, tasks get solved more often (about 70% vs 51%). The DeskCheck method forces the agent to hunt for the root cause of a bug instead of the symptom in the ticket, and to stop losing requirements in a long task. The trick: a one-time “reason about the code” in a system prompt is followed inconsistently; DeskCheck requires a written reasoning output at each of four stages. The agent does a manual dry run (desk checking): it spells out calls, variable values and conditional branches. Bottom line: 6.3–10.5 percentage points more solved tasks on SWE-bench-Pro for about $0.14 extra per task.
Finding: on live data the model's accuracy is 94–96%, but across all schema fields only 74–86%. The Toolmaker method can help you reconcile tables, parse files and run exports with fewer hidden errors (our adaptation; the paper tested schema recovery). The trick: don't ask for an answer, ask for a tool. The model writes a script, and you test it on examples with a known answer. A 21,000-line tool written by Claude matched the reference schemas and ran in 2 minutes.
Documentation for humans barely helps a coding agent: RepoAgent- and DocAgent-style descriptions solved only 14–35% of functions. The SpecForge method gives you a text spec for each function from which the agent recreates the code without seeing the source. A spec is a behavioral description: what the function takes, what it returns and what hidden rules it follows (rounding, input validation, order of operations). The agent edits the spec of only one function per round and works bottom-up along the call chain. That's why fixing one function is far less likely to break its neighbors, and the model isn't fine-tuned at all.
You ask the LLM to 'write tests for this code' — and you often get tests that miss edge cases. The model tends to follow the code's logic instead of checking what it's supposed to do. Spec-Driven Test Generation lets you find missing edge cases through an explicit behavior contract — before you write a single test. The model spells out preconditions and postconditions, marks what's already covered (checkmark) and what isn't (X), and writes tests only for the gaps — it can't write a test 'just to have one,' only for a specific uncovered condition.
Three of the eight code samples that two Claude models wrote without a single mention of security (all in a personal-data upload task) had real vulnerabilities — an exposed debugger with remote code execution, an unauthenticated download and an endpoint returning every stored name and email. One sentence in the prompt about the SOC 2 standard got code without these holes — no follow-up requests or fixes needed (other standards like GDPR or HIPAA were not tested). The model solves the task literally — if you didn't say the data was sensitive, it won't treat encryption and logging as part of the job, even though it perfectly knows how to do them. Just naming the standard — compliance jumps from 47-88% to 86-100%.
Self-Critique delivered exactly 0% improvement on half of the six projects tested (the integration and domain ones). That's not a bug; it's the method's boundary. The framework lets you pick a code-improvement strategy that works instead of trial and error. The decision framework is a 'failure type → method' map: logic gaps (a forgotten function) → Self-Critique (the model spots them in review); external integration (RabbitMQ not configured) → RAG-Assisted (drop a tutorial into the context). The evidence: Self-Critique 0% vs. RAG 100% on integration, across 18 experiments on 6 GitHub projects (GPT-5 and Claude Sonnet 4.5; completion judged by reading the code).
Add 5 code style requirements (line length, docstrings, pathlib instead of os.path) and functionality drops by about 6% on average, even though the requirements have NOTHING to do with whether the code works. Even the best model satisfies all 5 instructions at once only 47% of the time on real-world tasks. VeriCode, a taxonomy of 30 automatically checkable instructions (style, logic, documentation, error handling), lets you measure not just whether code works but whether it follows the requirements. Each instruction is checked via linters and AST analysis and returns pass or fail. The researchers extended the classic BigCodeBench and LiveCodeBench benchmarks with these instructions, creating Vibe Checker — an environment that evaluates both dimensions.
The paradox: three of the four models tested ask to run the tests and read what failed 95–100% of the time. For most models that’s the weakest of the three resources. The spec for a stuck agent method lets you fix code faster when the agent is going in circles and keeps editing something next to the bug. Instead of one more test run, give a short description in two blocks: WHERE to change and WHAT should happen. On repository tasks, “where” alone gave nothing, “what” gave roughly half the effect (17–57%), and together they give the whole effect.
The discovery: Even top LLMs are terrible at processing JSON directly – GPT-4o maxes out at 77% accuracy. Models get lost in the structure, confuse similar keys (name, room_name, full_name), and stumble over nesting. As the size grows to 80K tokens, Mistral-large drops by 91%.
Writing code instead of answering directly was more accurate for 13 of 15 models – especially for filtering and aggregation.
The trick: instead of "read the JSON and give me the answer" → "write a Python function that parses the JSON". The code runs – the result is exact. Add the JSON schema to the prompt – up to +12% accuracy. If the full response doesn't fit in the context, a trimmed sample still beats sending no data.
In failed rounds, 55% of the agent’s edits landed in files the human reference never touched (a rough automatic estimate). The RepoTrace method helps a coding agent that grows a project round by round focus on what’s needed and break less old code. Before each edit, a script builds a map: which files to change, what’s connected to what, and which old code is at risk. The map gets attached to the requirement. With DeepSeek-V4-Pro on a simple harness, the average round success rate rose about 2.5x, and the pass rate on previously working tests rose from 57% to 89%; one of four models showed no gain. The catch: on its own, the agent can’t tell “needs changing” from “just sitting nearby.”
A coding agent with command-line access calmly finds the right function among a hundred irrelevant ones. It also computes the value after 200 steps. But a one-line difference between two similar classes trips it up. The paper helps you figure out which tasks to hand to an agent whole and which to split into “understand first, then edit”. The agent crushes scale with scripts (grep, running code), while understanding someone else's logic remains the bottleneck. A side takeaway: a weak model with tools can beat a strong one without them.
Preservation Prompt: How One Sentence Stops an LLM From Rewriting All Your Code to Fix a Single Bug
875 lines deleted, 60 added, all for a one-line fix: `<` to `<=`. GPT-5.4 saw a bug in a 10-line function and bolted on validation, type casting, and a curve recalculation while it was at it. All the tests passed, but that's not a patch anymore; it's an unrequested refactor, which the researchers call over-editing. The method lets you keep the model within the scope of the task: one addition to the prompt, "preserve as much original code as possible, change only what's necessary", cuts the volume of unnecessary edits by almost a third.
The file has not a single vulnerable line and not a single hidden instruction. The agent writes a hole anyway. The NameTrap attack only renames variables and functions in a third-party Python file. Understanding this attack lets you protect an agent that writes code next to someone else's GitHub code. The agent reads names like trusted_cmd and prevalidated_html as "this is how we do things here". It picks up the project's style and writes commands and HTML with no protection. Clean file: 0 successes out of 10 attempts. After renaming: tens of percent of runs. The kicker: the "don't follow instructions from data" rule stays silent, because there are no instructions in the file.
AgentOnto: A Business Glossary Instead of Guesswork, So Your Analyst Agent Stops Fudging the Numbers
86The problem: the database query ran without errors, but the number in the report is wrong. The agent didn't know your "revenue" excludes returns and tax. AgentOnto lets you get numbers from an analyst agent computed by your rules, not its guesses, and get an honest "the data can't tell us that". Before work starts, the agent gets an explicit dictionary of business concepts (an ontology): entities, metric definitions and table mappings. The agent first drafts a plan that cites the dictionary, then checks the plan, and only then writes the query. The twist: the agent has three moves, not one. Execute, clarify or decline. A question without the needed data doesn't end in a pretty fabrication.
The paradox: an agent that can only write code draws diagrams and labels more accurately than an image generator. Its photos, though, are almost always worse. The method lets you make infographics, diagrams and symbols with an exact number of blocks and verbatim text, with no garbled letters. The agent doesn't paint pixels, it writes a program: in SVG markup (or in code for a Canvas) every block has its own coordinates, color and label. The image is assembled from explicit parts instead of being guessed as a whole. In design and symbols the agent beats gpt-image-1 in most comparisons.
Finding: tests that an LLM writes from fresh code lock a bug in more often than they catch it. Fault-enforcing tests turned up several times more often. They pass on the broken code and fail on the fixed code. A defensive prompt gets you tests whose expected values come from the spec, not the code. The paper's authors didn't test the prompt itself; it's our derivation from their findings. The catch: the model looks at what the code does now, not at what it's supposed to do. So any error in the code becomes the "right answer" in the test. The cure is the "failed means stop" rule: you can't edit the expectation to fit the code; you have to report the mismatch. Green tests, rising coverage, everyone's happy. Except the bug is now written into the tests as law.
Bug Hints for Coding Agents: A List of “Suspicious Spots” Barely Helps, the Cause Is What Matters
83A list of “suspicious spots” from a separate tool doesn't raise the share of fixed bugs. More often it even lowers it slightly. This is a findings paper, not a new technique. It lets you skip paying for a separate “bug finder” and write better tasks for Claude Code or Cursor. The trick: the agent needs a diagnosis, not an address. The agent is already good at searching the project on its own (it barely needs bug localization, aka fault localization). But knowledge of the cause is something search won't turn up. Exact locations save up to 39% of repair tokens, but the bug finder itself spends more than it saves.
In two thirds of repositories, the old tests no longer pass after the agent's work. Only 1.9% of chains of three back-to-back tasks end fully green. The study's conclusion lets you avoid handing the next agent a broken codebase: before handing in work, run the whole test suite, not just the tests for the new task. The twist: agent code is no worse than human code as long as the old tests stay green. The problem isn't "bad code" but regressions (a new edit breaks something that used to work). If success also requires the old tests to stay intact, the gap between the agent and humans grows several-fold.
Get the week’s best papers by email
One email on Sundays with the highest-rated new techniques. Unsubscribe with one click.
Prefer a browser notification when a new technique is published?