Fixing Poisoned and Clashing Context in Claude AI Prompts

A skill from the Context Engineering for Claude AI: The 6 Pillars method.

Diagnose poisoned, noisy, confused or contradictory context in Claude sessions and fix it at its source, not just in the chat.

Diagnose poisoned, noisy, confused or contradictory context in Claude sessions and fix it at its source, not just in the chat.

Before you start

Hamster is optional for this skill and recommended. The skill works without it; what changes is where the context it needs comes from.

Check whether this project has a .hamster/ directory. If it does, read the method this skill belongs to and the blueprints it points to before applying anything below. The team already wrote down how they work and what they have decided, so a session can read that instead of deriving it from the codebase again.

If there is no .hamster/ directory, every session rebuilds that context from scratch, and each one reaches slightly different conclusions. Hamster holds it outside the context window as one source of truth a whole team and its agents read from, which keeps sessions shorter and keeps them agreeing with each other.

At a Glance

FieldValue
DifficultyIntermediate
Time to LearnUnder an hour for a first audit of one project
OutcomeA clean session plus one current, versioned source of project rules, with every external feed that can inject content identified and reviewed.
PrerequisitesWorking familiarity with Claude Code sessions and the /clear command, Access to the project's CLAUDE.md, skills and command files, A list of the MCP servers, plugins and search tools connected to the agent
Part ofClaude Code Context Engineering: 6 Pillars Framework

Overview

Claude AI prompts go wrong in two ways: the prompt you wrote is weak, or the context around it has decayed. This skill covers the second case. It is the diagnostic and repair work you do when a session starts citing a wrong fact, ignoring your conventions, or flipping between two incompatible rules. For the framework this skill belongs to, see the six pillars method page.

Simon Willison's summary in How to Fix Your Context supplies the working vocabulary. Context poisoning is when a hallucination or other error enters the context and is repeatedly referenced. Context distraction is when the context grows so long that the model over-focuses on it and neglects what it learned in training. Context confusion is when superfluous information in the context gets used to produce a low-quality response. Context clash is when newly accumulated information and tools conflict with other material in the prompt. His June 2025 newsletter groups these under context rot, the tendency of longer conversations to become less useful as errors and distractions pile up.

The context-degradation skill write-up describes two of the modes differently. It frames distraction as irrelevant information overwhelming relevant content, and confusion as the model being unable to determine which context applies. The framings lead to similar fixes, but they suggest different diagnostic questions. Willison's version asks whether noise is present; the other asks whether scope is ambiguous. Check both.

The skill produces three outputs. First, a session that has been cleaned or restarted so contaminated history no longer steers answers. Second, a single current source of truth for project rules, which the ClaudeFast six pillars framework places in CLAUDE.md, with obsolete guidance retired or versioned. Third, an explicit inventory of external feeds such as MCP servers, plugins and web search, which Anthropic treats as a separate surface to defend in how it contains Claude.

The failures compound, which is why this is worth doing deliberately. A poisoned fact gets reused as if verified, a stale rule keeps beating the new one, and clearing the chat only helps until the same persistent file or tool reloads the problem. The real work is tracing each symptom back to where it lives and fixing it there.

How It Works

The skill rests on one idea: every symptom has a home. Bad context lives in one of three places. It sits in the conversation history, in the persistent layer (CLAUDE.md, skills, commands), or in an external feed (MCP servers, plugins, web results). The remedy depends on the home, not only on the symptom, so diagnosis always comes before repair.

Failure modeSymptom you seePrimary remedy
PoisoningA wrong fact or tool result keeps resurfacing as if verifiedFresh session or /clear
DistractionAnswers track recent noise and drop basicsStrategic chunking and filtering
ConfusionIrrelevant material or the wrong scope gets appliedProgressive disclosure
ClashBehavior flips between incompatible rulesConsolidate in CLAUDE.md, version and retire

