Context Drift in AI Coding Assistants: Cleaning Up and Governing Project Knowledge

    Conflicting project documents can lead AI coding assistants to give confident answers without flagging disagreements. This article distinguishes context drift from context rot and outlines five governance practices for keeping repository rules, task instructions, and business documentation consistent.

    A Hidden Failure Mode

    Suppose your project contains two documents describing the refund policy: one says 14 days, while the other says 30 days. You ask an AI coding assistant to answer a customer’s question using the project documentation, and it promptly gives a number. As the reviewer, can you tell from that answer whether it encountered the alternative policy?

    In most cases, you cannot. A developer ran a set of controlled experiments with AI coding tools. In matched tasks where task-specific instructions conflicted with project-wide rules, the models followed the task instructions in 95% to 100% of cases. Across 110 runs in which the models were not asked to report conflicts, they never volunteered that a disagreement existed.

    This points to a practical risk: you cannot rely on the model to identify conflicting documentation. It may quietly select one source and return an answer that sounds certain.

    Two Context Problems That Should Not Be Confused

    Anyone who has used AI to write code over long conversations will recognize the first problem: as the conversation grows, the assistant repeatedly revisits approaches that already failed, and response quality deteriorates. This is commonly called context rot—the accumulation of history and noise within a single session that degrades output quality.

    The usual remedies are familiar: compress the conversation history, remove distracting information, or start a new session.

    But restarting does not solve the second problem. Consider this project structure:

    1. project/
    2. ├── AGENTS.md # Global rules: refund period changed to 14 days
    3. ├── tasks/
    4. │ └── support/
    5. │ └── skill.md # Task instructions: still specify 30 days
    6. └── docs/
    7. └── refund.md # Outdated documentation from three months ago: 30 days

    Even in a completely fresh conversation, the assistant may encounter task instructions, global rules, and historical documentation that give different answers. This gradual loss of alignment among persistent documents is called context drift.

    The key differences are:

    Dimension Context Rot Context Drift
    Where the problem occurs Too much noise accumulates within a conversation Multiple project documents no longer agree
    When it appears Becomes more likely as the conversation grows Can occur on the first turn of a new session
    What the user sees Off-track answers or repeated failed approaches A fluent answer that presents only one version
    Where to start investigating Clean up message history and restate the task Locate conflicting source text and determine which document is still authoritative

    How Context Drift Develops

    Context drift does not require a major mistake. A typical sequence looks like this:

    1. Team A updates the integration instructions, but only in the directory it owns.
    2. Team B maintains its own copy, and nobody tells it to synchronize the changes.
    3. A new team member finds only the task-level copy and follows it successfully enough to complete the assignment, so the discrepancy goes unnoticed.
    4. Months later, the project contains two equally confident documents that contradict each other.

    When human engineers hand work over, these inconsistencies often surface through code reviews, integration testing, or informal conversations. AI coding assistants do not reliably provide that incidental discovery process. They receive a task, read files, choose a source, and proceed—quietly and efficiently.

    As a result, drift stops being merely a coordination problem between people and becomes a risk that can recur whenever an AI assistant uses the affected documents.

    Governance Practices: Clean Up the Agent Knowledge Base

    If your project uses global rule files, such as repository-level instructions, alongside task-specific instructions, such as skill files, review them regularly using the following practices.

    1. Establish a Single Source of Truth

    For every critical business concept—policy values, interface contracts, or deployment procedures—designate one authoritative document. Other documents should reference it rather than duplicate its contents:

    1. <!-- tasks/support/skill.md -->
    2. The refund period is defined in `docs/policy/refund.md`.
    3. This file does not restate the specific number of days.

    2. Make Consistency Checks Executable

    Turn “documents must not contradict each other” into a checkable requirement.

    You can add lightweight validation to CI, such as keyword scans that identify repeated declarations of the same value. Alternatively, periodically give a model a dedicated review task: read all rule files and list factual conflicts without executing any operational task.

    Conflict detection must be explicitly requested. The experiments described earlier show why it should not be assumed to happen by default.

    3. Add Review Metadata

    Include metadata in documents whose contents are likely to change:

    1. ---
    2. owner: support-team
    3. last-reviewed: 2025-06-01
    4. ---

    A document that has passed its review deadline without anyone taking responsibility for it is a likely source of drift.

    4. Clarify Each File’s Responsibilities

    Global rules should contain constraints that apply across tasks. Task-specific instructions should contain the steps needed to perform that task.

    Clearer boundaries reduce the number of files that need to change when a requirement changes, lowering the likelihood of drift.

    5. Include Documentation Synchronization in the Change Process

    Any code change that modifies a business fact should also trigger a review of every document that references that fact.

    The principle is similar to a database foreign key constraint: when the underlying data changes, its references cannot simply behave as though nothing happened.

    Conclusion

    Context rot and context drift are different problems. The former is addressed by cleaning up the conversation; the latter is prevented through documentation governance.

    As agents increasingly act directly on repository rule files, those files effectively become system configuration. The fundamentals of configuration management apply: maintain a single source of truth and audit it regularly.

    Clean up your rule files and task instructions before their inconsistencies surface in production as a confidently incorrect answer.