A self-orchestrating three-tier memory and verification meta-harness for AI coding agents: an always-loaded constitution (CONSTITUTION.md mirrored to AGENTS.md and CLAUDE.md), registry-driven specialist routing and command hooks (.harness/ and .agents/skills/), on-demand cold memory over two MCP servers (.context/ and code-review-graph), and a static + Pareto evaluation loop (.autoresearch/).
Built for repositories where long-context drift, cross-client divergence, or recurring agent mistakes cost real engineering time. If you only need a single prompt file for a small script, this template is intentionally heavier than you need.
flowchart LR
P["User Prompt / Tool Call / Stop"] --> A["Client Hook Adapter or Skill Catalog"]
A --> R["decision-gates.json + routing.py"]
R -->|"Tier 2 injection"| S[".harness/specialists/ & .agents/skills/"]
R -->|"Tier 0/1 policy"| G["Secret-Path Block & Premature-Stop Guard"]
P --> C["Tier 1 Hot Memory: CONSTITUTION.md = AGENTS.md = CLAUDE.md"]
S -->|"Tier 3 on-demand pull"| M1["MCP: codified-context-tier3 (.context/)"]
S -->|"Structural impact"| M2["MCP: code-review-graph"]
E[".autoresearch/prepare_and_eval.py"] -.->|"Static invariants & Pareto evals"| C
E -.-> R
- Tier 1 — Hot memory (
CONSTITUTION.md=AGENTS.md=CLAUDE.md): Global engineering invariants, fact-placement rules, and the Trigger Table. Static validation enforces byte-identical parity across all three entry points and caps length at 650 lines. - Tier 2 — Specialists & decision gates (
.harness/,.agents/skills/):decision-gates.jsonregisters every specialist once. Hook-capable clients evaluate conditions outside the main context window and inject only matching specialists; skill-discovering clients load the matching.agents/skills/<id>/SKILL.md. - Tier 3 — Cold memory over MCP (
.context/+code-review-graph): Subsystem contracts, architecture views,DesignLoretrade-offs, andsymptom-cause-fix.mdstay out of the base prompt and are retrieved sliced on demand. - Outer loop (
.autoresearch/):prepare_and_eval.pyenforces static harness invariants (--check-only) and optionally runs headless behavioral tasks with Pareto frontier tracking.
Running the offline UserPromptSubmit hook directly from the repository root shows how Tier 2 routing and Tier 3 pointers combine without any external API key:
echo '{"prompt":"Prevent this recurring mistake in .harness/gates/antigravity_gate.py"}' | uv run python .harness/gates/run_gate.py --hook UserPromptSubmit[System-1 Conditional Router] Relevant skills detected for this prompt:
- Load `.harness/specialists/correct.md` (Routing score: 1.00)
- Past pitfall in `.context/symptom-cause-fix.md` (`DEV-HARNESS` (`.agents/hooks.json`, `.harness/gates/antigravity_gate.py`)): Antigravity on Windows fails every hook with `SyntaxError: unterminated string literal` from the `python -c` bootstrap, blocking all tool use before any tool r…
- Tier-3 pull: call `get_context_for_change` on the Tier-3 MCP server for full sliced invariants.
Unmatched prompts (such as "Is this logic correct?") inject nothing (tests/test_decision_routing.py).
Requires Python 3.13+ and uv on PATH. No API keys or extra CLIs are required to run static checks and regression tests.
uv sync --locked
uv run python .autoresearch/prepare_and_eval.py --check-only
uv run python -m unittest discover -s tests -vFor Linux or a remote Linux workspace, run Quickstart from the checkout on the execution host. Check that uv is on the path inherited by the agent, hooks, and MCP processes. See Linux shell execution for shell, path, and filesystem diagnostics.
pyproject.toml sets package = false so .venv serves only the harness tooling and tests; standalone MCP scripts declare inline PEP 723 dependencies resolved separately by uv.
Choose a starting footprint:
| Starting point | What you get | Best for |
|---|---|---|
Repository root or .template/all/ |
Full 3-tier harness, all client hooks, .agents/skills/, .dsh/, .zcode/, .autoresearch/ |
Projects using multiple coding agents (Claude, Codex, Copilot, Antigravity, DSH, ZCode) |
.template/less/ |
Full 3-tier harness and hook adapters without .agents/skills/, .dsh/, or .zcode/ |
Teams using hook-based clients only |
.template/normal/ |
AGENTS.md / CLAUDE.md + .agents/skills/ only (no .harness/, .context/, or hooks) |
Lightweight skill-only adoption |
Then initialize your project's memory:
- Copy the chosen files into a new repository with its own Git history.
- Update
nameanddescriptioninpyproject.toml, then runuv lock. - Fill
.context/plan.mdwith your objective, frontier, and next slice. - Fill
.context/architecture.l1-l3.mdand author subsystem contracts using.harness/templates/00-subsystem-template.md. - Keep
CONSTITUTION.md,AGENTS.md, andCLAUDE.mdbyte-identical, and runuv run python .autoresearch/prepare_and_eval.py --check-onlyto verify.
| Client | Tier 1 Instructions | Tier 2 Routing | Native Hooks (Prompt / Tool / Stop) | Tier 3 MCP | Config file |
|---|---|---|---|---|---|
| Claude Code | CLAUDE.md |
Hook injection (run_gate.py) |
UserPromptSubmit, PreToolUse, Stop |
Both servers | .claude/settings.json, .mcp.json |
| Codex | AGENTS.md |
Hook injection (run_gate.py) |
UserPromptSubmit, PreToolUse, Stop |
Both servers | .codex/hooks.json, .codex/config.toml |
| GitHub Copilot (CLI & VS Code) | AGENTS.md / CLAUDE.md |
Hook injection (copilot_gate.py) |
userPromptTransformed, preToolUse, agentStop |
Both servers | .github/hooks/decision-gates.json, .mcp.json |
Google Antigravity (App, IDE, agy) |
AGENTS.md |
Hook injection (antigravity_gate.py) + .agents/skills/ |
PreInvocation, PreToolUse, Stop |
Both servers (harness- prefixed) |
.agents/hooks.json, .agents/mcp_config.json |
| DeepSeek Harness (DSH) | AGENTS.md |
Native .agents/skills/ catalog |
None (advisory + DSH permissions) | Config bundle or Settings > MCP | .dsh/bundles/tier3-context/ |
| ZCode | AGENTS.md |
Native .agents/skills/ catalog |
None (advisory + ZCode permissions) | Both servers (mcp.servers) |
.zcode/config.json |
See Client Setup & Hook Operations for per-client installation, classifier provider configuration (OPENAI_API_KEY, TYPESAFE_API_KEY / JEV_API_KEY), Windows agy.exe launch notes, and hook contracts.
All routing conditions live in .harness/gates/decision-gates.json and share one registry (.harness/gates/routing.py) across prompt hooks, MCP suggest_agent, static file checks, and .agents/skills/<id>/SKILL.md parity.
| ID | Role | Entry point |
|---|---|---|
system-architect-atam |
ISO 42010 viewpoints, deep modules/seams, ATAM trade-offs | .harness/specialists/system-architect-atam.md |
cmcts-solver |
Complex feature, state-machine, and concurrency implementation (fallback) | .harness/specialists/cmcts-solver.md |
grounded-prm-debugger |
Executable-oracle debugging, SZZ blame triage, revert-flip proof | .harness/specialists/grounded-prm-debugger.md |
review-tribunal |
Multi-specialist PR/diff audit with falsification checks | .harness/review-tribunal/00-orchestrator.md |
ast-grep |
Syntax-aware structural search, codemods, and executable lint rules | .harness/tools/ast-grep.md |
| Pack | Purpose | Supporting resources |
|---|---|---|
tdd |
Vertical-slice red-green TDD and boundary-only mocking | test patterns, mocking rules |
wayfinder |
Multi-session decision maps and single-session decision tickets | .context/plan.md |
correct |
Two-incident recurring mistake audits and structural/ast-grep guardrails |
.context/symptom-cause-fix.md, ast-grep guide |
create-verification-skill |
Project-local verify-<app> end-to-end UI/CLI/API journey skills |
tooling contract |
create-formal-verification-skill |
Formal invariant / model-checking skills with reachability witness & drift checks | architecture spec |
codebase-map |
Source-linked request-path and change-impact maps | mapping approaches |
verified-docs |
Human-facing docs with mechanically verified claims | authoring checklist |
concept-article |
Offline scrolling HTML technical articles and interactive explainers | authoring reference, starter HTML, geometry checker |
diagram-design |
Orthogonal HTML/inline SVG software diagrams | visual rules, geometry checker |
typescript-browser-apps |
Browser storage (IndexedDB/OPFS), Workers, lifetimes, and PWA delivery | browser runtime, PWA delivery, eval guide |
typescript-source-inspection |
Verifying node_modules/, .d.ts declarations, and Node flags from source |
package inspection |
rust-source-inspection |
Verifying resolved crates, Cargo features, traits, and SDK callbacks | crate inspection |
Adding or removing a pack requires no Python changes: add/remove its condition in .harness/gates/decision-gates.json along with its specialist file, optional .context/references/<domain>/ manuals, and matching .agents/skills/<id>/SKILL.md. See domain pack registration.
Registered in .mcp.json (and mirrored to .codex/config.toml, .agents/mcp_config.json, and .zcode/config.json), launched via uv run .context/mcp_context_server.py (inline mcp>=1.0.0,<2). Exposes five read-only tools:
get_context_for_change(file_paths, query)— one-call composite bundle of glob-matched subsystem specs, rankedsymptom-cause-fix.mdrows,DesignLore, and specialist routinglist_subsystems()— lists.context/subsystems/*.mdand@METAheadersfind_relevant_context(query)— section- and row-sliced search across subsystems, architecture, symptoms, and registered referencessuggest_agent(task_or_file_path)— single highest-priority specialist recommendationquery_design_lore(subsystem_or_concern)— tokenized lookup in.context/design-lore-taxonomy.json
Registered in .mcp.json pinned to code-review-graph==2.3.9 via uvx, scoped to seven graph tools (build_or_update_graph_tool, get_minimal_context_tool, get_impact_radius_tool, query_graph_tool, detect_changes_tool, list_graph_stats_tool, get_docs_section_tool). Build and refresh the ignored local .code-review-graph/ index from the repository root:
uvx --from code-review-graph==2.3.9 code-review-graph build --repo .
uvx --from code-review-graph==2.3.9 code-review-graph status --repo .
uvx --from code-review-graph==2.3.9 code-review-graph update --repo .Install RTK (token-saving CLI proxy referenced in CONSTITUTION.md) and ast-grep (structural search and lint rules) on PATH:
rtk --version
rtk proxy ast-grep --version
rtk proxy ast-grep run --lang python --pattern 'subprocess.run($$$ARGS)' .autoresearch- Static invariants (
--check-only, read-only):uv run python .autoresearch/prepare_and_eval.py --check-onlyverifies required files, byte-identicalCONSTITUTION.md/AGENTS.md/CLAUDE.md, gate injection and context paths,.agents/skills/frontmatter and relative links,.dsh/bundles/manifests, and fails closed if any credential pattern appears under.context/(tests/test_template_validation.py). - Regression suite:
uv run python -m unittest discover -s tests -vcovers routing, offline/mocked classifier protocols, client hook adapters, MCP config parity, secret scanning, skill validation, geometry checking, and README/docs/link and anchor integrity. - Opt-in behavioral evals: Omit
--check-onlyonce you supply.autoresearch/tasks.json(see.autoresearch/tasks.example.jsonand the browser evaluation guide) to run isolated headless evaluations, archive uncompressed traces in ignored.autoresearch/traces/, and update.autoresearch/pareto_frontier.json.