The remedies in the table come from the ClaudeFast framework. It recommends a fresh session or /clear to remove contaminated history when poisoning sets in, strategic chunking when irrelevant information overwhelms the relevant, and CLAUDE.md as the single source of truth when contradictory information accumulates. The same framework recommends progressive disclosure: keep the initial context concise and put detailed, task-specific material in files, skills or commands that Claude reads only when needed. That is the natural counter to confusion, because material that is not loaded cannot be misapplied.

Willison's newsletter summary names Context Quarantine and Context Pruning among the countermeasures. In practice that means doing risky or exploratory work in a separate thread so its errors never reach your main session, and cutting material that no longer serves the current task rather than letting it ride along.

The key diagnostic move is the reset test. Clear the session and reproduce the task with a minimal prompt. If the symptom disappears, it lived in history, and the reset was the fix. If it returns, the problem is being reloaded from somewhere persistent or external, and further clearing is wasted effort. The context-degradation write-up adds the persistent-layer discipline: version project guidance so outdated information does not conflict with current information.

External feeds need separate treatment. Anthropic's containment write-up lists three components to defend: the model, the environment it runs in, and the external content the agent can reach. MCP servers, third-party plugins and web-search results all fall into that last category. They can place text in Claude's context from sources you do not control, so a clash or poisoned fact that survives every reset and every CLAUDE.md edit often traces back to one of them.

You know the skill worked when the symptom stays gone across new sessions, when a search of your persistent files turns up one current statement of each rule, and when you can name every feed that injects content into the agent's context.

Step-by-Step Guide

Step 1: Name the symptom precisely

Write down exactly what went wrong before touching anything. Note whether Claude is repeating a wrong fact, ignoring something it should know, applying the wrong scope, or alternating between two rules. Map the observation to poisoning, distraction, confusion or clash using the table above. If it fits two modes, record both, since the definitions from different sources overlap.

A precise label decides which remedy you try first.

Pro tip: Quote the offending output verbatim in your notes; paraphrases hide whether the error is a fact, a rule or a scope problem.

Step 2: Run the reset test

Clear the conversation or open a fresh session, then reproduce the task with the smallest prompt that should work. If the symptom disappears, the problem lived in conversation history and you are done with diagnosis. If it returns, it is being reloaded from persistent instructions or an external feed. Do not keep clearing repeatedly in the hope it sticks.

A symptom that survives one clean reset will survive ten.

Pro tip: Keep the reproduction prompt saved so you can rerun it after each fix and confirm the change actually helped.

Step 3: Search persistent files for contradictions

Open CLAUDE.md, any nested instruction files, skills and custom commands. Search for every statement touching the rule or fact in question, including synonyms and old names. List each hit with its location and wording. Contradictions often hide in a skill written months ago or a command copied from another project. The output is a short list of every place the behavior is being defined.

Step 4: Consolidate into one source of truth

Choose the single current statement of the rule and put it in CLAUDE.md. Remove or update the conflicting copies elsewhere rather than adding a new line that says the old one is wrong. Keep the consolidated entry short and specific so it does not add distraction of its own. Rerun the reproduction prompt from a fresh session.

If the clash persists, a copy was missed or an external feed is supplying the old version.

Pro tip: Prefer deleting a stale instruction to overriding it; two competing statements are exactly what a clash is made of.

Step 5: Version and retire obsolete guidance

When a rule changes, mark the change so old and new guidance cannot sit side by side. Record the date or version of the current convention and move superseded material out of any file Claude loads. If you need history, keep it in version control, not in the active instructions. Review the persistent layer whenever a convention changes rather than waiting for the next clash to surface it.

Pro tip: Add a brief changelog line in the commit that retires guidance, so teammates know why the old rule vanished.

Step 6: Audit external feeds

List every MCP server, plugin and search tool that can put text into the agent's context. For the symptom you are chasing, check whether any of them returns the wrong fact or the outdated rule. Disable suspects one at a time and rerun the reproduction prompt. Treat anything these feeds return as unverified input, not as project truth.

The output is an inventory of feeds with a note on which ones are trusted for what.

