Skip to content

PATTERN Cited by 1 source

Codebase correction as implicit feedback

Problem

LLM-based coding agents inherit whatever patterns exist in the codebase they read. If a codebase has a sloppy pattern — a deep-clone where a reference would do, an allocation inside a tight loop, inconsistent error handling — a new agent session reading that code will reproduce the sloppy pattern in the new code it generates. Explicit per-session correction doesn't persist: telling the agent "use references, not clones" in one session doesn't carry into the next conversation.

The pattern

Merge corrections to the mainline codebase once; let future agent sessions discover the corrected pattern implicitly through their normal codebase reading. No dedicated context file, no memory transfer, no fine- tuning — the agent's standard read-the-surrounding- code behaviour becomes the memory channel.

The pattern is a direct consequence of concepts/source-code-as-agent-feedback-loop: the codebase is the agent's implicit long-term memory, so corrections to the codebase are implicit agent-behaviour updates.

Canonical wiki instance

From Anthony Shew's 2026-04-21 Turborepo post verbatim:

"In places where the existing code had a sloppy pattern, the agent would write new code in the same style. Once I corrected one instance, the agent followed the correction going forward. In future conversations, without any memory or context carrying across chats, the agent would see the merged improvements in the source and stop reproducing the old patterns."

The pattern is emergent from agent retrieval mechanics, not engineered — it costs nothing to maintain because it's a side effect of normal PR workflow.

Observable behaviours over time

Shew's canonical observations across the 8-day campaign:

  1. Pattern propagation per-session. Asking the agent "do you see anywhere else where we can improve in the same way?" after a correction elicits the agent finding other instances — that session's work already benefits.
  2. Cross-session style consistency. Future unrelated sessions adopt the corrected style without being told. No explicit prompt engineering needed.
  3. Capability uplift over time. "I would revisit a place in the codebase where the agent had previously been ineffective, and, with no changes to model or harness, it would produce better code outputs." The codebase's improved hygiene compounds into agent capability.
  4. Spontaneous test-writing. "Over time, I noticed the agent spontaneously writing tests when I wasn't expecting it to." Not just pattern correction — quality discipline propagates too.

Mechanism

Agent retrieval on a given edit typically includes:

  • The file being edited (with its current surrounding code).
  • Adjacent files / sibling modules (through symbol- search, grep, or retrieval).
  • Documentation / README / AGENTS.md if it exists.

All three surface the current mainline state. If the dominant style in the file is the corrected style, the agent's next-token prediction is biased toward the corrected style — the model's pretraining prior combines with the codebase's current-state signal.

Discipline implications

  • Fix one instance, mention it, merge. The PR doing the correction is the memory-update mechanism.
  • Don't defer corrections. Sloppy patterns that persist in the codebase actively train the agent to produce more sloppy patterns — compounding technical debt in an agent-assisted-engineering world.
  • The codebase IS the style guide. Explicit style guides in CONTRIBUTING.md matter less than the style guide encoded in the actual merged code.
  • Review for consistency with surrounding code. Code review that catches style inconsistency protects the agent's implicit feedback channel — landing inconsistent code poisons it.
  • Refactor before new features. If an area of the codebase has patterns you want to move away from, refactor first — the subsequent agent-assisted feature work inherits the cleaned-up patterns.

Distinction from explicit context files

Implicit correction (this pattern) Explicit file (patterns/precomputed-agent-context-files)
Update mechanism Normal PR Explicit file edit
Risk of staleness None High (concepts/context-file-freshness)
Agent discovery Retrieval-driven File-read-driven
Scope Wherever the pattern appears Whatever authors wrote
Maintenance cost Zero Explicit

The two are complementary: explicit context files encode architectural invariants the codebase can't show (build commands, conventional locations, deprecation status); implicit codebase correction encodes style + idiom choices the codebase shows directly.

Siblings at other altitudes

  • patterns/in-code-annotation-as-llm-guidance (Shopify 2025-09-12) — inline comments as explicit author intent delivered through the code itself. Hybrid: the annotations are in the code (implicit delivery) but explicit in author intent.
  • patterns/precomputed-agent-context-files (Figma CONTEXT.md) — fully-explicit documentation channel.
  • Codebase-correction as feedback (this pattern) — fully-implicit; the code itself is the signal.

Three altitudes of the same underlying codebase-as-agent-substrate discipline.

Limits

  • Requires mostly-clean codebase. If the dominant pattern is wrong, the implicit feedback reinforces it.
  • Requires agent harness with good retrieval. Harnesses that don't expose the surrounding code effectively (no symbol index, no broad grep, poor retrieval) don't benefit.
  • Works better with per-area consistency. A file with both patterns mixed confuses the signal; a refactor that cleanly replaces one pattern with another sends a strong signal.
  • Doesn't substitute for explicit architectural constraints. Build system choices, dependency policies, deprecation timelines still need explicit documentation.

Seen in

  • Making Turborepo 96 % faster (Vercel, 2026-04-21) — canonical wiki instance; definitional source; Anthony Shew's "your own source code is the best reinforcement learning out there" framing.
Last updated · 476 distilled / 1,218 read