The Efficiency & Orchestration Contract Format
A MARCHESE.md file is a Markdown document with YAML frontmatter that declares
context budgets, input compression rules, Minimum Viable Model (MVM) mappings,
script bindings, gotchas, 4-block orchestration loops, session reminders, and
human validation zones.
Canonical machine schema: packages/core/schema.json (mirrored at spec/schema.json
and sdks/python/src/marchese_md/schema.json).
Compute Used = Tokens Consumed × Model Cost
Every Marchese control optimizes tokens, model tier, or both.
---
marchese_version: "1.0" # required, enum: "1.0"
name: my-agent-system # required, ^[a-z0-9][a-z0-9-_]*$
efficiency:
context_limit_tokens: 150000
compact_threshold_percent: 60 # 10..90
output_mode: concise # concise | caveman | standard
rtk_compression: true
effort_level: medium # low | medium | high
claude_md_max_lines: 200
models:
default_mvm: claude-haiku-4-5
frontier_model: claude-sonnet-4-5
task_routes:
- task: parsing
model: claude-haiku-4-5
- task: architecture
model: claude-sonnet-4-5
fork_context: true
skills_config:
ask_user_formatting: true
scripts_dir: ./scripts
init_templates: [nextjs]
gotchas:
- id: GOTCHA-001
title: ...
issue: ...
resolution: ...
skill: optional-skill-id
tags: [optional]
orchestration:
loops:
- name: feature-loop
trigger: manual
execution_skill: feature-builder
verification_gate: npm test
history_log: .history.jsonl
training_mode: true
max_iterations: 3
session_reminders:
- day: friday # monday..sunday | daily
message: Run marchese audit
skill: optional
human_validation_zones:
- name: production-deploy
reason: High cost of error
require_approval: true
knowledge:
enabled: true
root_dir: ./knowledge
raw_dir: ./knowledge/raw # ingested source material
wiki_dir: ./knowledge/wiki # curated TOC + pages
sources: [repo, claude-md, marchese, history, gotchas, manual]
improvement:
enabled: true
loop_name: improve-system
change_log: ./knowledge/change-log.md
outputs_dir: ./knowledge/outputs
protected_paths: [CLAUDE.md, knowledge/wiki, .claude/skills]
auto_approve: [broken-wiki-link, missing-toc-entry, empty-raw-stub]
sign_off_required:
[new-skill-candidate, skill-edit, wiki-structural-rewrite, contradiction, bloat-removal]
---CLAUDE.mdshould stay underclaude_md_max_lines(default 200).- At
compact_threshold_percent(default 60), agents should/compactor/clear. - RTK compression strips redundant whitespace/log noise from tool payloads.
Resolve order: exact task_routes → partial match → heuristic (lint/parse/test → MVM;
architecture/security/plan → frontier) → default_mvm.
Append-only edge-case memory. Unique id values required. Inject matching gotchas
into skill context when symptoms reappear.
trigger → execution_skill → verification_gate → history_log
Training mode (default) records history without executing the shell gate.
Pass --run-gate / runGate: true for live verification. History is append-only JSONL.
Human frames the goal, agent executes the middle ~95%, human validates zones listed
in human_validation_zones before high-risk mutations.
The knowledge block declares a self-seeded knowledge base (raw/ ingested material,
wiki/ curated TOC) populated by marchese knowledge init && marchese knowledge ingest
from the repo itself — no external data dump required. The improvement block declares
the LOOP: marchese improve applies checked review items from the previous run, scans
knowledge + repo, and buckets every proposal:
- AUTO-APPROVE (kinds in
auto_approve): applied directly, appended tochange_log. Mechanically-resolvable stubs carry an autoFix (e.g. an emptyraw/file is deleted so it stops re-reporting). - NEEDS SIGN-OFF (kinds in
sign_off_required): written tooutputs_dir/review-*.mdas checkboxes; applied only on the next run after the human checks them. If the proposal carries a stored autoFix, checking the box applies that edit (not just logs approval). Applied review files are retired to*.applied.md.protected_pathsare never auto-modified for sign-off items. - MORE CONTEXT: written to
outputs_dir/needs-context-*.mdas questions.
Both auto_approve and sign_off_required accept any improvement kind, so a kind such as
missing-toc-entry can be gated behind sign-off instead of applied automatically. Proposal
ids are content-derived and stable across runs, so two coexisting review files never collide.
| Surface | Commands / tools |
|---|---|
CLI marchese |
validate, audit, init, optimize, gotcha, loop, status, rtk, route, knowledge, improve, image, models |
| MCP | marchese_audit_context, marchese_validate_spec, marchese_mvm_route, marchese_run_loop, marchese_log_gotcha, marchese_write_history, marchese_ask_user, marchese_interview_user, marchese_codex_route, marchese_rtk_status, marchese_improve_system, marchese_knowledge |
Python marchese_md |
parse, parse_marchese_spec, validate |
npm run test:fixturesFixtures live in spec/fixtures/valid and spec/fixtures/invalid.