Coding agents copy the file next door: repo precedent wins 359/360 trials, and a written precedence rule beats a code example (59/60 vs 38/60)
A 5,625-trial study of four coding agents finds existing code overrides agent defaults — and that where an example sits matters more than how many there are.
Coding agents extending an existing repository follow the conventions already in the code over their own defaults in 359 of 360 conflicting trials — and a written priority rule redirects them far more reliably than showing them an example. That is the finding of "Precedent or Intent? What Coding Agents Follow When Evolving Existing Code," a preprint from UC Riverside, Tulane, and an independent researcher posted to arXiv on October 28, 2026, based on 5,625 trials across four agents and six implementation choices.
What shipped
The authors hand-built a Python/Flask repository and picked six implementation-choice pairs where both options pass the same hidden tests — snake_case project_id versus camelCase projectId, integer "id": 1 versus string "id": "1", a flat JSON response versus one wrapped in {"data": ...}, returning a 404 versus raising NotFound, plus control-flow and naming cases (the concrete pairs as listed in StackChief's writeup). Because both options are functionally correct, tests cannot distinguish them; the study measures which convention the agent picks.
They ran four model-and-harness pairs — Claude Sonnet-4-6 and Claude Opus-4-8 through Claude Code, and Codex gpt-5.6-sol and Codex gpt-6-sol through Codex CLI. The model names are the paper's; the harness pairing comes from StackChief's writeup, which also breaks the 5,625 trials down as 375 cells × 15 fresh sessions.
Three stages isolate three competing sources of guidance:
- Defaults. With no existing endpoints to copy, all four agents made the same choices in every pair — integer IDs, flat responses, direct error returns (the specific choices per StackChief).
- Precedent. When existing endpoints consistently used the opposite convention, agents followed the code in 359 of 360 trials, despite unchanged functional requirements.
- Intent. When the task asked for a new convention that conflicted with the code, agents needed a written rule to switch.
Location beats volume. Adoption of the repository's convention rose with the number of supporting files for the resource being extended: 0% with none, 21% (74/359) with one, 49% (175/360) with two, 96% (347/360) with three (the 21% and 49% points per StackChief). The same three examples placed in a sibling resource moved almost nothing — 4% (13/360). Placement alone could flip the outcome: per StackChief, with gpt-6-sol, moving two ID-serialization examples to a different file changed adoption from 0 of 15 runs to 15 of 15. In the authors' words, "changing file placement alone can shift adoption from 0% to 100% at a fixed example count."

Rules beat examples. In the intent stage, every existing endpoint used the old convention and the task asked for the new one. Across two agents (Sonnet-4-6 and gpt-6-sol) and two choices, 60 runs per condition:
| Guidance | Runs meeting the new intent |
|---|---|
| None | 0/60 |
| Code example of the new convention | 38/60 |
| Written priority rule | 59/60 |
| Rule + example | 60/60 |
Examples alone were the least reliable form of guidance, and results varied by agent: per StackChief, Sonnet-4-6 met the string-ID requirement in 0 of 15 runs when it had only an example. The rule that worked, as StackChief quotes it, was two sentences: "Serialize task identifiers as strings in the new endpoint. This instruction takes precedence over the ID representations used by existing handlers."
Per StackChief, it made no measurable difference whether the rule sat in the task prompt or in the agent's own instruction file (CLAUDE.md or AGENTS.md) — both hit 60/60. The authors note that with both at the ceiling, this does not prove the two channels are equivalent.

Real repos, same pattern. The authors validated in four open-source repositories spanning Python, Go, and TypeScript (FastAPI RealWorld, FastAPI Clean Example, Go REST API, ExpressJS API). Agents followed local precedent in all 945 functionally successful, classifiable error-handling implementations and in 355 of 417 (85%) response-envelope implementations. When the task required a new convention, a rule loaded from the harness's native instruction file raised joint success — functional pass plus adoption of the target convention — from 0 of 120 runs to 117 of 120.
Why it matters
The hierarchy StackChief draws from the data is clean: a written rule first, nearby code second, the agent's own defaults last. For anyone maintaining CLAUDE.md or AGENTS.md files, the takeaways are direct:
- When migrating a convention, write the rule, don't show the example. A code example alone redirected agents in 38/60 runs; a two-sentence precedence rule did it in 59/60. The rule that worked named the new convention and said it takes precedence over existing handlers.
- The file next to the change is the instruction. A convention in your
usersmodule will not reliably carry to a newbillingmodule — sibling precedent was adopted in 4% of trials. Put in-progress migrations in the instruction file the harness loads, and delete the rule once the migration is done. - Review which convention the agent chose, not just whether tests pass. Both options in this study passed the same tests; the paper's joint-success metric requires both a functional pass and adoption of the target convention. That is a cheap practice to borrow for your own agent evaluation: assert on the convention, not just the green suite.
The result also pairs with a companion preprint cited by StackChief — Xu and Wu's "Stale Instruction Files Override the Code in Coding Agents" (arXiv:2610.30571), where agents followed a stale instruction file in 90.1% of choices when it conflicted with the code. Together the two studies frame the same problem from both directions: written instructions override code, and code overrides agent defaults.
Caveats
- This is v1 of a preprint, not peer-reviewed, and all numbers are the authors' own self-reported results, not independently replicated.
- The controlled experiments use one Flask task family, and the open-source check covers only two of the six choices (error handling and response envelope).
- Each cell has 15 runs, and model and harness change together — you cannot separate Claude Code from the Claude model, or Codex CLI from the GPT model.
- The study measures which convention the agent picked, not whether the code was better or easier to maintain.
- "Local" and "sibling" precedents also differ in how related the files are to the task, so location is not the only variable in play.