<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: yuqin lin</title>
    <description>The latest articles on DEV Community by yuqin lin (@dmlin7777777).</description>
    <link>https://dev.to/dmlin7777777</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3956844%2F631fe794-9eb6-41c7-baff-2d122cced06f.png</url>
      <title>DEV Community: yuqin lin</title>
      <link>https://dev.to/dmlin7777777</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dmlin7777777"/>
    <language>en</language>
    <item>
      <title>Why Your AI Agent Keeps Rewriting Your Codebase — And How to Stop It</title>
      <dc:creator>yuqin lin</dc:creator>
      <pubDate>Thu, 28 May 2026 14:59:26 +0000</pubDate>
      <link>https://dev.to/dmlin7777777/why-your-ai-agent-keeps-rewriting-your-codebase-and-how-to-stop-it-3190</link>
      <guid>https://dev.to/dmlin7777777/why-your-ai-agent-keeps-rewriting-your-codebase-and-how-to-stop-it-3190</guid>
      <description>&lt;p&gt;You ask your AI agent to add a small feature. It rewrites three files you didn't mention, extracts a utility function that didn't need extracting, and introduces an abstraction layer "for future extensibility."&lt;/p&gt;

&lt;p&gt;Sound familiar?&lt;/p&gt;

&lt;p&gt;This isn't a model problem. It's a &lt;strong&gt;protocol problem&lt;/strong&gt; — and it happens specifically in the gap that no one has designed for yet.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Gap Nobody Talks About
&lt;/h2&gt;

&lt;p&gt;The AI-assisted development ecosystem has gotten very good at two things:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Starting fresh.&lt;/strong&gt; Spec-driven development, PRDs, interview-me skills — lots of tooling helps you go from "I have an idea" to "I have a plan."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Executing steadily.&lt;/strong&gt; Incremental implementation, TDD, thin vertical slices — once you know what to build, agents can implement it carefully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But there's a gap between them&lt;/strong&gt; that happens dozens of times in any real project:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You're mid-development. Something is half-built. And a new idea arrives.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Maybe you're testing what you built and realize it needs to work differently. Maybe a user gives feedback that changes the direction. Maybe you just think of something better while looking at the code.&lt;/p&gt;

&lt;p&gt;When this happens, most agents do one of two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Rewrite the foundation to accommodate the new idea&lt;/li&gt;
&lt;li&gt;Ask clarifying questions, then rewrite the foundation anyway&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Neither is what you actually want.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Agents Default to Rewriting
&lt;/h2&gt;

&lt;p&gt;The rewrite default isn't random. It comes from how agents reason about change requests.&lt;/p&gt;

&lt;p&gt;When you say &lt;em&gt;"I want to add X,"&lt;/em&gt; the agent evaluates the current codebase, sees where X doesn't fit cleanly, and takes the most "correct" path: restructure until X fits.&lt;/p&gt;

&lt;p&gt;This is locally rational but globally destructive. The agent optimizes for code cleanliness at the moment of the request. It doesn't know that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You have three other things half-done that depend on the current structure&lt;/li&gt;
&lt;li&gt;The restructure will force you to re-test things that were already working&lt;/li&gt;
&lt;li&gt;The new idea might not survive contact with reality and shouldn't justify a rewrite yet&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The agent treats every new idea as a confirmed requirement. But in real product development — especially AI-assisted development, where ideas surface faster than ever — most new ideas are hypotheses that need to be tested, not requirements that need to be built.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Five Questions an Agent Should Ask
&lt;/h2&gt;

&lt;p&gt;When a new idea arrives mid-development, five things need to be determined before a single line of code changes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Is this idea worth acting on now?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;New ideas aren't equal. Some are genuine blockers (a bug in the current main path). Some are improvements (the current thing works, but could be better). Some are extensions (a new feature or scenario entirely).&lt;/p&gt;

&lt;p&gt;These need different responses. A blocker should be handled immediately. An improvement should be batched. An extension should be parked for 24 hours — most new feature urges either fade or crystallize into something clearer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. How destructive is this change?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Some changes are reversible: add a new field, add a new route, change a UI element. You can always undo them.&lt;/p&gt;

&lt;p&gt;Others are one-way doors: change a database schema, modify an external API signature, delete files. These deserve more scrutiny — not because they're wrong, but because the cost of being wrong is high.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Does anyone actually consume what you're about to build?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before creating a new module, function, or API, count its real call sites. If the answer is zero, you're building for a hypothetical future. If the answer is one, you don't need abstraction. If the answer is three or more, now abstraction is worth considering.&lt;/p&gt;

&lt;p&gt;The "zero consumers" case is where the most over-engineering happens. An agent enthusiastically builds a general-purpose system that nothing actually calls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. What's the least destructive way to integrate this?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There's a spectrum of integration modes, ordered by how much existing code they disturb:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Wrap:&lt;/strong&gt; Add a layer around the existing code. Don't touch the original.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extend:&lt;/strong&gt; Add a new branch, parameter, or route. Don't change existing paths.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Branch:&lt;/strong&gt; Implement in parallel. Keep the old path, migrate consumers gradually.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replace:&lt;/strong&gt; Genuinely rewrite. Only when the old implementation is a real liability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most new ideas fit in Wrap or Extend. Agents default to Replace.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Is the same logic appearing in too many places?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the same pattern shows up three or more times, that's worth flagging — but not necessarily worth fixing immediately. Surface it, let the developer decide.&lt;/p&gt;




&lt;h2&gt;
  
  
  What This Looks Like in Practice
&lt;/h2&gt;

