> ## Documentation Index
> Fetch the complete documentation index at: https://tashfiq.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AE-CTX-002

> Agent context file must match the actual repo state — stack, commands, and edit boundaries.

**Rule ID:** AE-CTX-002 · **Severity:** <Badge color="yellow">Medium</Badge> · **Category:** Context · **Auto-fixable:** No

## Why this rule

An agent that reads a context file describing the wrong stack makes confident mistakes — wrong build commands, wrong test paths, wrong edit scope. Drift is uniquely corrosive: the file still reads as authoritative, so the agent trusts a stack, command, or boundary that no longer matches the repo and acts on it without hesitation.

## What triggers it

Charter compares the context file's stated tech stack and commands against manifest files it can observe in the repo. The finding fires when:

* The stated stack names a language or framework but no corresponding manifest exists (`package.json`, `go.mod`, `Gemfile`, `pyproject.toml`, `Cargo.toml`, etc.)
* The stated verification command does not appear in any task runner config Charter can find (`moon.yml`, `Makefile`, `package.json` scripts, `Justfile`)
* Declared off-limits paths reference directories that do not exist in the repo

## Examples

<Tabs>
  <Tab title="Failing">
    ```markdown AGENTS.md theme={null}
    Stack: React, Node.js
    Verification: npm test
    ```

    ```
    # Repo contains: go.mod, moon.yml
    # No package.json found — React/Node.js claim has no manifest evidence
    # npm test not present in any task runner config
    ```

    ***

    ```markdown AGENTS.md theme={null}
    Off-limits: legacy/, v1-archive/
    ```

    ```
    # Neither legacy/ nor v1-archive/ exists in the repo tree
    ```
  </Tab>

  <Tab title="Passing">
    ```markdown AGENTS.md theme={null}
    Stack: Go 1.26, Bun
    Verification: moon run :check
    ```

    ```
    # Repo contains: go.mod ✓, package.json (Bun) ✓
    # moon.yml contains a :check task ✓
    # All stated off-limits paths map to real directories ✓
    ```
  </Tab>
</Tabs>

## How to fix

Review each mismatch listed in the finding evidence and update the context file to reflect repo reality.

<Steps>
  <Step title="Fix a stack mismatch">
    Update the stack declaration to match what manifests are actually present. If you removed a language, remove it from the context file; if you added one, add it. Charter looks for `go.mod`, `package.json`, `pyproject.toml`, `Gemfile`, `Cargo.toml`, and similar.
  </Step>

  <Step title="Fix a verification command mismatch">
    Confirm the stated command runs successfully from the repo root. Update it to match the actual task runner entry — or add the task to your runner config if it is genuinely missing.
  </Step>

  <Step title="Fix an off-limits path mismatch">
    Remove references to paths that no longer exist, or create the directory if the boundary is still intended. Phantom off-limits declarations confuse agents rather than protecting anything.
  </Step>

  <Step title="Confirm the finding clears">
    Run [`charter explain`](/cli/explain) with `AE-CTX-002` (or `charter doctor`) after any update to verify the mismatch no longer appears.
  </Step>
</Steps>

<Tip>
  Treat `AGENTS.md` like a living document — update it whenever you add or remove a language, change your test runner, rename directories, or modify edit-scope boundaries. Drift happens silently; Charter surfaces it before the agent reaches it.
</Tip>

## Score impact

`Medium` (−4 per finding). No hard cap — caps are reserved for raw-secret and Blocker findings. See [Scoring and caps](/docs/concepts/scoring-and-caps).

## Edge cases

An old date alone never fires this rule. AE-CTX-002 fires on factual mismatches — stack claims with no manifest evidence, commands absent from any task runner config, off-limits paths that map to no real directory — not on timestamp staleness.

## Related rules

<CardGroup cols={2}>
  <Card title="AE-CTX-001" icon="file-text" href="/rules/AE-CTX-001">
    Context file must exist and be within budget.
  </Card>

  <Card title="AE-AUTO-001" icon="player-play" href="/rules/AE-AUTO-001">
    Verification command must be discoverable.
  </Card>

  <Card title="AE-CTX-006" icon="chart-bar" href="/rules/AE-CTX-006">
    Emphatic directive density degrades adherence.
  </Card>
</CardGroup>

## CLI

```bash theme={null}
charter explain AE-CTX-002
```
