This document is the agent contract for this repo. It applies identically to Codex, Claude Code, and any other agentic CLI working here. CLAUDE.md is a symlink to this file — do not edit them independently.
- Optimize for task completion with low token use.
- Prefer phase-based execution over conversational micro-steps.
If you are a Claude Code session arriving in this repo for the first time:
- Branch awareness — by default ANY branch that is not a protected base
(
main/dev/master, plus any repo-configured protected branch) counts as an agent-managed branch you may edit and commit on.agent/*,claude/*,vendor/*,feat/*, or any ad-hoc name all work — being OFF a protected base is the only load-bearing rule, so you don't need to setGUARDEX_AGENT_BRANCH_PREFIXES. Lockdown is opt-in: setGUARDEX_AGENT_BRANCH_PREFIXES_ONLY=1(+ an explicit prefix list) to gate the Claude Code edit/Bash guard, and/orGUARDEX_REQUIRE_AGENT_BRANCH=1(orgit config multiagent.requireAgentBranch true) to force git commits back onto theagent/*namespace. - Slash commands —
/gx-status,/gx-doctor,/gx-pivot,/gx-pr,/gx-finish,/gx-setup,/gx-actare available out of the box. See.claude/commands/./gx-actwraps nektos/act so CI workflows run locally before the remote PR run, letting you squash-merge on the first green round-trip. - PR flow — when you need explicit PR control, use
gx pr open,gx pr status,gx pr sync, orgx pr watch. For end-of-task commit + push + PR + merge + cleanup, still use the non-negotiablegx branch finish --via-pr --wait-for-merge --cleanup. - Repo wiring —
gx claude installwrites.claude/settings.json, hooks, slash commands, the gitguardex skill, and a.mcp.jsonthat registers the read-onlygxMCP server (the cross-repo agent radar:list_agents,who_owns,my_context) into a target repo. Opt out with--no-mcp. It also installs abide rule hooks through the in-repo shim.claude/hooks/abide_hook.js, which compile the repo'sAGENTS.md/CLAUDE.mdinto.abide/rubric.jsonand judge every edit against those rules from outside the context window. The shim finds@coldtea/abideat run time (global install, or the npx cachegx claude installwarms), so the committed hook entry is the same on every machine. Abide needs a TypeSafe key (abide login, orTYPESAFE_AI_API_KEYin the env /.env.local); without one the hooks are wired but silent. Opt out with--no-abide;--compilebuilds the rubric now instead of at the next session.gx claude checkdiagnoses drift without writing (legacy absolute hook paths, an unresolvable package, a missing key, a rubric older than its sources;--calibratescores the rules against git history);gx claude doctordiagnoses and repairs. The same rules judge the PR:gx pr-reviewandgx branch finish --gate-reviewrunabide checkon the PR diff and post its verdicts beside the AI review (actblocks like a high finding,flagis advisory);--no-abide/--no-gate-abideorGUARDEX_REVIEW_ABIDE=0turn that off.gx codex installwires the same hooks into.codex/hooks.jsonfor Codex (accept them once via/hooks);gx statusand the MCPmy_contexttool show whether the rules are enforced here (hooks, rubric freshness, key, last-7-day violations).
When writing complex features or significant refactors, use an ExecPlan (as described in .agent/PLANS.md) from design to implementation.
- Never edit, stage, or commit on
dev/main. Open anagent/*branch + worktree first. - Claim files before edits:
gx locks claim --branch "<agent-branch>" <file...>(or Colonytask_claim_fileon an active task). - Finish completed work with
gx branch finish --branch "<agent-branch>" --via-pr --wait-for-merge --cleanup. Never stop at bare--via-pr.gx shipis the short alias for that exact gated finish. - When work is complete, always offer to finish and merge it — never leave commits stranded in a worktree. Set
GUARDEX_AUTO_SHIP=1to make a baregx finish/gx branch finishdefault to that gated ship automatically (see Toggle). - Commit, push, and open/update a PR for completed work unless the user explicitly says to keep it local.
- OpenSpec is opt-in. Work directly in code/tests unless the user requests it, an existing change is being continued, or T2/T3 is explicitly selected.
- Keep outputs compact: less word, same proof.
- Do not commit ephemeral runtime artifacts or local settings:
.dev-ports.json,apps/logs/*.log,.codex/settings.local.json,.claude/settings.local.json,.omc/project-memory.json,.omc/state/**,.omx/state/**. - Do not embed stale memory dumps, PR transcripts, session history, or long logs in this file.
- Frontend/UI/UX requests: load
.codex/skills/ui-ux-pro-max/SKILL.mdfirst. - The
multiagent-safetymarker section below is machine-managed. Do not edit between markers.
# 1. Start a sandbox worktree (default T1 writes no OpenSpec artifacts):
ALLOW_BASH_ON_NON_AGENT_BRANCH=1 \
gx branch start [--tier T0|T1|T2|T3] "<task>" "claude-<name>"
# 2. Work inside the printed worktree path:
cd .omc/agent-worktrees/gitguardex__claude-<name>__<slug>
gx locks claim --branch "agent/claude-<name>/<slug>" <file...>
# implement + commit inside this worktree
# 3. Only for an explicitly active OpenSpec workflow:
openspec validate --specs
# 4. Finish via PR + cleanup (the non-negotiable default):
gx branch finish \
--branch "agent/claude-<name>/<slug>" \
--base main --via-pr --wait-for-merge --cleanup
# Branch protection blocks merge? Enable auto-merge once PR URL is known:
gh pr merge <PR-NUMBER> --repo <owner>/<repo> --auto --squash
# Sweep multiple finished lanes in one shot:
gx finish --allTier guide (default is direct T1; select T2/T3 only when OpenSpec is wanted):
| Tier | Use for | Scaffolding | Gates |
|---|---|---|---|
T0 |
typos, dep bumps, format-only | none | tasks gate skipped |
T1 |
routine implementation (default) | none | tasks gate skipped |
T2 |
explicit structured change | full change workspace | full gates |
T3 |
explicit plan-driven work | change + plan workspace | full gates |
See .agent/CLAUDE-CODE-WORKFLOW.md for full tier examples, finish flow, and skill_guard notes.
- Python:
.venv/bin/python(uv, CPython 3.13.3) - GitHub auth for git/API is available via env vars:
GITHUB_USER,GITHUB_TOKEN(PAT). Do not hardcode or commit tokens. - For authenticated git over HTTPS in automation, use:
https://x-access-token:${GITHUB_TOKEN}@github.com/<owner>/<repo>.git
The /project-conventions skill is auto-activated on code edits (PreToolUse guard).
| Convention | Location | When |
|---|---|---|
| Code Conventions (Full) | /project-conventions skill |
On code edit (auto-enforced) |
| Git Workflow | .codex/conventions/git-workflow.md |
Commit / PR |
- Specs/Design/Tasks (SSOT):
openspec/- Active changes:
openspec/changes/<change>/ - Main specs:
openspec/specs/<capability>/spec.md - Archived changes:
openspec/changes/archive/YYYY-MM-DD-<change>/
- Active changes:
spec.mdis normative (testable requirements only); free-form context lives inopenspec/specs/<capability>/context.md.- Do not add feature/behavior docs under
docs/. Do not editCHANGELOG.mddirectly. - Validate:
openspec validate --specs. Verify before archive:/opsx:verify <change>. - Opt-in OpenSpec workflow, command list, and documentation model:
.agent/OPENSPEC-WORKFLOW.md.
If a change publishes or bumps a package version, the same change must also update the release notes / changelog entries (record change notes in OpenSpec artifacts, not CHANGELOG.md).
| Subdoc | What's inside |
|---|---|
.agent/TOKEN-DISCIPLINE.md |
Token-efficient execution: planning phases, token/command/git discipline, reporting format, verification, and multi-agent token budget supplement. |
.agent/MULTI-AGENT-EFFICIENCY.md |
Token-efficient multi-agent work: scout-then-implement, one-job-per-agent, parallel split-role review, model routing, and when not to fan out. |
.agent/GUARDEX-TOGGLE.md |
GUARDEX_ON toggle semantics in repo-root .env (disable / re-enable Guardex workflow). |
.agent/CLAUDE-CODE-WORKFLOW.md |
Full Claude Code workflow: tiering table with examples, sandbox + lock + finish steps, default Claude finish (non-negotiable), skill_guard notes. |
.agent/OPENSPEC-WORKFLOW.md |
Opt-in OpenSpec workflow, source-of-truth layout, documentation model (spec + context), and /opsx:* command list. |
.agent/MULTI-AGENT-CONTRACT.md |
Repo-specific supplements to the marker-managed multiagent-safety contract: local base safety, ownership/lock discipline (incl. main.rs lock), shared behavior protection, integrator finalization gate. |
.agent/PLAN-WORKSPACE.md |
openspec/plan/ workspace contract: default quick flow, role tasks files, checklist headings, helper sub-branch exception, scaffold command. |
.agent/STALLED-WORKTREE-RECOVERY.md |
How scripts/agent-stalled-report.sh and scripts/agent-autofinish-watch.sh recover stalled agent/* worktrees; __source-probe-* cleanup steps. |
Guardex is enabled by default. Disable via repo-root .env with GUARDEX_ON=0.
- Work from an
agent/*branch + worktree — never edit the protected base (main/dev) directly. Start withgx branch start "<task>" "<agent-name>", thencdinto the printed worktree. - Claim files before editing:
gx locks claim --branch "<agent-branch>" <file...>. - Finish completed work via PR + cleanup:
gx branch finish --branch "<agent-branch>" --via-pr --wait-for-merge --cleanup(orgx finish --all). - Default to the self-repairing gated ship — add
--gate-review --gate-autofixso blocking findings are fixed and re-verified before the merge instead of leaving the PR open. Add--gate-baselineonly where the base branch CI is already red. CI waits until the review is clean by default;--no-gate-serial-ciopts into overlapping CI with review. Posting a review is not merging:gx pr-reviewposts and exits; onlygx branch finishmerges. Never ask the user whether to run the review or to merge: review automatically and merge when the gate is clean; stop only when it blocks or the user said keep-local.
Want the full multi-agent contract (Colony coordination, OpenSpec, token discipline, recovery)? Run gx setup --contract.
For additional context about technologies to be used, project structure, shell commands, and other important information, read the current plan