&lt;p&gt;Here's a real pattern from AI-assisted development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The scenario:&lt;/strong&gt; You're building a data dashboard. You've completed the user analytics page and the content analytics page. Mid-session, you think: &lt;em&gt;"We should add real-time collaboration."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Default agent behavior:&lt;/strong&gt; Begin evaluating the architecture for real-time support. Propose WebSocket integration. Maybe start refactoring the data layer to support shared state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What should actually happen:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Classify the idea: new scenario, not a bug. C-class — new feature.&lt;/li&gt;
&lt;li&gt;Log it to the inbox. Continue the current task.&lt;/li&gt;
&lt;li&gt;24 hours later, revisit: Is real-time collaboration something current users are asking for? Is the core dashboard even validated yet?&lt;/li&gt;
&lt;li&gt;If yes — then evaluate it properly, pick an integration mode, scope it as a real task.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The idea doesn't die. It gets a fair evaluation at the right moment, not an impulsive implementation at the wrong one.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Another scenario:&lt;/strong&gt; An existing utility function appears in five different files with slight variations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Default agent behavior:&lt;/strong&gt; Silently copy it into a sixth place, or silently "refactor" all five to use a common version (touching files outside the current task scope).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What should actually happen:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The agent flags it: &lt;em&gt;"I've found [X logic] duplicated 5 times. Consolidate now or log to inbox?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If the developer says "log it" — it goes to the inbox as a polish item. The current task continues uninterrupted. When the consolidation is eventually done, it's a clean, dedicated task — not a side effect of something unrelated.&lt;/p&gt;




&lt;h2&gt;
  
  
  The build-forward Protocol
&lt;/h2&gt;

&lt;p&gt;These five questions are the core of a SKILL.md I built called &lt;code&gt;build-forward&lt;/code&gt;. It's a set of agent instructions that fires whenever a new idea appears mid-development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule 1 — Classify first, don't code.&lt;/strong&gt;&lt;br&gt;
Every new idea gets an A/B/C label before anything is written. A (fix) = handle now. B (polish) = batch later. C (extend) = 24-hour cooldown.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule 2 — Assess destructiveness.&lt;/strong&gt;&lt;br&gt;
One-way door changes require an explicit impact matrix before proceeding. Two-way door changes proceed directly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Impact Assessment:
- Direct change:      [file / interface name]
- Downstream effects: [which consumers are affected]
- Rollback cost:      [high / medium / low — reason]
- Recommendation:     [proceed / new branch / defer]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Rule 3 — Consumer audit.&lt;/strong&gt;&lt;br&gt;
Zero consumers → don't build. One consumer → inline, no abstraction. Three or more consumers → now consider a shared layer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule 4 — Choose an integration mode.&lt;/strong&gt;&lt;br&gt;
Wrap → Extend → Branch → Replace, ordered by destructiveness. Pick the lowest one that works.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule 5 — Duplication alert.&lt;/strong&gt;&lt;br&gt;
Three or more occurrences of the same logic → surface it, ask whether to consolidate or log it.&lt;/p&gt;

&lt;p&gt;There's also a fallback for when the developer overrides the protocol: the agent doesn't argue, but it does force-output the impact matrix and defaults to the most rigorous evaluation (Replace mode). Informed decision, not blind compliance.&lt;/p&gt;


&lt;h2&gt;
  
  
  What This Isn't
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;build-forward&lt;/code&gt; isn't about blocking ideas. It's not a PRD process or a change freeze.&lt;/p&gt;

&lt;p&gt;It's about &lt;strong&gt;routing ideas to the right moment and the right path&lt;/strong&gt;. An idea that arrives as a C-class impulse at 2pm might become a valid B-class task at the next planning session. The 24-hour rule doesn't kill ideas — it filters for the ones that survive examination.&lt;/p&gt;

&lt;p&gt;It also isn't about making the agent more restrictive. An agent running &lt;code&gt;build-forward&lt;/code&gt; will still implement what you ask. It just asks five questions first, and picks the integration path that preserves rather than destroys.&lt;/p&gt;


&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;build-forward&lt;/code&gt; works with Claude Code, Cursor, Codex CLI, Gemini CLI — anywhere that supports SKILL.md files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# English version&lt;/span&gt;
curl &lt;span class="nt"&gt;-L&lt;/span&gt; https://github.com/dmlin7777777/build-forward/raw/main/SKILL.en.md &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-o&lt;/span&gt; .claude/skills/build-forward/SKILL.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The skill is on GitHub at &lt;a href="https://github.com/dmlin7777777/build-forward" rel="noopener noreferrer"&gt;dmlin7777777/build-forward&lt;/a&gt; — English and Chinese versions both available.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Bigger Picture
&lt;/h2&gt;

&lt;p&gt;AI coding assistants have made it trivially easy to generate code. The new bottleneck isn't generation — it's &lt;strong&gt;integration&lt;/strong&gt;. How do you connect new ideas to existing structure without creating the kind of churn that makes AI-assisted codebases feel like they're always being rebuilt from scratch?&lt;/p&gt;

&lt;p&gt;&lt;code&gt;build-forward&lt;/code&gt; is one answer to that question. The five rules aren't complicated, but they close a gap that most agent workflows leave completely open: the moment between "I just thought of something" and "the agent is already changing everything."&lt;/p&gt;

&lt;p&gt;That gap is where most of the wasted time in AI-assisted development lives.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Have you hit this problem in your own AI coding workflow? What's your current approach? I'd love to hear in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agentskills</category>
    </item>
  </channel>
</rss>
