agent-context
Skill14 starsChanged 45 days agoMITView on GitHub
Create, validate, and maintain a structured .agent-context directory for a repository so AI agents navigate the codebase efficiently and make higher-quality decisions. Use when setting up agent context for a new repo, updating context after agent work, or catching up context after human work.
5 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- amaranthic/skillstheir own version, first seen Oct 20, 2026
- cote-star/agent-contextedited, first seen Oct 15, 2026
- kimgea/agent-kittheir own version, first seen Oct 15, 2026
- dev-ik/ai-design-rulestheir own version, first seen Oct 6, 2026
- InnovationMachineTeam/skillstheir own version, first seen Aug 1, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- cote-star/agent-context★ 278% same
Wrote their own version · 4
- dev-ik/ai-design-rules★ 3same name
- amaranthic/skills★ 1same name
- InnovationMachineTeam/skills★ 1same name
- kimgea/agent-kit★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-chorusSkill
- agent-chorusSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
66 rules. 0 are common, 42 are distinctive, and 24 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
42
Distinctive
This author's own choices. Worth a look.
24
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Create, validate, and maintain a structured .agent-context/ directory for a repository.
- Distinctive: line 32
Not every repo needs the full pack.
- Very specific: line 40
If using the CLI: agent-context init --tier 1|2|3 .
- Distinctive: line 48
After merge, every agent that opens a session in the repo automatically reads the routing block and follows the pack.
- Distinctive: line 58
When humans merge code without using agents, the agent context gradually goes stale.
- Distinctive: line 60
When ready, anyone can ask an agent: "update the agent context"
- Distinctive: line 114
Check whether agent context is warranted:
- Distinctive: line 123
Check for an existing pack:
- Distinctive: line 129
If exists and validated: ask whether to update (use the Update flow) or reinit from scratch.
- Distinctive: line 130
If exists but empty/scaffolded: proceed with filling.
- Distinctive: line 131
If missing: proceed with full init.
- Distinctive: line 135
Prefer the CLI because it copies helper tools, writes routing blocks, and can install the advisory freshness hook:
- Distinctive: line 141
If the CLI is unavailable, create the directory structure manually:
- Distinctive: line 185
Before writing any content, mechanically enumerate the repo's subsystems.
- Distinctive: line 210
Read the repo structure and fill each markdown file.
- Very specific: line 228
routes.json: Verify the default task routes make sense for this repo.
- Very specific: line 236
Every glob pattern must match >=1 real file — verify with ls or git ls-files before finalizing.
- Distinctive: line 256
All markdown files present and non-empty (no unfilled template markers)
- Distinctive: line 257
All structured artifact file references resolve on disk
- Very specific: line 262
Every required_file_families glob pattern matches >=1 real file (run each glob and verify)
- Very specific: line 263
Every contractually_required_files path exists on disk
- Very specific: line 264
No template variables ({name}, {domain}, etc.) remain in any JSON artifact
- Very specific: line 265
Every invariant in 30_BEHAVIORAL_INVARIANTS.md that uses universal language ("every", "all") has been verified against at least one …
- Very specific: line 267
Every verification_shortcuts look_for string actually appears in the referenced file
- Distinctive: line 275
Every source directory with >3 files in the inventory is referenced in at least one pack file
- Very specific: line 276
If any significant directory is absent from all pack files, either add coverage or list it in the "Not covered in detail" section of …
- Very specific: line 279
Run python3 .agent-context/tools/verify_agent_context.py from the repo root and make sure it exits 0 before committing.
- Distinctive: line 285
Run a structured acceptance test against the pack.
- Distinctive: line 297
Verify the answer by grep-searching the actual codebase.
- Distinctive: line 308
No test should send the agent to the wrong subsystem entirely
- Distinctive: line 316
Before adding any new workflow file, inspect the repo's existing automation and adapt the agent-context checks into it.
- Distinctive: line 321
Prefer patching that workflow instead of creating a second competing CI workflow
- Very specific: line 324
If the repo already installs Python/Node/uv/pnpm/etc.
- Distinctive: line 325
Add the agent-context verification step after checkout and dependency/runtime setup
- Distinctive: line 326
Do NOT introduce a different runtime path just for agent-context if the repo already has one
- Distinctive: line 329
Start from the actual top-level source directories in the repo
- Distinctive: line 334
If there is an existing PR workflow: patch it
- Very specific: line 335
If there is no suitable PR workflow: create a dedicated workflow using docs/references/ci-example.yml
- Very specific: line 336
If CI cannot be changed safely in the current task: document the exact follow-up in 40_OPERATIONS_AND_RELEASE.md
- Very specific: line 355
If there is no existing hook, .git/hooks/pre-push is installed and calls .agent-context/tools/pre-push-hook.sh.
- Distinctive: line 356
If a managed agent-context hook already exists, it is updated in place.
- Very specific: line 357
If an unmanaged pre-push hook already exists, it is preserved and a pre-push.agent-context.sample chain block is written.
- Very specific: line 363
Add an agent-context verification check to your PR workflow.
- Distinctive: line 366
verify the machine-checkable subset of pack integrity
- Distinctive: line 368
run on pull requests against your main branch
- Very specific: line 372
If CI enforcement cannot be set up immediately, document it as a follow-up in 40_OPERATIONS_AND_RELEASE.md so the gap is visible.
- Distinctive: line 385
When you are an agent that has just completed work and is preparing a PR:
- Distinctive: line 399
When a human asks you to update the agent context after significant changes were merged without agent involvement:
- Distinctive: line 428
Every markdown file has content (no unfilled template markers)
- Distinctive: line 429
Every JSON artifact has at least some repo-specific entries (no all-empty arrays)
- Very specific: line 430
No template variables ({name}, {domain}) remain in any JSON artifact
- Distinctive: line 431
Every completeness contract glob matches >=1 real file (tier 3)
- Distinctive: line 432
Every invariant with universal language has been verified against counter-examples
- Very specific: line 438
Every significant subsystem from the Step 3 inventory is referenced in at least one pack file, or listed in "Not covered in detail" in …
- Distinctive: line 445
Do not create agent context for repos with <50 files unless the user explicitly asks
- Very specific: line 446
Do not touch actual repo source files — only .agent-context/, CLAUDE.md, AGENTS.md, GEMINI.md, .cursorrules
- Distinctive: line 447
Do not auto-update the agent context on human-opened PRs — you lack the context of why changes were made
- Distinctive: line 448
Do not rewrite the entire pack on updates — patch only affected sections
- Distinctive: line 449
Do not include secrets, credentials, or sensitive configuration in the agent context
- Very specific: line 450
Do not add the agent context to .gitignore — it is meant to be committed and shared
- Very specific: line 451
Do not use template variables ({name}, {domain}) in JSON artifacts — use * glob wildcards
- Distinctive: line 452
Do not assert universal invariants ("every X does Y") without searching for counter-examples first
- Distinctive: line 453
Do not use the same routing block for CLAUDE.md and AGENTS.md — they serve different agent architectures (P5, P11)
- Distinctive: line 454
Do not claim file counts without verifying against git ls-files
- Distinctive: line 455
Do not start writing pack content before completing the subsystem inventory (Step 3) — enumerate first, narrate second
- Very specific: line 456
Do not concentrate CODE_MAP paths in a few subsystems while leaving others uncovered — breadth matters more than depth for large repos
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Context
Create, validate, and maintain a structured .agent-context/ directory for a
repository. This is the single most impactful thing you can do to improve how
AI agents work on a large codebase.
How It Works — The Big Picture
What gets created
A .agent-context/ directory in the repo root with three layers:
- Content (5 markdown files) — architecture, code map with risk ratings, change checklists with explicit file paths, silent failure modes, operations. Readable by humans and all agents.
- Authority (3 JSON files, tier 3) — task routing, completeness contracts ("these files MUST be in your answer"), reporting rules. Used by Claude and similar agents that trust structured guidance.
- Navigation (1 JSON file) — search scopes ("search HERE, not THERE"), verification shortcuts with line ranges. Used by Codex, Cursor, and similar agents that verify everything against code.
Plus 2-3 sentence routing blocks in CLAUDE.md / AGENTS.md / GEMINI.md / .cursorrules (~90 tokens each) that tell agents to read the pack before opening any repo files.
Tiers
Not every repo needs the full pack. Choose a tier based on complexity:
| Tier | Files | Best for |
| Tier 1 (minimal) | 20_CODE_MAP.md + search_scope.json | Quick adoption, 50-100 file repos |
| Tier 2 (standard) | + 00_START_HERE.md, 30_BEHAVIORAL_INVARIANTS.md, manifest.json, acceptance_tests.md | Most repos, 100-500 files |
| Tier 3 (full) | + all 5 markdown + authority layer (routes.json, completeness_contract.json, reporting_rules.json) | Complex repos, 500+ files, multi-agent workflows |
If using the CLI: agent-context init --tier 1|2|3 . --install-hook (default: tier 3).
First time setup
You ask an agent: "set up agent context for this repo"
The agent reads the entire repo, fills the pack files describing the architecture, key paths, change patterns, and search boundaries, copies the helper tools, installs the advisory freshness hook when safe, validates everything, runs acceptance tests with grep verification, and commits. Takes ~15-20 minutes for a large repo.
After merge, every agent that opens a session in the repo automatically reads the routing block and follows the pack. No per-developer setup. No configuration. It just works.
Ongoing — when agents do the work
When an agent finishes work and opens a PR, it automatically includes .agent-context updates as a separate commit. The agent knows what it changed, so it patches only the affected sections — a new CODE_MAP entry, an updated checklist row, shifted line numbers in verification shortcuts.
Reviewers see code changes and context updates as separate commits in the same PR. Easy to review, easy to revert independently.
Ongoing — when humans do the work
When humans merge code without using agents, the agent context gradually goes stale. A pre-push hook warns about this (advisory only, never blocks).
When ready, anyone can ask an agent: "update the agent context"
The agent diffs since the last validation, reads each changed file, and proposes the minimal edit per section. You approve each change — the agent never overwrites context it didn't write. This takes 2-5 minutes.
Ongoing — mixed work
In practice, most teams have a mix:
- Agents handle routine work → context updates automatically in the PR
- Humans handle sensitive/creative work → periodic catchup when context drifts
- Pre-push hook catches the gap → you decide when to update
What the agent touches — and never touches
| Touches | Never touches |
.agent-context/ (pack files + helper tools) | Source code (no modifications without approval) |
CLAUDE.md / AGENTS.md / GEMINI.md / .cursorrules (routing blocks only) | Human-authored PRs (agent stays silent) |
.git/hooks/pre-push (advisory freshness check, when no unmanaged hook blocks safe install) | Secrets or credentials |
When to use it — and when not to
| Repo size | Recommendation |
| <50 files, simple structure | Skip — agents can scan everything efficiently |
| 50-200 files, 2-3 subsystems | Recommended — tier 1 or 2 gives measurable quality and efficiency gains |
| 200+ files, complex architecture | Strongly recommended — tier 3 prevents silent failures, cuts token cost 50-70% |
When to Use
- Create: first time setting up agent context for a repo (>50 files or >3 subsystems)
- Update (agent PR): agent opens a PR — prep
.agent-contextupdates as a separate commit - Update (catchup): significant human work merged — agent diffs and proposes patches
Trigger Phrases
- "set up agent context for this repo"
- "set up agent context"
- "create agent-context for this repo"
- "update the agent context"
- "refresh the agent context"
Prerequisites
- Git repository with at least one commit
- For update triggers: existing
.agent-context/directory with a validated pack
Flow: Create
Step 1 — Assess
Check whether agent context is warranted:
git ls-files | wc -l- >50 files or >3 top-level source directories: proceed.
- <50 files, simple structure: warn the user that agent context may add overhead without benefit. Proceed only if they confirm.
Check for an existing pack:
ls .agent-context/current/ 2>/dev/null- If exists and validated: ask whether to update (use the Update flow) or reinit from scratch.
- If exists but empty/scaffolded: proceed with filling.
- If missing: proceed with full init.
Step 2 — Scaffold
Prefer the CLI because it copies helper tools, writes routing blocks, and can install the advisory freshness hook:
agent-context init --tier 3 --install-hook .If the CLI is unavailable, create the directory structure manually:
mkdir -p .agent-context/current .agent-context/toolsCreate these files:
- Markdown files in
.agent-context/current/— start from the starter templates intemplates/(00_START_HERE.md, 10_SYSTEM_OVERVIEW.md, 20_CODE_MAP.md, 30_BEHAVIORAL_INVARIANTS.md, 40_OPERATIONS_AND_RELEASE.md). For tier 1, only copy20_CODE_MAP.md. Remove allREPLACE:guidance text after filling. - JSON artifacts in
.agent-context/current/— start from the starter templates intemplates/(routes.json, completeness_contract.json, reporting_rules.json, search_scope.json). For tier 1-2, only copysearch_scope.json. The templates include inline_rulesthat define the format contract for each file. Remove_rulesand_EXAMPLEentries after filling. - Manifest in
.agent-context/current/manifest.json— use the template intemplates/manifest.json. Fillrepo,git_revision(fromgit rev-parse HEAD), andgenerated_at(ISO 8601 UTC). - Acceptance tests in
.agent-context/current/acceptance_tests.md— use the template fromtemplates/acceptance_tests.md. Fill during Step 7. - Helper tools in
.agent-context/tools/— copytools/verify_agent_context.py,tools/check_freshness.sh, andtools/pre-push-hook.sh. These are the canonical machine-checkable validator, freshness checker, and advisory local hook used by the reference CI and hook examples. - Routing blocks in
CLAUDE.md,AGENTS.md,GEMINI.md,.cursorrules(~90 tokens each). Use these canonical templates:
CLAUDE.md / GEMINI.md (trust-and-follow agents — read invariants first, then code map):
BEFORE starting any task, read these 3 files in order:
1. .agent-context/current/00_START_HERE.md
2. .agent-context/current/30_BEHAVIORAL_INVARIANTS.md
3. .agent-context/current/20_CODE_MAP.md
Do NOT open repo source files until steps 1-3 are complete.
Then open only files the pack identifies as relevant to your task.AGENTS.md / .cursorrules (search-and-verify agents — load structured artifacts first, then scope search):
1. Read .agent-context/current/routes.json → identify task type
2. Load contracts from .agent-context/current/completeness_contract.json + .agent-context/current/search_scope.json
3. Search ONLY within scoped directories defined in search_scope.json
4. Do not open repo source files before step 3For tier 1-2 packs (no authority layer), use a simplified search-and-verify block:
1. Read .agent-context/current/20_CODE_MAP.md → identify relevant files
2. Load search boundaries from .agent-context/current/search_scope.json
3. Search ONLY within scoped directories defined in search_scope.json
4. Do not open repo source files before step 2These two patterns optimize for different agent architectures (see docs/architecture.md). Do NOT use the same routing for both.
Step 3 — Inventory
Before writing any content, mechanically enumerate the repo's subsystems. This prevents the most common pack failure: deep coverage of a few subsystems while others are silently omitted.
- List all significant source directories — find every directory under the main source root(s) that contains >3 files:
# Adapt the root paths (app/, src/, lib/, etc.) to the repo
find app/ -mindepth 1 -maxdepth 2 -type d -exec sh -c 'echo "$1 $(find "$1" -maxdepth 1 -name "*.py" -o -name "*.ts" -o -name "*.go" | wc -l)"' _ {} \; | awk '$2 > 3'- List all distinct data store and external integration patterns — scan imports for database clients, SDKs, and external service connectors:
grep -rn "import.*sqlalchemy\|import.*pynamodb\|import.*databricks\|import.*elasticsearch\|import.*redis\|import.*boto3\|import.*openai\|import.*mlflow" app/ --include="*.py" -l | head -30- Produce a subsystem inventory — a flat list with one line per subsystem:
| Directory | File count | Data store / integration | Covered in pack? |
| (one row per significant directory) | (fill after Step 4) |
This inventory is your coverage checklist. After filling the pack, every row must appear in at least one pack file (system overview, code map, behavioral invariants, search scope, or completeness contract). If you choose not to cover a subsystem in detail, list it in a "Not covered in detail" section in 00_START_HERE.md so agents know it exists.
Step 4 — Fill content layer (markdown)
Read the repo structure and fill each markdown file. Use the inventory from Step 3 to ensure breadth. Follow this order:
- 00_START_HERE.md: Fill Fast Facts (product, languages, quality gate, core risk, version). Fill Scope Rule. Fill Stop Rules based on repo patterns.
- 10_SYSTEM_OVERVIEW.md: Fill Product Shape, Runtime Architecture (3-5 steps), Silent Failure Modes (any code path where failure produces no error), Command/API Surface table, Tracked Path Density.
- 20_CODE_MAP.md: Identify 8-15 high-impact paths, with at least one path per major subsystem in the inventory. If the repo has >8 subsystems, prioritize breadth over depth — cover each subsystem at least once rather than covering 5 subsystems deeply. For each path: what it does, why it matters, risk level, authority (authoritative/derived/reference). Fill Quick Lookup Shortcuts (4-6 patterns). Fill Cross-Cutting Tracing Flows for changes that ripple through multiple files. Fill Extension Recipe.
- 30_BEHAVIORAL_INVARIANTS.md: Write 3-8 testable invariants. Before asserting any universal rule (words like "every", "all", "must", "always"), search the repo for counter-examples using grep. If counter-examples exist, qualify the invariant (e.g., "Snowflake CRUDs extend BaseCRUD" not "every CRUD extends BaseCRUD"). Fill Update Checklist with one row per common change type — explicit file paths, not descriptions (P7). Identify File Families (glob pattern, member count, report-as-family or enumerate) — verify member counts with
git ls-files | grep ... | wc -l. Write Negative Guidance (what NOT to do — common over-exploration patterns). - 40_OPERATIONS_AND_RELEASE.md: Fill validation commands, CI checks, release flow, agent context maintenance.
Step 5 — Fill authority layer (JSON) — tier 3 only
Skip this step for tier 1-2 packs.
Fill the structured JSON artifacts with repo-specific content:
- routes.json: Verify the default task routes make sense for this repo. Add
named_patternsfor repo-specific lookup and change patterns. completeness_contract.json: For each common change type, fill
contractually_required_fileswith explicit file paths andrequired_file_familieswith glob patterns. These are the files that MUST appear in an impact analysis answer. Include at least one contract entry per subsystem in the inventory that has a distinct change pattern. If a subsystem is too simple for its own contract, fold it into a broader contract and note it in the description.Pattern format rules:
contractually_required_files— exact paths only (e.g.,app/api/v1/endpoints/v1.py)required_file_families— valid shell globs using*wildcards (e.g.,app/api/v1/endpoints/*.py,tests/unit/crud/test_*.py)- Template variables like
{name}or{domain}are NOT valid glob patterns and must NOT be used. They will not resolve against the repo and will silently weaken the contract. - Every glob pattern must match >=1 real file — verify with
lsorgit ls-filesbefore finalizing.
Example of a correctly filled contract entry:
"add_endpoint": { "description": "Adding a new API endpoint", "contractually_required_files": ["src/routes/index.ts"], "required_file_families": ["src/routes/*.ts", "src/handlers/*.ts", "tests/routes/test_*.ts"] }- reporting_rules.json: Fill
groupable_families(homogeneous file sets to report as family, not individually). Fillnever_enumerate_individually(derived/generated files). Fillauthoritative_vs_derived_pathsin global rules. - search_scope.json: For each task family, fill
search_directories(where to look),exclude_from_search(where NOT to look), andverification_shortcuts(specific file + line range or function name for quick checks).
Step 6 — Validate
Validate the pack before committing. Run all of these checks:
Structural checks:
- All markdown files present and non-empty (no unfilled template markers)
- All structured artifact file references resolve on disk
- Grouped families don't point to generated files as authoritative edit targets
.agent-context/tools/verify_agent_context.py,.agent-context/tools/check_freshness.sh, and.agent-context/tools/pre-push-hook.shexist if you copied the helper tools
Semantic checks:
- Every
required_file_familiesglob pattern matches >=1 real file (run each glob and verify) - Every
contractually_required_filespath exists on disk - No template variables (
{name},{domain}, etc.) remain in any JSON artifact - Every invariant in
30_BEHAVIORAL_INVARIANTS.mdthat uses universal language ("every", "all") has been verified against at least one counter-example search - File family member counts (e.g., "~25 files") are within +-20% of actual
git ls-filescount - Every
verification_shortcutslook_forstring actually appears in the referenced file
Routing checks:
CLAUDE.md/GEMINI.mdrouting block reads 00->30->20 (trust-and-follow pattern)AGENTS.md/.cursorrulesrouting block starts withroutes.json(search-and-verify pattern) for tier 3, or20_CODE_MAP.mdfor tier 1-2- The two patterns are NOT identical — they serve different agent architectures
Coverage check (against the Step 3 inventory):
- Every source directory with >3 files in the inventory is referenced in at least one pack file
- If any significant directory is absent from all pack files, either add coverage or list it in the "Not covered in detail" section of
00_START_HERE.md
Preferred machine check:
- Run
python3 .agent-context/tools/verify_agent_context.pyfrom the repo root and make sure it exits 0 before committing. The shipped verifier checks the machine-checkable subset above, including a lightweight coverage heuristic.
Fix any validation errors before proceeding.
Step 7 — Acceptance test
Run a structured acceptance test against the pack. This is not a self-assessment — it requires verifying pack answers against actual code using grep. The test catches gaps that structural validation cannot: missing subsystems, understated blast radius, and cross-cutting blind spots.
Generate 4 test questions that span these categories:
- Lookup — find a specific config value, function location, or integration point. Pick something from a subsystem the pack covers lightly, not one of the top code map entries.
- Impact analysis — list all files that must change for a common modification. Pick a change type that touches >=2 subsystems.
- Cross-cutting impact — map the blast radius of a change that spans 3+ subsystems. Good candidates: auth/identity changes, config/env variable changes, shared utility changes, data store migrations. This is the most important test — it catches the deep-but-narrow failure mode.
- Diagnosis — trace a runtime failure to its root cause. Pick a failure that involves an external integration (database, API, cache, file storage).
For each question, follow this protocol:
- Answer using ONLY the agent context files (no source code).
- Verify the answer by grep-searching the actual codebase.
- Score:
- Files identified by pack vs files found by grep (the coverage ratio)
- False positives — files the pack pointed to that turned out irrelevant
- False negatives — files grep found that the pack missed entirely
Pass criteria:
- Lookup and diagnosis: pack must point to the correct starting files
- Impact analysis: pack must surface >=80% of files in the real change set
- Cross-cutting: pack must surface >=80% of core infrastructure files in the blast radius. Downstream files found via grep guidance (e.g., "grep for X across Y/") count as surfaced.
- No test should send the agent to the wrong subsystem entirely
If any test fails, improve the relevant pack section (add missing paths to code map, add a contract, add a search scope family, add an invariant) and re-run that test. Iterate until all 4 tests pass.
Record the test results in .agent-context/current/acceptance_tests.md using the template from templates/acceptance_tests.md. This file is committed with the pack so reviewers can see what was tested and how the pack scored.
Step 8 — Adapt to existing repo automation
Before adding any new workflow file, inspect the repo's existing automation and adapt the agent-context checks into it.
- Inspect existing workflows first:
- List
.github/workflows/*.yml - Identify which workflow already gates pull requests against the default branch
- Prefer patching that workflow instead of creating a second competing CI workflow
- List
- Reuse the repo's runtime setup:
- If the repo already installs Python/Node/uv/pnpm/etc. in CI, reuse that setup
- Add the agent-context verification step after checkout and dependency/runtime setup
- Do NOT introduce a different runtime path just for agent-context if the repo already has one
- Infer
CONTEXT_RELEVANT_PATHSfrom the repo's real source roots:- Start from the actual top-level source directories in the repo
- Include directories the pack explicitly claims to cover in
00_START_HERE.md - Exclude generated artifacts and vendored dependency directories
- Choose integration strategy:
- If there is an existing PR workflow: patch it
- If there is no suitable PR workflow: create a dedicated workflow using
docs/references/ci-example.yml - If CI cannot be changed safely in the current task: document the exact follow-up in
40_OPERATIONS_AND_RELEASE.md
- Record the adaptation:
- In
40_OPERATIONS_AND_RELEASE.md, state which workflow file was patched (or created) - Record the chosen
CONTEXT_RELEVANT_PATHS
- In
See docs/ci-adaptation.md for repo-adaptation heuristics and examples.
Step 9 — Set up CI enforcement
Set up both local advisory freshness and CI verification before treating the pack as production-ready.
Local advisory hook:
agent-context install-hook .Expected outcomes:
- If there is no existing hook,
.git/hooks/pre-pushis installed and calls.agent-context/tools/pre-push-hook.sh. - If a managed agent-context hook already exists, it is updated in place.
- If an unmanaged pre-push hook already exists, it is preserved and a
pre-push.agent-context.samplechain block is written. Document the follow-up in40_OPERATIONS_AND_RELEASE.mdor manually merge the block into the repo's hook chain.
The hook is advisory only: it warns when context-relevant paths changed without .agent-context/ changes, but never blocks a push.
CI enforcement:
Add an agent-context verification check to your PR workflow. This is not required for the initial pack commit, but should be set up before the pack is treated as production-ready.
The CI check should:
- verify the machine-checkable subset of pack integrity
- fail when context-relevant code changes without a corresponding pack update
- run on pull requests against your main branch
A reference CI job is provided in docs/references/ci-example.yml. The advisory pre-push hook is provided in tools/pre-push-hook.sh and copied into .agent-context/tools/ by init.
If CI enforcement cannot be set up immediately, document it as a follow-up in 40_OPERATIONS_AND_RELEASE.md so the gap is visible.
Step 10 — Commit
git add .agent-context/ CLAUDE.md AGENTS.md GEMINI.md .cursorrules
git commit -m "feat: add agent context (.agent-context)"Flow: Update (Agent PR)
When you are an agent that has just completed work and is preparing a PR:
- Determine what changed — review your own work: which files did you create, modify, or delete?
- Map changes to agent context sections — is it in CODE_MAP? Does it affect a checklist row in BEHAVIORAL_INVARIANTS? Does it shift line numbers in search_scope.json verification shortcuts? Is it a new file that should be added to a completeness contract?
- Patch only affected sections — do not rewrite entire files
- Re-validate — check all file references still resolve, contracts match real files
- Commit separately:
git commit -m "chore: update agent context for <change>"
The context update must be a separate commit from the code changes. This lets reviewers assess them independently and revert the context update without reverting the code.
Flow: Update (Manual Catchup)
When a human asks you to update the agent context after significant changes were merged without agent involvement:
- Find what changed since last validation:
# Find when the pack was last validated
LAST_VALIDATED=$(jq -r '.generated_at' .agent-context/current/manifest.json)
# Show what changed since then
git log --oneline --since="$LAST_VALIDATED" -- . ':!.agent-context'
git diff $(git log -1 --before="$LAST_VALIDATED" --format=%H)..HEAD --stat -- . ':!.agent-context'- Propose patches — for each changed area, state what changed in the code, which agent context section is affected, and show the specific before/after edit. Ask the user to approve or reject each section.
- Wait for approval — do NOT apply changes without approval. The user authored this code — you may misunderstand the intent.
- Apply approved patches and re-validate — check all references still resolve after changes.
git add .agent-context/
git commit -m "chore: catchup agent context with recent changes"Quality Bar
Agent context is ready when:
- Validation passes — all structural, semantic, routing, and coverage checks from Step 6 pass
- Every markdown file has content (no unfilled template markers)
- Every JSON artifact has at least some repo-specific entries (no all-empty arrays)
- No template variables (
{name},{domain}) remain in any JSON artifact - Every completeness contract glob matches >=1 real file (tier 3)
- Every invariant with universal language has been verified against counter-examples
- Acceptance test passes: 4 tests (lookup, impact, cross-cutting, diagnosis) all meet pass criteria, results committed in
acceptance_tests.md - CLAUDE.md / GEMINI.md say "BEFORE starting any task, read these 3 files" and route 00->30->20 — not suggestive "follow the read order" (P16: agents interpret suggestive wording as optional)
- AGENTS.md /
.cursorrulesroute search-and-verify agents through structured artifacts (different from CLAUDE.md — P5, P11, P12) - 00_START_HERE.md says "MANDATORY before starting work" and "Do NOT open repo source files until steps 1-3"
- Routing blocks are under 100 tokens each (~90 tokens measured)
- Every significant subsystem from the Step 3 inventory is referenced in at least one pack file, or listed in "Not covered in detail" in
00_START_HERE.md - CODE_MAP has at least one path per major subsystem in the inventory
- CI enforcement is either set up or documented as a follow-up in
40_OPERATIONS_AND_RELEASE.md - The advisory pre-push hook is installed, updated, or explicitly documented as a follow-up when an existing unmanaged hook prevents safe automatic installation
What NOT to Do
- Do not create agent context for repos with <50 files unless the user explicitly asks
- Do not touch actual repo source files — only
.agent-context/,CLAUDE.md,AGENTS.md,GEMINI.md,.cursorrules - Do not auto-update the agent context on human-opened PRs — you lack the context of why changes were made
- Do not rewrite the entire pack on updates — patch only affected sections
- Do not include secrets, credentials, or sensitive configuration in the agent context
- Do not add the agent context to
.gitignore— it is meant to be committed and shared - Do not use template variables (
{name},{domain}) in JSON artifacts — use*glob wildcards - Do not assert universal invariants ("every X does Y") without searching for counter-examples first
- Do not use the same routing block for CLAUDE.md and AGENTS.md — they serve different agent architectures (P5, P11)
- Do not claim file counts without verifying against
git ls-files - Do not start writing pack content before completing the subsystem inventory (Step 3) — enumerate first, narrate second
- Do not concentrate CODE_MAP paths in a few subsystems while leaving others uncovered — breadth matters more than depth for large repos
Evidence
Tested across 3 repo types (ML pipeline, CLI library, React frontend), 7 experiment runs, 78+ graded results:
- Answer quality: 50% -> 88% correct
- Claude efficiency: -70% files opened, -65% tokens, zero dead ends
- Risk elimination: 0 production-risk answers with agent context (was 7 without)
- Templates are general-purpose — zero modifications needed across repo types
- Real-world feedback led to P16: routing wording must be imperative, not suggestive
Full evidence: docs/evidence/
Design principles: docs/design-principles.md
Architecture: docs/architecture.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

