Kun Chen’s useful metaphor for maintaining project-level AGENTS.md and CLAUDE.md files: treat the file as a small set of behavioral weights, treat each agent session as a forward pass, and use transcripts to perform a human-approved backward pass. The point is not that Markdown literally becomes a neural network. The point is to replace anecdotal prompt editing with an evidence-based training loop.
Key
The project instruction file should be trained on observed sessions, not expanded whenever someone remembers being annoyed.
A rule earns its place when transcripts show a recurring failure or a broad invariant. It gets rewritten, extracted, or deleted when the evidence says it is stale, redundant, too narrow, or not working.
Two files, opposite ownership
The article makes an important distinction that is easy to lose when everything is called “memory”:
| File | Job | Editing policy |
|---|---|---|
| User-level instructions | Personal preferences and opinions that apply across projects | Handwritten, stable, and owned by the user. Agents should not optimize this file. |
| Project-level instructions | Repository conventions, commands, boundaries, and workflow constraints | A maintained behavioral configuration, refined from the project’s session history. |
The distinction maps cleanly onto this setup. The global ~/.pi/agent/AGENTS.md carries Quang’s smart-colleague preferences. This vault’s CLAUDE.md carries WikiLLM’s schema and operating rules. The former should change only when Quang changes his mind. The latter can be improved when repeated sessions reveal friction, ambiguity, or missing guidance.
This also prevents a common category error: durable user preference, project operating constraint, and factual knowledge are different things. A fact belongs in a wiki page. A procedure belongs in a skill or README when it is conditional. Only an invariant that should shape nearly every turn belongs in the always-loaded project file. See Agent Harness’s always-attached set.
The forward pass and backward pass
The mapping is intentionally concrete:
| Training concept | Agent-harness equivalent |
|---|---|
| Weights | The project’s AGENTS.md or CLAUDE.md |
| Model-size budget | Maximum tokens for the always-loaded file |
| Forward pass | A session that reads the file and performs work without modifying it |
| Loss | The gap between the agent’s behavior and the desired behavior |
| Training data | Session transcripts, including tool calls, corrections, rediscovery, and violations |
| Backward pass | Inspecting transcripts, attributing failures to individual instructions, and proposing bounded edits |
| Learning rate | Maximum number of edits per update |
| Batch size | Minimum number of independent sessions supporting a new rule |
| Human optimizer | The person who accepts or rejects each proposed change |
The loss signal is wider than “the agent made a mistake.” It includes at least four cases:
- The agent ignored a rule that was present.
- The agent did something wrong because no rule covered it.
- The agent followed a rule that had become stale or was itself wrong.
- The agent spent time rediscovering a convention that should have been legible.
A good update therefore has both positive and negative evidence. Which instructions helped? Which were violated? Which rules were irrelevant to most sessions? What recurring failure has no corresponding rule?
The disciplined update loop
The article’s manual method can be turned into a repeatable maintenance routine:
- Collect transcripts. Tie sessions to the project by working directory or repository identity.
- Distill the signal. Keep the user request, agent response, meaningful tool-call shape, corrections, and relevant quotes. Discard tool-call noise that cannot explain the outcome.
- Score addressable units. Treat each paragraph or list item in the instruction file as a unit. Count where it was useful, followed, violated, or contradicted.
- Batch evidence. Do not promote a new rule because of one noisy incident. Require repeated evidence, especially for rules that add permanent context cost.
- Propose a small step. Add, remove, rewrite, or extract only a few units. The article suggests a maximum of five edits per pass.
- Enforce gates mechanically. Require evidence quotes, a minimum number of sessions for new rules, and a post-edit token budget check.
- Review before writing. The human accepts or rejects each diff. Rejections should be remembered so a rejected suggestion does not return unchanged without new evidence.
- Run the next sessions. The edited file is now the next forward-pass configuration. Its effect must be observed rather than assumed.
This is Harness Engineering’s Ratchet with the missing measurement discipline made explicit. The Ratchet says failures should change the system. This method adds constraints on which failures count, how much evidence is enough, and how large the change may be.
Budget and progressive disclosure
The always-loaded file is a recurring inference cost. Every token is sent into the model’s context repeatedly, including on turns where the rule is irrelevant. A size budget makes that tradeoff visible instead of allowing the file to grow by accretion.
When the file approaches its budget, an addition must be paid for by one of three moves:
- Remove a rule that no longer earns its cost.
- Rewrite several rules into one clearer invariant.
- Extract a narrow, triggerable procedure into a skill, README, or other on-demand artifact.
The extraction rule matters. Broad instructions and safety-critical constraints belong in the always-loaded file. Narrow instructions with a reliable trigger belong in skills. Narrow instructions with no reliable trigger are candidates for deletion because they consume context without a dependable retrieval path.
This is the same three-tier architecture already visible in the vault:
CLAUDE.mdanswers who the agent is and what always applies.- Skills and READMEs answer how to do a task when that task appears.
- Wiki pages hold the knowledge the agent reads when relevant.
See Context Engineering and Agent Legibility for the broader context-cost and progressive-disclosure principles.
Backpass as an implementation
Kun Chen built backpass to automate this loop. The article describes a pipeline that:
- Reads local transcript stores from common agent harnesses and associates sessions with a repository.
- Reduces transcripts before model processing, retaining the parts that carry a loss signal.
- Uses model calls to produce evidence against addressable instruction units, while requiring verbatim quotes.
- Aggregates counts and clusters repeated gaps deterministically, dropping gaps seen in fewer than two sessions.
- Uses one high-reasoning call to propose edits, with mechanical gates for edit count, evidence, and token budget.
- Presents diffs for human approval, and writes nothing when a gate fails or the proposal is rejected.
The tool’s flags express the training analogy directly: --budget is model size, --max-edits is learning rate, --min-gap-evidence is batch size, and --since is the training window. These implementation details are reported by the author and were not independently audited here. The durable idea does not depend on using backpass: a small script plus a weekly transcript review can implement the same discipline.
Why the metaphor is useful, and where it breaks
The metaphor is useful because it puts four neglected engineering constraints in one picture:
- Configuration has an inference cost. The project file is not free documentation when it is injected every turn.
- Anecdotes are noisy. One failure is not enough evidence for a permanent rule.
- Small updates preserve working behavior. A large rewrite destroys the ability to tell which change helped.
- Human approval protects intent. The agent can identify patterns and draft edits, but the user decides which behavior the project should institutionalize.
It should not be read literally. An instruction file is not a differentiable parameter tensor. Rules interact nonlinearly, model behavior changes with the task and model version, and transcript frequency is not causal attribution. A rule may be valuable precisely because it prevents a rare, high-impact failure. Conversely, a frequently violated rule may be badly phrased rather than missing. The training loop is therefore an evidence discipline and governance mechanism, not a promise of automatic optimization.
The ratchet can tighten in the wrong direction
If every observed failure becomes a rule without pruning, batching, or a budget, the system learns the noise in its transcripts. It becomes bloated, contradictory, and harder to follow. The backward pass must include deletion, extraction, and rejection, not just accumulation.
Application to this vault
The method suggests a practical maintenance cadence for WikiLLM and for Pi configuration:
- Keep user preferences in the global
AGENTS.md, and do not let a project-level review silently rewrite them. - Treat
CLAUDE.mdas a bounded schema and invariant layer, not as a place to store every ingest procedure or every wiki fact. - Use session transcripts to find repeated misses in frontmatter, wikilinks, immutable-source handling, index updates, or log maintenance.
- Promote a rule only after it appears across multiple relevant operations, unless the failure is safety-critical.
- Extract conditional operations into skills, such as the ingest workflow, rather than expanding the always-loaded schema.
- Review proposed changes as diffs with the evidence attached. Do not let an agent rewrite the schema file in one cleanup pass.
This is especially relevant to the vault’s own maintenance problem. CLAUDE.md is the harness contract. index.md and MOCs are navigation. Wiki pages are knowledge. Sources/ is immutable evidence. A transcript-trained instruction file should make those boundaries easier to follow without turning the schema into a 900-line autobiography.
Related Concepts
- Harness Engineering — the wider discipline of designing and tightening the agent runtime
- The Ratchet - Every Mistake Becomes a Rule — the principle that historical failures should improve the system
- Context Engineering — why always-loaded instructions consume a finite attention budget
- Agent Harness — how the harness injects project instructions on every turn
- AGENTS.md Six Core Areas — what belongs in an instruction file and how to keep it actionable
- Agent-Friendly Codebase — the related transcript-driven loop for reducing repository friction
- Evaluation-First Prompting — define success before the agent acts, so loss is observable
- Agentic Code Review — Kun Chen’s plan-first variant: move human judgment before code generation and use automation for line-by-line checking
- Agent Memory — why project instructions are configuration, not the same thing as long-term knowledge
Source
- Your AGENTS.md is a Neural Net — Kun Chen, Your AGENTS.md is a Neural Net (2026-08-23)