Home / Errors / Replit / agent-breaks-working-features

Replit Agent broke my code: features it wasn't asked to touch

Replit Moderate 20-60 minutes Last verified Jul 17, 2026
The fix  Run git diff HEAD in the Shell to see every file the Agent touched, then restore clobbered files with the File History tool instead of a full rollback. If the Agent keeps reasoning about old versions of files you edited by hand, start a new chat and tell it to re-read those files: the Agent caches its own copies and misses manual edits.

Symptoms

  • You ask the Agent to add one feature and unrelated parts of the app break: forms stop submitting, API endpoints error, auth stops working
  • After you manually edit a file, the Agent keeps reasoning about the old version, as if your changes never happened
  • The Agent 'fixes' things based on stale code and silently reverts or conflicts with your hand-written changes
  • git diff shows edits in files you never mentioned in the prompt

Why it happens

The Agent edits shared code to implement narrow requests

While implementing a request, the Agent freely modifies shared utilities, config files, and base components. Those edits ripple into dependent code it never re-tested, which is how adding a feature breaks login.

The Agent caches its own copies of files

Users on Replit's forum documented that the Agent appears to cache file contents and does not always re-read manual edits made outside the Agent. Its next change can then silently revert or conflict with your hand-written code because it is working from a stale copy.

How to fix it

  1. Commit or fork before every Agent sessionCreate a commit, checkpoint, or fork before letting the Agent work. This gives you a clean revert point, and it makes the next step (auditing the diff) meaningful.
  2. Audit the damage with git diff HEADAfter each Agent task, run git diff HEAD in the Shell and scan the list of changed files before testing anything. Files you did not expect it to touch are where the collateral breakage lives.
  3. Re-test core flows, not just the new featureAfter each Agent change, re-test the flows that matter: login, save, pay. The new feature working tells you nothing about what the Agent's edits to shared code did elsewhere.
  4. Force the Agent to see your manual editsIf the Agent is reasoning about stale file contents after your manual edits, start a new Agent chat and explicitly tell it to re-read the specific files, or paste the current file contents into the prompt. Do not keep arguing with it in the old chat; the cached copy wins that argument.
  5. Restore individual files with File HistoryUse the File History tool to restore clobbered files one at a time rather than a full checkpoint rollback, which rewinds conversation and database state along with the code.
  6. Scope prompts to named filesPrompts like 'only modify routes/checkout.js' reduce collateral edits. The narrower the stated scope, the less shared code the Agent wanders into.

How to prevent it

  • Commit, checkpoint, or fork before every Agent session, no exceptions
  • Make git diff HEAD a reflex after every Agent task
  • Keep a short list of core flows (login, save, pay) and re-test them after each change
  • Scope every prompt to the specific files the Agent is allowed to modify
  • After manual edits, start a fresh Agent chat and have it re-read the changed files before it writes anything

Tools that actually fix this

Recommended because they address the failure mode above, not because of the payout. Some are affiliate links; see how we choose.

Frequently asked questions

Why did Replit Agent change files I didn't ask it to touch?

While implementing your request, the Agent freely modifies shared utilities, config files, and base components, and those edits ripple into dependent code it never re-tested. Run git diff HEAD in the Shell after each Agent task to see the full list of files it changed, and scope prompts to named files to limit the blast radius.

Why doesn't Replit Agent see my manual code edits?

Users on Replit's forum documented that the Agent appears to cache its own copies of files and does not always re-read manual edits made outside the Agent. The fix is to start a new Agent chat and explicitly tell it to re-read the specific files, or paste the current file contents into the prompt so it works from the real code.

How do I see everything Replit Agent changed?

Run git diff HEAD in the Shell after the Agent finishes. It shows every modified file against your last commit, including files you never mentioned in the prompt, which is where unexpected breakage usually hides. This only works if you committed before the session, which is why a pre-session commit or fork is the habit to build.

How do I restore a single file the Agent overwrote?

Use Replit's File History tool from the Tools sidebar, which keeps per-file version history independent of Agent checkpoints. It restores the one clobbered file without a full checkpoint rollback, which would also rewind the Agent conversation and development database state.

Sources

Related errors

The Vibe Oops briefing

One email when something ships to production that should not have. New incidents, new error guides, no filler.