magus v0.4.3 is out. See what's new
¶ View generated markdown
6 min read

magus-context-audit

Short form: 3463 bytes, 41% smaller than the full form's 5888.

Audit the instructions an agent was given for statements that contradict each other or no longer match the tools. Covers the repo instruction file, installed skills, memory, the routing index, hook text and user-level files. Use after changing a guard rule, a denied command, or a documented workflow; before shipping a change to the agent integration; and when an agent has been behaving inconsistently or ignoring a rule. This is a lens over INSTRUCTIONS, not over code: it reports ranked findings for a human to act on and never edits anything itself.

Install it, rather than copying from this page:

magus agent install .claude/skills   # writes both forms below

An installed copy carries a provenance stamp, so magus doctor can tell you when a magus upgrade has made it stale. Text copied from this page carries none.

What an installed copy carries

magus agent install writes this frontmatter above the body. magus doctor reads it to report whether your installed skills are current.

field value
license GPL-3.0-or-later
compatibility any-agent
source magus
agent-skill-version 147
knowledge-schema-version 24
skill-content e58a7b150db9
skill-variant full

The skill-content digest covers this skill alone, and both forms below report it: they go stale together, never one silently, and a change to another skill does not move it.

The two forms

Both are hand-authored from one source body. The short form is the always-loaded primary - the enumeration dropped, the judgment kept, for the most capable readers rather than the least. The full form is its <name>-full twin, loaded by name when a reader wants the rationale. The bar above shows how much shorter the primary is; switch between them here to see exactly what it gave up. See Skills for how to choose.

magus agent install --tar | tar -xO -f - magus-context-audit/SKILL.md
# Auditing agent instructions

Lens, like `magus\insight`: observes, ranks; does not gate.
Output: findings list human decides on, never automatic edit.
Looks at text, not code: everything agent loads as authoritative, from sources magus does not own and cannot read in advance.
Agent reads all of it in one window; cannot tell which line newer or which file wins.
When two lines disagree -> agent picks one arbitrarily or stalls.

## Enumerate before reading

Cannot audit what you cannot list; riskiest source: one nobody remembers loading.
- repo agent file (`CLAUDE.md`, `AGENTS.md`, ...): always loaded, whole file, never scoped
- installed skills: whole directory; stale one looks identical to current
- local workspace-owned skill (`magus-local-development`): loads beside shipped set; nothing generates or verifies it
- harness memory entries: loaded at session start; point-in-time by nature
- routing index (`MAGUS.md`): invites reading; only true up to last regeneration
- hook-injected text: fires on every matching tool call; nothing displays it in one place
- user-level or global instruction file: invisible from inside repo; outranks nothing
- tool output agent trusts: deny reasons, usage text, doctor hints

## Check claims against tools, not documents

Resolve every claim against something that executes.

```sh
magus shell "<the exact command a document recommends>"
magus describe targets -o name        # does the target a doc names still exist
magus describe file <path>            # is that file really source / output
```

Then run commands instructions tell agent to run.
Work outward from what changed (diff, changelog, recent decision), not reading everything; conflicts cluster around recent edits.

```sh
grep -rn "<the command or rule>" <every source you enumerated>
```

## Rank

Every finding carries command that reproduces it; finding nobody can re-run is opinion.
Order:
1. Dead end: A forbids X, B requires X, no third path. Agent must break one or stall.
2. Stale claim: names command that no longer exists, no longer works, or now denied.
3. Split verdict: two sources describe one decision differently (one "advised", other "denied"); agent cannot tell which current. Local statement contradicting shipped skill: always this. Check each local statement's `retire-when` while here; retire-when may already be true.
4. Orphaned successor: denial or deprecated command names tool no statement documents.
5. Silent copies: one statement restated in several places.

## Do not report

- Different altitudes: skill with full ladder, hook injection with one line: one statement, two lengths; by design.
- Record of history: "Verified on <date> by doing X" describes what happened, not what to do now; journal entries point-in-time by nature.
- Stated exception: "Never pipe output, EXCEPT <case>" looks like conflict to grep; one statement with carve-out.
- Labeled note describing old behavior on purpose.

