metagit-cli
AGENTS.md4 starsChanged 11 days agoMITView on GitHub
Compact guide for agents told to install and use Metagit across Git repositories. Prefer these commands over reading full repo trees. Day-1 control loop: start with agents-quickstart.md (install → context pack → aos next → work → complete). PyPI package: metagit-cli (not metagit). Optional — install bundled playbooks into your agent host: Run from the umbrella repo that contains .metagit.yml (workspace manifest): Escalate tiers only when needed. Use --project / --repo to narrow tier 1/2. Before escalating packs, check workspace…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository62 other files it gives its agents.
- agentsAGENTS.md
- agentsAGENTS.md
- agentsCopilot instructions
- .cursor/rules/github-cli.mdcCursor rule
- .cursor/rules/project-level.mdcCursor rule
- llms.txtllms.txt
- gitnexus-cliSkill
- gitnexus-debuggingSkill
- gitnexus-exploringSkill
- gitnexus-guideSkill
- gitnexus-impact-analysisSkill
- gitnexus-refactoringSkill
- humanizerSkill
- metagit-agent-accessSkill
- metagit-agent-coordinationSkill
- metagit-aosSkill
- metagit-bootstrapSkill
- metagit-campaignSkill
- metagit-cliSkill
- metagit-config-refreshSkill
- metagit-context-packSkill
- metagit-control-centerSkill
- metagit-gatingSkill
- metagit-gitnexusSkill
- metagit-graph-maintainSkill
- metagit-mcp-resourcesSkill
- metagit-multi-repoSkill
- metagit-projectsSkill
- metagit-release-auditSkill
- metagit-repo-impactSkill
- metagit-rewrite-campaignSkill
- metagit-sharing-stateSkill
- metagit-stampSkill
- metagit-upstream-scanSkill
- metagit-upstream-triageSkill
- metagit-workspace-scopeSkill
- metagit-workspace-syncSkill
- metagit-agent-accessSkill
- metagit-agent-coordinationSkill
- metagit-aosSkill
- metagit-bootstrapSkill
- metagit-campaignSkill
- metagit-cliSkill
- metagit-cliSkill
- metagit-config-refreshSkill
- metagit-context-packSkill
- metagit-control-centerSkill
- metagit-gatingSkill
- metagit-gitnexusSkill
- metagit-graph-maintainSkill
- metagit-mcp-resourcesSkill
- metagit-multi-repoSkill
- metagit-projectsSkill
- metagit-release-auditSkill
- metagit-repo-impactSkill
- metagit-rewrite-campaignSkill
- metagit-sharing-stateSkill
- metagit-stampSkill
- metagit-upstream-scanSkill
- metagit-upstream-triageSkill
- The first 60 shown.
The file
We split this agents.md into the rules it gives an agent
12 rules. About 0 are common, 3 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 28
Run from the umbrella repo that contains .metagit.yml (workspace manifest):
- Distinctive: line 45
Before escalating packs, check workspace readiness:
- Very specific: line 162
Start MCP: metagit mcp serve (stdio).
- Distinctive: line 167
When several agents must share one queue, configure the MCP server process (not just the IDE shell):
- Very specific: line 176
Verify: resources/read → metagit://gate/status → state_backend.backend is http.
- Very specific: line 191
Search on-disk files in managed repos.
- Very specific: line 201
Do not use metagit search for file contents — that command searches .metagit.yml metadata only.
- Very specific: line 224
Use the metagit-agent-access skill when a repository needs agent-friendly metadata without bloating human docs:
- Very specific: line 270
Use pause when you need a low-friction checkpoint, then resume to pick the best objective quickly.
- Distinctive: line 386
When multiple agents or humans must see the same objectives, handoffs, and approvals, configure a shared ops server instead of per-machine …
- Very specific: line 396
Run metagit web serve on the coordinator host.
- Very specific: line 405
Not a Git client, SBOM tool, or full-repo packer.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Metagit for AI agents
Compact guide for agents told to install and use Metagit across Git repositories. Prefer these commands over reading full repo trees.
Day-1 control loop: start with agents-quickstart.md (install → context pack →
aos next→ work → complete).
PyPI package:
metagit-cli(notmetagit).
Install
uv tool install metagit-cli
export METAGIT_AGENT_MODE=true # non-interactive CLI (no fuzzy finder / prompts)
metagit version
metagit version check --jsonOptional — install bundled playbooks into your agent host:
metagit skills list
metagit skills install --scope user --target openclaw # or claude_code, hermes, …
metagit mcp install --scope user --target openclaw # MCP server registrationSession start (do this first)
Run from the umbrella repo that contains .metagit.yml (workspace manifest):
metagit context pack --tier 2 --json
metagit prompt workspace --kind session-start --text-only| Tier | Command | Tokens (typical) | Contents |
| 0 | context pack --tier 0 | ~100–400 | Paged workspace map (default 80 repos; check truncated) |
| 1 | context pack --tier 1 | +200–600/repo | Tier 0 + repo cards (git, stack hints, health) |
| 2 | context pack --tier 2 | +digest | Tier 1 + changes since last session |
Escalate tiers only when needed. Use --project / --repo to narrow tier 1/2.
Discovery & readiness
Before escalating packs, check workspace readiness:
metagit workspace summary --json
metagit workspace health --jsonsummary returns readiness.score (0–100), dimension breakdown, and blockers. Exit 0 even when the score is low (report-only). Details: workspace-discovery.md.
Core CLI (agent mode)
| Goal | Command | |||
| Find a managed repo | metagit search "<query>" --json | |||
| Resolve one absolute path | metagit search "<query>" --path-only · MCP metagit_repo_search {path_only: true} | |||
| List managed targets (paged, slim) | metagit workspace repo list --json · MCP metagit_workspace_repos_list | |||
| Search file contents (workspace) | metagit workspace grep "<query>" --json | |||
| Ripgrep / grep backend status | metagit workspace grep info --json | |||
| Workspace catalog (no full manifest) | metagit workspace list --json (paged index; no summary.workspace) | |||
| Large umbrella loop | metagit prompt workspace -k large-workspace --text-only · context-reduction.md | |||
| Workspace health | metagit workspace health --json | |||
| Workspace readiness summary | metagit workspace summary --json | |||
| Validate manifest | metagit config validate | |||
| Component model | Nested repos[].components[]; see concepts/components.md | |||
| Component list/show/resolve | `metagit component list | show | resolve` | |
| Component graph | metagit component graph <identity> --json | |||
| Component detect/init | metagit component detect --json / metagit component init PATH --apply --json | |||
| Derived from component | metagit project derived create -n N --from P/R/C --include-dependencies | |||
| Safe sync (fetch-first) | metagit project sync | |||
| Scoped repo snapshot | metagit context repomix --profile bugfix-local --project P --repo R | |||
| Record objective | echo '{"id":"…","status":"in_progress","title":"…","repos":[]}' | metagit context objective set | |||
| Update objective (merge) | echo '{"id":"…","status":"in_progress","notes":"progress"}' | metagit context objective set — title/repos optional when id exists | |||
| Objective quick-note flags | metagit context objective set --id obj-1 --status in_progress --left-off "done parser" --next "wire CLI" --blockers "none" --human-notes "handoff" --notes-file ./notes.txt | |||
| Objective field edit | metagit context objective edit --id obj-1 --field status --value in_progress | |||
| Pause current work | metagit context pause --title "Paused for handoff" --repo P/R --left-off "tests passing" --next "open PR" | |||
| Resume best objective | metagit context resume --format detailed (or metagit context resume "substring" --json) | |||
| Request approval (CLI) | echo '{"action":"repo_sync","requested_by":"agent","payload":{}}' | metagit context approval request | |||
| List pending approvals | metagit context approval list --json | |||
| Installed vs latest release | metagit version check --json | |||
| Self-update (dry-run) | metagit version upgrade --json | |||
| Self-update (apply) | metagit version upgrade --apply --json | |||
| Agent profile (merged) | metagit agent profile show -p P -n R --json | |||
| Materialize agent posture | metagit agent apply --vendor claude_code -p P -n R | |||
| Campaign list / status | metagit campaign list / metagit campaign status --slug <s> --json --limit 40 | |||
| Campaign create / expand | metagit campaign new … / metagit campaign expand --slug <s> --limit 40 | |||
| Campaign board-sync (ADO) | metagit campaign board-sync --slug <s> --organization ORG --ado-project PROJ --dry-run --json | |||
| Semantic ownership | metagit semantic declare · metagit semantic owners · metagit semantic conflicts | |||
| Merge orchestration | metagit merge enqueue · metagit merge integrate · metagit merge status | |||
| Agent scheduler | metagit schedule next · metagit schedule status · metagit schedule policy show | |||
| Agent OS (composition) | metagit aos status · metagit aos doctor · metagit aos next (coord alias) | |||
| Run ledger | `metagit run list | show | replay | export` |
| Local Atlas | metagit atlas init · metagit atlas generate · metagit atlas validate · metagit atlas query | |||
| Organization index | metagit org index github ORG · metagit org search "query" · metagit graph neighbors REPO · metagit repo materialize REPO | |||
| Derived surgical project | metagit project derived create -n NAME --from P/R or P/R/C [--include-dependencies] · refresh · include · exclude | |||
| Skills surface (inventory) | metagit skills surface --json |
<!-- modality:agent_profile_apply --><!-- modality:native_campaigns --><!-- modality:org_index --><!-- modality:campaign_everroom_context --><!-- modality:objective_mr_approval_binding --><!-- modality:coordination_events_scope --><!-- modality:semantic_ownership --><!-- modality:merge_orchestrator --><!-- modality:agent_scheduler --><!-- modality:aos_status --><!-- modality:run_ledger --><!-- modality:workspace_health --><!-- modality:workspace_summary --><!-- modality:mutation_policy --><!-- modality:atlas_local --><!-- modality:derived_projects --><!-- modality:skills_surface --><!-- modality:campaign_board_link --><!-- modality:context_reduction --><!-- modality:component_model --><!-- modality:component_resolve --><!-- modality:component_graph --><!-- modality:component_detect --><!-- modality:nav_flattened --><!-- modality:managed_repo_search -->Set --definition path/to/.metagit.yml when not in the manifest repo root.
Agent profile and campaigns: reference/agent-profile.md, reference/campaigns.md. Derived projects: reference/derived-projects.md. Skills surface: reference/skills-surface.md. Local repository Atlas: reference/atlas.md. Master index: reference/modality-feature-registry.md.
Prompt kinds (metagit prompt list)
| Kind | Scope | Use when |
large-workspace | workspace | 500+ repo search → paged campaign → board-sync loop |
session-start | workspace | Bootstrap checklist after context pack |
context-switch | workspace | Mid-session switch checklist after metagit context switch |
context-pack | workspace, project, repo | Tier 0→2 escalation guidance |
sync-safe | all | Before fetch/pull/clone |
catalog-edit | workspace, project | Before adding projects/repos |
repo-enrich | repo | Detect metadata into manifest |
subagent-handoff | project, repo | Delegate single-repo work |
metagit prompt workspace --kind context-pack --text-only
metagit prompt project --kind sync-safe --project myproj --text-onlyMCP vs CLI
| Use CLI when | Use MCP when |
| Shell / subprocess agent | IDE host with MCP (Cursor, Claude Desktop, OpenClaw) |
METAGIT_AGENT_MODE=true | Gate active (valid .metagit.yml in workspace) |
Key MCP tools (when gate ACTIVE): metagit_context_pack, metagit_session_begin, metagit_repo_search, metagit_workspace_search, metagit_workspace_grep_info, metagit_workspace_discover, metagit_workspace_health_check, metagit_workspace_sync, metagit_objective_list, metagit_approval_request, metagit_campaign_status, metagit_campaign_board_sync, metagit_campaign_context.
MCP resources (read-only, token-efficient): metagit://catalog → workspace/map?limit=80 → prompt/workspace/session-start?instructions=0 → session/meta. Do not read workspace/config?view=full on large umbrellas. See context-reduction.md.
metagit_version_check and metagit_version_upgrade are available even when the workspace gate is inactive. Use version check (or metagit_version_check) to compare against the latest GitHub release and PyPI. Use version upgrade (or metagit_version_upgrade with apply: true) to run the detected package-manager upgrade (uv tool upgrade metagit-cli by default). Upgrades default to dry-run; pass --apply or apply: true explicitly.
Start MCP: metagit mcp serve (stdio). Install config: metagit mcp install --scope user.
Shared coordination state (multi-agent)
Objectives, handoffs, approvals, and the events feed use the same backend as the CLI. When several agents must share one queue, configure the MCP server process (not just the IDE shell):
export METAGIT_STATE_URL=https://coordinator.example.com:8787
export METAGIT_STATE_TOKEN='…'
metagit mcp serve --root /path/to/manifest-rootVerify: resources/read → metagit://gate/status → state_backend.backend is http.
| MCP tool | Purpose |
metagit_objective_list / metagit_objective_upsert / metagit_objective_edit | Objectives |
metagit_approval_request / metagit_approval_list / metagit_approval_resolve | Approvals |
metagit_handoff_list / metagit_handoff_create / metagit_handoff_claim / metagit_handoff_complete | Handoffs |
metagit_events | Event poll (optional since ISO cursor) |
Resources: metagit://objectives, approvals/pending, handoffs/open, events/recent?since=.
Skill: metagit-sharing-state. Docs: Sharing state across a team.
Workspace content grep (not manifest search)
Search on-disk files in managed repos. Always excludes node_modules, .venv, and similar scaffold paths.
| Goal | CLI | MCP | HTTP (metagit api serve) |
| Content search | metagit workspace grep "QUERY" --json | metagit_workspace_search | GET /v2/workspace/grep?q=… |
| Scoped to project | --project NAME | (filter via repos selectors) | ?project=NAME |
| Scoped to repo | --repo NAME | repos: ["project/repo"] | ?repo=NAME |
| Ripgrep status | metagit workspace grep info --json | metagit_workspace_grep_info | GET /v2/workspace/grep/info |
| List files by intent | — | metagit_workspace_discover | — |
Do not use metagit search for file contents — that command searches .metagit.yml metadata only.
Install skill: metagit-workspace-grep (see Skills). Examples: metagit workspace grep --help.
Skills catalog
Install once; skills are short playbooks (when to use which command):
| Skill | Use when |
metagit-context-pack | Tiered context packs, digest, objectives, approvals, repomix; Hermes session bootstrap |
metagit-cli | All CLI-only workflows (this doc expanded) |
metagit-workspace-scope | Session start, workspace boundaries |
metagit-control-center | Ongoing multi-repo coordination |
metagit-workspace-sync | Guarded sync |
metagit-upstream-scan | Error may originate in another managed repo |
metagit-projects | Before creating new project folders |
metagit-agent-access | On-demand: optimize any repo for minimal-token agent onboarding |
Full table: Skills.
Optimize a target repo (on demand)
Use the metagit-agent-access skill when a repository needs agent-friendly metadata without bloating human docs:
# Audit gaps (llms.txt, AGENTS.md, hidden README HTML comment)
skills/metagit-agent-access/scripts/optimize-agent-access.sh /path/to/repo --json
# Scaffold missing artifacts from templates
skills/metagit-agent-access/scripts/optimize-agent-access.sh /path/to/repo --apply --jsonFor large or unfamiliar repos, dispatch the subagent prompt in skills/metagit-agent-access/subagent-prompt.md (returns JSON summary only — no full file dumps in chat).
Hidden marker convention in README:
<!-- agent-access:start
install: ...
session_start: ...
refs: llms.txt, AGENTS.md
agent-access:end -->Single-repo first run
Inside any Git repo without a manifest:
metagit init # safe to re-run when .metagit.yml already exists and is valid
metagit config validateRe-running init on a valid manifest exits 0 with “Already initialized” and does not overwrite. Use --force only when you intend to replace the file (blocked in agent mode without removing it first).
Catalog adds support --ensure (auto-enabled in agent mode): re-run succeeds with operation: noop when the project/repo already exists with matching url/path. MCP/API default ensure: true.
Human ↔ agent shared state
- Objectives —
.metagit/sessions/objectives.json(local default); CLImetagit context objective … - Approvals — mutating ops queue;
metagit context approval … - Handoffs —
.metagit/sessions/handoffs.json; CLImetagit context handoff … - Web UI (local):
metagit web serve→ objectives/approvals at/v3/ops/*
Objective pause/resume and notes ergonomics
<!-- modality:context_resume_status_tracking -->Use pause when you need a low-friction checkpoint, then resume to pick the best objective quickly.
metagit context pause --title "Paused for handoff" --repo demo/svc --left-off "completed parser" --next "wire CLI" --blockers "none"
metagit context resume --format detailed
metagit context resume "demo/svc" --jsonResume selection prefers in_progress objectives, then most recently updated entries. The optional filter matches objective id/title/repos plus human/agent notes.
Objective set/edit supports ergonomic updates without rewriting full payloads:
metagit context objective set --id obj-123 --status in_progress --left-off "tests green" --next "open PR" --human-notes "handoff"
metagit context objective edit --id obj-123 --field human_notes --value "Waiting on review"Helper script template: examples/resume-project.sh
MCP parity: metagit_context_resume exposes the same resume candidate logic.
Handoffs and leases
<!-- modality:handoff_lease_heartbeat -->metagit context handoff claim --id <id> --by agent-1 --ttl 30m
metagit context handoff heartbeat --id <id> --by agent-1 --ttl 30m
metagit context events --campaign <slug> --json
metagit context events --objective <id> --since "2026-07-06T00:00:00Z" --jsonExpired claims auto-release when listing handoffs. Objectives may carry mr_url and approval_id for campaign rollups (modality:objective_mr_approval_binding).
Agent Coordination Layer (ACL)
<!-- modality:acl_branch --><!-- modality:acl_lease --><!-- modality:acl_worktree --><!-- modality:acl_claim --><!-- modality:acl_manifest -->For isolated agent checkouts, branch leases, and advisory file claims, see
Agent coordination (ACL) and skill
metagit-agent-coordination. ACL branch leases are
distinct from handoff claim TTL leases above.
metagit branch allocate --repository project/repo --agent-id agent-1 --task-id 412
metagit lease acquire --repository project/repo --agent-id agent-1 --task-id 412 --allocate
metagit worktree create --repository project/repo --agent-id agent-1 --task-id 412 --branch agent/412
metagit claim declare --repository project/repo --agent-id agent-1 --pattern 'src/*'
metagit claim declare --repository platform/core --agent-id agent-1 --component web
metagit context events --json # includes source=acl lifecycle eventsTask Graph & Intent (RFC-0008)
<!-- modality:task_graph -->Expand objectives into a DAG of executable nodes, compute ready sets, and store optional ACL command hints. See Task graph.
metagit task create --title "Ship auth" --goal "…" --json
metagit task expand --graph-id … --from-outline outline.txt
metagit task ready --json
metagit task complete --node-id …
metagit task bind-acl --node-id … --agent-id agent-1 --json
metagit context events --json # includes source=taskgraphContext Compiler (RFC-0009)
<!-- modality:context_compile -->Compile a budgeted context artifact for a project/repo (optionally bound to a task node). See Context compiler.
metagit context compile --project P --repo R --tier 1 --budget 8000 --json
metagit context compile --project P --repo R --task-id NODE --graph-id G --jsonContext switch
<!-- modality:context_switch -->Mid-session bootstrap into a project (optional repo): env exports, tiered pack,
context-switch prompt, and an objective. See Context switch.
eval "$(metagit context switch <project> [<repo>])"
metagit context switch <project> --json
metagit prompt workspace -k context-switch --text-onlyMCP: metagit_context_switch (full bootstrap). Lean alternative: metagit_project_context_switch.
Human FuzzyFinder shortcut (not for agent mode): metagit nav --all lists every managed project/repo with the repo-picker preview; --print-path prints the absolute path instead of opening an editor; --unmanaged includes extra sync-folder dirs. Agents must use workspace repo list --json and search --path-only instead.
Semantic Ownership (RFC-0010)
Declare concept-level ownership for repository paths, resolve path owners, and surface advisory claim hints without replacing Git or GitNexus. See Semantic ownership.
metagit semantic declare --concept Authentication --repository project/repo --pattern 'src/auth/**' --json
metagit semantic owners --repository project/repo --path src/auth/token.py --json
metagit semantic conflicts --repository project/repo --json
metagit semantic ingest --jsonSharing state across machines (remote backend)
When multiple agents or humans must see the same objectives, handoffs, and approvals, configure a shared ops server instead of per-machine JSON files:
export METAGIT_STATE_URL=https://coordinator.example.com:8787
export METAGIT_STATE_TOKEN='…'
# CLI / MCP commands unchanged — stores use RemoteHttpBackend automatically
metagit context objective list --jsonRun metagit web serve on the coordinator host; set the same state.url in app
config on every client. Repo clones remain local; only coordination documents are
centralized.
See Sharing state across a team for architecture
diagram, HTTP contract (ETag / If-Match), and troubleshooting.
What metagit is not
Not a Git client, SBOM tool, or full-repo packer. For whole-repo dumps use metagit context repomix with a profile, not raw repomix on the entire tree.
More
- Terminology — workspace / project / repo
- CLI reference
- Hermes multi-repo IaC
- Site: https://metagit-ai.github.io/metagit-cli/
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.