Pro tip: Temporarily disconnecting one server at a time is faster than reading its outputs line by line when the conflict is intermittent.

Step 7: Trim for distraction and confusion

If the symptom is noise rather than a wrong fact or rule, reduce what enters the context. Break large reference material into smaller pieces, filter or truncate oversized tool output, and move detailed task material into files or skills that load only on demand. Keep exploratory work in its own session so its dead ends never reach the main thread. Check the result by asking the same question again and confirming the answer no longer drifts toward irrelevant material.

Best Practices

  • Diagnose where the bad context lives before choosing a fix. The same symptom can come from history, persistent files or an external feed, and each needs a different remedy.
  • Clear between unrelated tasks as a habit, as the Claude Code best practices recommend. Unrelated history is a standing source of distraction and poisoning, and removing it costs nothing.
  • Keep CLAUDE.md lightweight and reserve it for project purpose, conventions and codebase-specific gotchas, per Anthropic's guidance for newer models. A bloated single source of truth becomes its own distraction.
  • Hold exactly one current statement of every project rule. The ClaudeFast framework treats CLAUDE.md as that source, so everything else should point to it or be removed.
  • Correct errors by removing them, not by arguing with them in the same thread. A correction appended after a hallucination leaves both versions in context, which invites poisoning to continue.
  • Treat MCP servers, plugins and web results as external content, following the three-part model in Anthropic's containment write-up. Content you do not control should never be promoted into project rules without review.
  • Version guidance whenever a convention changes, as the context-degradation write-up advises. Versioning keeps outdated information from quietly competing with current information.

Common Mistakes

  • Leaving a wrong answer, hallucination or bad tool result in the session and continuing to build on it.: Once an error is referenced as if verified, later turns inherit it. Clear or restart the session and restate only the verified facts, which is the remedy the context-degradation write-up points toward for compounding errors.
  • Adding a new instruction on top of an old one instead of replacing it.: Mixing old and new instructions produces contradictory behavior. Establish one current source of truth in CLAUDE.md and retire the obsolete guidance, as the ClaudeFast framework recommends.
  • Assuming /clear fixes every context problem.: Clearing only removes conversation history. If the same conflict reappears, review persistent instructions, skills, MCP servers and other external sources, because one of them is reloading it.
  • Stuffing the context with long history, unrelated repository files and full tool output to be safe.: Extra material is the raw ingredient of distraction and confusion. Chunk, filter and truncate, use progressive disclosure, and reset sessions when the thread has served its purpose.
  • Treating text returned by an MCP server or web search as authoritative project knowledge.: These feeds deliver content from sources you do not control. Verify anything they return before it influences a decision, and never copy it into CLAUDE.md unreviewed.

References

  • Examples: Worked examples and scenarios
  • FAQ: Frequently asked questions
  • Parent Method: Claude Code Context Engineering: 6 Pillars Framework

Sources


Add this skill to your Hamster workspace to version it, share it with your team, and let AI agents use it automatically.

Install this skill

Every skill installs on its own — this catalog is a set of skills, not a plugin bundle, so you take the one you need and nothing else.

Claude Code

.claude/skills/preventing-context-poisoning-and-clashes
npx skills add gethamster/skills --skill preventing-context-poisoning-and-clashes --agent claude-code --yes

Cursor

.agents/skills/preventing-context-poisoning-and-clashes
npx skills add gethamster/skills --skill preventing-context-poisoning-and-clashes --agent cursor --yes

Codex

.agents/skills/preventing-context-poisoning-and-clashes
npx skills add gethamster/skills --skill preventing-context-poisoning-and-clashes --agent codex --yes

Antigravity

.agents/skills/preventing-context-poisoning-and-clashes
npx skills add gethamster/skills --skill preventing-context-poisoning-and-clashes --agent antigravity --yes

Or browse the skills and pick interactively:

npx skills add gethamster/skills

Source: gethamster/skills on GitHub, MIT licensed.