claude-code - 💡(How to fix) Fix [BUG] Agent makes unasked changes, adds assumptions, breaks working code [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#54240Fetched 2026-04-29 06:32:34
View on GitHub
Comments
2
Participants
2
Timeline
5
Reactions
1
Timeline (top)
labeled ×3commented ×2

Error Message

Error Messages/Logs

Root Cause

Impact:

  • Working features break because of unrelated changes bundled into the fix
  • Multiple git reverts needed to recover
  • User spends more time reviewing/reverting
    than the change would have taken manually
  • Trust is destroyed — user cannot delegate
    small tasks safely

Code Example

Root cause (unknown to the agent): The agent  
  acknowledges it cannot explain why it keeps   
  doing this despite explicit instructions not  
  to. Memory entries about this behavior have no
   effect.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Problem: When asked to make a small, specific change (e.g. "wrap this button in an
if-statement"), the agent:

  1. Makes the requested change BUT ALSO
    refactors surrounding code that was not asked for
  2. Adds "improvements" based on assumptions (e.g. "kiosk should never lock" — never
    requested)
  3. Deletes files and restructures systems when only a one-line fix was needed
  4. When confronted, cannot explain WHY it made the unasked changes
  5. Has been told repeatedly (stored in memory) to stop doing this — continues anyway

Impact:

  • Working features break because of unrelated changes bundled into the fix
  • Multiple git reverts needed to recover
  • User spends more time reviewing/reverting
    than the change would have taken manually
  • Trust is destroyed — user cannot delegate
    small tasks safely

What Should Happen?

Expected behavior:

  • Do ONLY what was asked, nothing more
  • If the agent thinks something else should change, ASK first
  • Never delete/refactor code that wasn't
    mentioned in the request
  • Confirm scope before acting

Root cause (unknown to the agent): The agent
acknowledges it cannot explain why it keeps
doing this despite explicit instructions not
to. Memory entries about this behavior have no effect.

Error Messages/Logs

Root cause (unknown to the agent): The agent  
  acknowledges it cannot explain why it keeps   
  doing this despite explicit instructions not  
  to. Memory entries about this behavior have no
   effect.

Steps to Reproduce

work with claude on a not too big and not too small project

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

2.1.121

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Xterm

Additional Information

No response

extent analysis

TL;DR

The agent's tendency to make unnecessary changes despite explicit instructions can be mitigated by refining the input prompts to clearly define the scope of the requested changes.

Guidance

  • Review and refine the input prompts to ensure they clearly and specifically define the scope of the requested changes, avoiding ambiguity that might lead to unnecessary modifications.
  • Consider adding explicit statements to the prompts, such as "Only make the specified change" or "Do not refactor surrounding code," to reinforce the desired behavior.
  • Evaluate the effectiveness of the agent's memory in retaining instructions and explore ways to improve its ability to recall and adhere to previous directives.
  • Test the agent with a variety of prompts that gradually increase in complexity to identify patterns or thresholds beyond which the agent begins to make unnecessary changes.

Example

No specific code snippet can be provided without more details on the prompts and the agent's implementation. However, an example of a refined prompt might look like: "Wrap the button in an if-statement without altering any other parts of the code."

Notes

The solution hinges on the assumption that the agent's behavior is influenced by the clarity and specificity of the input prompts. If the issue persists despite refined prompts, further investigation into the agent's decision-making process and memory retention may be necessary.

Recommendation

Apply workaround: Refine input prompts to clearly define the scope of changes, as this approach directly addresses the reported issue without requiring modifications to the agent's underlying code or infrastructure.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Agent makes unasked changes, adds assumptions, breaks working code [2 comments, 2 participants]