## Recommend, then verify fix landed

Fix at source; generator propagates.
magus's own skills: `internal/agent/skills/*/SKILL.md`, then reinstall.
Reinstall with binary built from edited source; confirm content digest moved:

```sh
magus doctor    # the agent skills check must report a CHANGED digest, or the install did nothing
```

Stale binary re-installs old body, reports success.
Prefer deleting conflicting line over reconciling.
When statement must appear twice -> one is source, other names it, not restates it.
magus agent install --tar | tar -xO -f - magus-context-audit-full/SKILL.md
# Auditing the instructions an agent was given

This is a LENS, like `magus\insight`: it observes and ranks; it does not gate.
The output is a findings list a human decides on, never an automatic edit.

It looks at the text, not code: everything an agent loads as
authoritative, from sources magus does not own and cannot read in advance.

An agent reads all of it in one window, with no way to tell which line is newer,
which file outranks which, or which was written for a version of the tools that
no longer exists. When two lines disagree, that is not a documentation nit: the
model cannot resolve it from inside, so it picks one arbitrarily, alternates
across turns, or spends reasoning budget arbitrating instead of working.

## Contents

- Enumerate before reading
- Check claims against the tool, not against the other documents
- Rank what you find
- Do not report these
- Recommend, then verify the fix landed

## Enumerate before reading

You cannot audit what you cannot list. The riskiest source is usually the one
nobody remembers is loaded.

| source | why it bites |
| --- | --- |
| the repo's agent file (`CLAUDE.md`, `AGENTS.md`, ...) | always loaded, whole file, never scoped |
| installed skills | whole directory; a stale one looks identical to a current one |
| a local, workspace-owned skill (`magus-local-development`) | loads beside the shipped set, but nothing generates or verifies it |
| the harness's own memory entries | loaded at session start, and POINT-IN-TIME by nature |
| a routing index (`MAGUS.md`) | invites being read, only true up to the last time it was regenerated |
| hook-injected text | fires on every matching tool call, and nothing displays it in one place |
| a user-level or global instruction file | invisible from inside the repo, and outranks nothing |
| tool output the agent is told to trust | deny reasons, usage text, doctor hints |

The user-level file is the one to check first precisely because it is not in the
repo: nothing about the workspace hints that it exists, and its author may not be
the person hitting the conflict.

## Check claims against the tool, not against the other documents

Two documents agreeing with each other and both being wrong is the common case,
not the exception: they were usually written in the same sitting by the same
person. Resolve every claim against something that executes.

```sh
magus shell "<the exact command a document recommends>"
magus describe targets -o name        # does the target a doc names still exist
magus describe file <path>            # is that file really source / output
```

Then RUN the commands the instructions tell an agent to run. A documented command
that errors is worse than an undocumented one: the agent trusts it, tries it,
fails, and has to invent a recovery nothing sanctioned.

Work outward from what CHANGED (a diff, a changelog, a recent decision), not by
reading everything. Conflicting lines cluster around recent edits.

```sh
grep -rn "<the command or rule>" <every source you enumerated>
```

## Rank what you find

Every finding carries the command that REPRODUCES it: the exact line a reader
runs to see the conflict for themselves, not a description of where you saw
it. A finding nobody can re-run is an opinion about a document, and it gets
argued with instead of fixed.

Report findings in this order. Here the order measures "how badly does this derail a
session", not "how wrong is the sentence".

1. Dead end: A forbids X, B requires X, and no third path exists. The agent must
   break one of the two or stall. Nothing else on this list is worth
   reporting before one of these.
2. Stale claim: it names a command that no longer exists, no longer works,
   or is now denied. It is indistinguishable from a dead end until the agent tries it.
3. Split verdict: two sources describe one decision differently (one
   "advised", the other "denied"), and the agent cannot tell which is current.
   A workspace-local statement contradicting a shipped skill is always this finding:
   local text overrides nothing, so the two are in conflict. Check each
   local statement's `retire-when` while here; the retire-when may already be true.
4. Orphaned successor: a denial or a deprecated command names a tool no statement
   documents.
5. Silent copies: one statement restated in several places. It is not yet a
   conflict; it is where the next one is born, because an edit updates
   some of them.

## Do not report these

A lens that cries wolf gets switched off, taking the real findings with it.

- **Different altitudes.** A skill giving the full ladder and a hook injection
  giving one line are one statement at two lengths. That is the design.
- **A record of history.** "Verified on <date> by doing X" describes what happened,
  not what to do now. Journal entries are point-in-time by nature.
- **A stated exception.** "Never pipe output, EXCEPT <case>" looks like a conflict
  to grep and is one statement with a carve-out.
- **A labeled note** that describes old behavior on purpose.

## Recommend, then verify the fix landed

Fix at the SOURCE and let the generator propagate it; editing an installed copy is
drift a verify step flags anyway. For magus's own skills that is
`internal/agent/skills/*/SKILL.md`, then reinstall.

Reinstall with a binary built from the EDITED source, and confirm the content
digest moved:

```sh
magus doctor    # the agent skills check must report a CHANGED digest, or the install did nothing
```

A stale binary re-installs the OLD body and reports success, which is the single
most common way an applied fix silently does not apply.

Prefer DELETING a conflicting line over reconciling it. Two reconciled
statements are still two statements to keep in sync; one statement cannot
contradict itself. When a statement must appear twice, make one the source and have
the other name it, not restate it.
generatedinternal/agent/skills/magus-context-audit/SKILL.mdagentsskillsmagus-context-audit
Last updated (61fd39a7)
Earlier changes on this page (7)

Full history ↗ · Blame source ↗

Glossary

Workspace

The magus root directory that owns a set of projects and shared config; the unit magus operates over. Workspace in full.

Target

A named operation (build, test, ...) you invoke with magus run <target>; it may compose a spell's tool-native operations and depend on other targets. Target in full.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). Op in full.

Ward

A coded diagnostic that inspects a resolved op and nudges or blocks an anti-pattern before it runs. Ward in full.

CI

An ordinary target you compose yourself with ctx.needs; magus does not hardcode its stages. It is the anchor magus affected ci keys off, and ci strips the rw charm. CI in full.

MAGUS.md

The committed routing index at a workspace root, regenerated from the knowledge graph: it lists every node and points at the exact query for a given question, so it is the entry point an agent reads first. MAGUS.md in full.

Insight

The reports magus derives over the graph and history (hotspots, affinity, ownership, trend, volatility, unreferenced). Insight in full.

Agent

A model working through an agent host such as Claude Code, Codex, Cursor or OpenCode. magus treats an agent as one more caller of its CLI, MCP tools and console, held to the same checks as a person. Agent in full.

Tool

An action a model can call through its host: a name, a description, a typed input and a result. magus serves its tools over MCP, each a read of the workspace model or a run of the CLI it already has. Tool in full.

Harness

The deterministic scaffolding around the work on a change, for a person or an agent: compiler errors, formatters, linters, checks, gates, leases and hooks, placed at points a person chose. Around an agent's loop, magus supplies one and keeps it outside. Harness in full.

Skill

A packaged set of instructions an agent host loads when a task matches its description: a directory holding a SKILL.md. magus ships its magus-* skills in the binary and writes them with magus agent install. Skill in full.

Session

An agent host's conversation, by the id the host delivers to its hooks. magus never mints one: a record with no session is unattributed, and the OS user it carries says whose account ran it. Session in full.

Window

The terminal a command runs in. It keys fire-once notices for a caller no host gave a session, and is never recorded as a session. Window in full.

Run

One target executing under one magus invocation, such as magus run test web or magus affected ci. A run keeps its captured output behind an output reference. Every magus run is a run whether or not any job asked for it; see Job for how the two relate. Run in full.

Pane

A split within a tab. Splitting divides the focused pane along its longer side, so the same action tiles side-by-side on a desktop and stacks on a phone; a tab with no split is a single pane. Drag the divider to re-weight the split. Pane in full.

Conventions

Placeholders

Angle brackets mark a value you replace with your own; never type the brackets:

magus run <target>
magus completion <shell>    # e.g. bash, zsh, fish

<target>, <path>, <shell>, <name> and the like are stand-ins, not literal text.