Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

chore(agents): make shared agent definitions canonical

rubenluetke10-beepcafd03324a9d
diff --git a/.agents/README.md b/.agents/README.md
index 3e4b9aadd6..0011fe7a3e 100644
--- a/.agents/README.md
+++ b/.agents/README.md
@@ -1,20 +1,19 @@
-# .agents/ — tool-neutral twin of .claude/
+# .agents/ — shared source of agent knowledge
-This directory is the cross-tool mirror of the versioned agent knowledge in
-`.claude/`: the `agents/`, `commands/` and `skills/` subtrees are kept in sync
-pair-for-pair (see CLAUDE.md / AGENTS.md §0, the binding mirror rule).
+This directory is the source for the versioned agent definitions and skills.
+`AGENTS.md` is the source for repository-wide instructions.
- **Audience:** every coding agent working in this repo — Codex, Gemini CLI,
Claude Code, or anything else. Nothing in here is Claude-only; read the
subagent definitions, command templates and skills as generally applicable.
-- **Canonical side:** `.claude/` (tie-breaker on pre-existing drift), but edits
- on either side propagate to the other — including deletions.
-- **Sync engine:** `scripts/ci/sync_agents_dir.py`, run from the Claude Code
- `PostToolUse` hook (live), `.githooks/pre-commit --stage` (hard guarantee on
- every commit), and `--check` for CI/manual verification.
+- **Compatibility copies:** `scripts/ci/sync_agents_dir.py` copies `agents/`,
+ `commands/`, and `skills/` into `.claude/`; `sync_codex_agents.py` projects
+ `agents/*.md` into `.codex/agents/*.toml`. Both are checked in CI and run
+ before commits. Claude Code and Codex still need these tool-specific paths
+ to discover project subagents; Claude Code also needs `.claude/skills/`.
- **Privacy:** gitignored entries (e.g. `skills/security-github/`, a local-only
maintainer tool) are excluded from the mirror on both sides and must never be
committed.
-Do not hand-copy files between the two trees; edit one side and let the sync
-engine (or the pre-commit hook) do the rest.
+Edit this tree only. Run the sync scripts after editing or let the pre-commit
+hook create the compatibility copies.
diff --git a/.agents/agents/code-reviewer.md b/.agents/agents/code-reviewer.md
index 597c3ba6d4..73105fb928 100644
--- a/.agents/agents/code-reviewer.md
+++ b/.agents/agents/code-reviewer.md
@@ -1,13 +1,13 @@
---
name: code-reviewer
-description: Use proactively after writing or modifying substantial code in the current session. NEVER as part of a push or release — version bumps, changelog entries, tags, and pushing already-committed work spawn no review (maintainer directive 2026-08-12; CLAUDE.md §2, a push is `git push`). Senior code review against the rules in CLAUDE.md.
+description: Use proactively after writing or modifying substantial code in the current session. NEVER as part of a push or release — version bumps, changelog entries, tags, and pushing already-committed work spawn no review (AGENTS.md §4, a push is `git push`). Senior code review against AGENTS.md.
tools: Read, Grep, Glob
model: sonnet
role: reviewer
domain: generic
phase: any
must_read:
- - CLAUDE.md
+ - AGENTS.md
when_to_use: Diff review after writing substantial code in the session — generic, any area, BLOCKER/MAJOR/MINOR findings with file:line evidence. Never at push/release time; publishing existing commits is not a code change.
---
@@ -16,8 +16,8 @@ problems and propose concrete fixes with `file:line` evidence.
## Mandatory reading before every review
-1. `CLAUDE.md` — the whole rulebook, single source. (`AGENTS.md` is its
- byte-identical twin, not a second document; reading both is reading one.)
+1. `AGENTS.md` — the whole rulebook and source of truth. `CLAUDE.md` is its
+ byte-identical compatibility copy; reading both is unnecessary.
2. `docs/BUGS.md` — what these traps cost in production, when you need the
history behind a rule or an `AP-nn` marker you found in a code comment.
3. The changed files themselves, read in full, not just the diff.
@@ -101,7 +101,7 @@ is worse than no review.
## Review checklist — MINOR
-- **Everything committed is English** (CLAUDE.md §1, highest priority): code,
+- **Everything committed is English** (AGENTS.md §2): code,
comments, docstrings, log and error messages, test names, CLI help. German is
allowed only on the closed product surface — runtime voice/chat output, i18n
files, speech-input vocabulary, and tests quoting them. Pre-existing German in
@@ -139,5 +139,5 @@ is worse than no review.
```
If the review is fully clean, say so explicitly — `Clean review — no issues
-found, conforms to CLAUDE.md` — and return
+found, conforms to AGENTS.md` — and return
`APPROVE`. Do not invent findings to look thorough.
diff --git a/.agents/agents/docs-privacy-reviewer.md b/.agents/agents/docs-privacy-reviewer.md
index 86b9ee6e00..b4cfb949c8 100644
--- a/.agents/agents/docs-privacy-reviewer.md
+++ b/.agents/agents/docs-privacy-reviewer.md
@@ -7,12 +7,12 @@ role: reviewer
domain: generic
phase: docs
must_read:
- - CLAUDE.md
+ - AGENTS.md
- scripts/ci/docs_privacy_scan.py
when_to_use: After a Write/Edit under docs/ — the deterministic hook flagged a hit, or a substantial new/changed doc needs a semantic privacy pass before it could ship publicly.
---
-You are the documentation privacy reviewer for Personal Jarvis. The project ships from ONE public repo whose history is world-readable forever (see `CLAUDE.md` §2): one leaked key, real name, personal path, private email, or Windows SID in a single commit is permanent. Your job is to read a documentation file end-to-end and report everything personal or secret that must not ship. You write NO fixes — you find problems with `file:line` evidence; the main agent applies the masking.
+You are the documentation privacy reviewer for Personal Jarvis. The project ships from ONE public repo whose history is world-readable forever (see `AGENTS.md` §2): one leaked key, real name, personal path, private email, or Windows SID in a single commit is permanent. Your job is to read a documentation file end-to-end and report everything personal or secret that must not ship. You write NO fixes — you find problems with `file:line` evidence; the main agent applies the masking.
You are the *semantic* half of a two-layer defence. The *deterministic* half is `scripts/ci/docs_privacy_scan.py`, which reuses the canonical masking manifest when it is present and otherwise falls back to generic patterns (`_generic_manifest()`). The manifest itself is deliberately NOT in the public tree — it would name the very identifiers it masks — so on a public checkout the deterministic half runs in its generic mode and your semantic pass carries proportionally more weight. Always run the script first, then read for what a regex cannot judge.
diff --git a/.agents/agents/jarvis-critic-design-reviewer.md b/.agents/agents/jarvis-critic-design-reviewer.md
index 5dc6f71389..d76b33b117 100644
--- a/.agents/agents/jarvis-critic-design-reviewer.md
+++ b/.agents/agents/jarvis-critic-design-reviewer.md
@@ -7,7 +7,7 @@ role: reviewer
domain: specialist
phase: 6
must_read:
- - CLAUDE.md
+ - AGENTS.md
- docs/adr/0009-self-healing-worker-critic.md
when_to_use: Phase-6 Critic-Loop design review — checks prompts, verdict schema, MAX_CRITIC_LOOPS=3 hardcoding, anchor token, adversarial framing
---
diff --git a/.agents/agents/phase7-selfmod-auditor.md b/.agents/agents/phase7-selfmod-auditor.md
index 4e3a31523f..ee647d5e95 100644
--- a/.agents/agents/phase7-selfmod-auditor.md
+++ b/.agents/agents/phase7-selfmod-auditor.md
@@ -7,7 +7,7 @@ role: reviewer
domain: phase-spezifisch
phase: 7
must_read:
- - CLAUDE.md
+ - AGENTS.md
- docs/self_mod.md
when_to_use: Phase-7 self-mod code review — allowlist hardcoding, pre-validate pipeline, backup atomicity, echo-confirmation pattern match, skill-draft forcing
---
@@ -20,7 +20,7 @@ You are paranoid. You write NO code. You deliver PASS/FAIL verdicts with `file:l
1. **The AP-SM1..SM14 checks below — this file carries them in full.** They are
the register for this area; there is no separate document to fetch.
-2. `CLAUDE.md` section 3 — the project-wide rules these checks specialise
+2. `AGENTS.md` section 3 — the project-wide rules these checks specialise
(atomic config writes, risk tiers, `ToolExecutor`, skills stay draft), plus
`docs/self_mod.md` for the pipeline itself.
3. The reviewed files themselves COMPLETELY — typically under `jarvis/core/self_mod/`, `jarvis/core/config_writer.py`, `jarvis/setup/wizard.py`, `jarvis/plugins/tool/` (self-mod tools), `jarvis/skills/` (skill-authoring path), `jarvis/ui/web/` (audit UI).
diff --git a/.agents/agents/plan-verifier.md b/.agents/agents/plan-verifier.md
index 1e8d4e07a2..bb85f1a4de 100644
--- a/.agents/agents/plan-verifier.md
+++ b/.agents/agents/plan-verifier.md
@@ -7,7 +7,7 @@ role: verifier
domain: generic
phase: any
must_read:
- - CLAUDE.md
+ - AGENTS.md
when_to_use: Check the acceptance criteria of a named plan against the implementation, with file:line or test-name evidence; a hard-negative violation is a merge-stop
---
diff --git a/.agents/agents/win32-specialist.md b/.agents/agents/win32-specialist.md
index 821166e013..1ec409133d 100644
--- a/.agents/agents/win32-specialist.md
+++ b/.agents/agents/win32-specialist.md
@@ -7,7 +7,7 @@ role: worker
domain: specialist
phase: vision+awareness
must_read:
- - CLAUDE.md
+ - AGENTS.md
- jarvis/vision/screenshot.py
- jarvis/vision/uia_tree.py
when_to_use: Win32 API / pywin32 / SetWinEventHook / GetLastInputInfo / UIA / DPI-Awareness — lazy imports + hook lifecycle (UnhookWinEvent + thread join timeout 2s)
@@ -21,7 +21,7 @@ You are a senior Windows systems engineer for Personal Jarvis. You are called wh
2. `jarvis/vision/uia_tree.py` — reference for UIA walking + pruning + thread discipline.
3. `jarvis/awareness/watchers/window.py` and `idle.py` — the two live watchers;
they are the reference for hook lifecycle and the one permitted polling site.
-4. `CLAUDE.md` — sections 1 (traps) and 3 (architecture).
+4. `AGENTS.md` — sections 1 (traps) and 3 (architecture).
## Binding patterns
@@ -41,9 +41,9 @@ You are a senior Windows systems engineer for Personal Jarvis. You are called wh
## Output
-When you write code: Edit/Write directly into the target file. Everything you commit is English (CLAUDE.md section 2) — identifiers, comments, docstrings, log and error messages. Comments explain the WHY, not the WHAT.
+When you write code: Edit/Write directly into the target file. Everything you commit is English (AGENTS.md section 2) — identifiers, comments, docstrings, log and error messages. Comments explain the WHY, not the WHAT.
-Windows is one of three first-class targets, never the baseline (CLAUDE.md section 2). Every Win32 backend sits behind a capability probe with an honest, English-language no-op on macOS and Linux, and a tracked entry in `docs/os-parity.md` when a sibling backend is still missing.
+Windows is one of three first-class targets, never the baseline (AGENTS.md section 2). Every Win32 backend sits behind a capability probe with an honest, English-language no-op on macOS and Linux, and a tracked entry in `docs/os-parity.md` when a sibling backend is still missing.
When you review: findings as a numbered list with severity (BLOCKER/MAJOR/MINOR), file-path:line, concrete fix.
diff --git a/.agents/skills/phase6-adr-update/SKILL.md b/.agents/skills/phase6-adr-update/SKILL.md
index 29edb1f70f..92769d9ba0 100644
--- a/.agents/skills/phase6-adr-update/SKILL.md
+++ b/.agents/skills/phase6-adr-update/SKILL.md
@@ -56,7 +56,7 @@ This skill writes a new ADR or amends an existing ADR in the Phase-6 family. Sty
- ADR-0015 Worker-Backend-Containerized
- ADR-0016 Mission-Reattach-Strategy
-5. **Update CLAUDE.md:** the Phase-6 section in `CLAUDE.md` references the current ADRs. If the new ADR is Phase-6-relevant: add it.
+5. **Update AGENTS.md:** the Phase-6 section in `AGENTS.md` references the current ADRs. If the new ADR is Phase-6-relevant: add it.
6. **Verification:**
- `markdown-lint` if available (otherwise visually).
diff --git a/.agents/skills/publish-new-version/SKILL.md b/.agents/skills/publish-new-version/SKILL.md
index 9447a87d61..ca9e67bf3d 100644
--- a/.agents/skills/publish-new-version/SKILL.md
+++ b/.agents/skills/publish-new-version/SKILL.md
@@ -7,7 +7,7 @@ description: >-
"mach ein Release", "publish the new version", "cut a release", "neue
Public-Version". NOT for an ordinary push — "push", "push nach GitHub",
"sichere den Stand", "commit and push" mean `git push`, no skill, no
- ceremony (CLAUDE.md §2). NOT for untangling git chaos (use git-rescue).
+ ceremony (AGENTS.md §4). NOT for untangling git chaos (use git-rescue).
---
# Cut a New Release
@@ -18,7 +18,7 @@ A release is a **normal push plus four things**: a version bump, a CHANGELOG
entry, a tag, and a published GitHub Release. Nothing else. There is no
snapshot build, no staging tree, no parallel clone, no privacy sub-agent —
that ceremony was retired on 2026-08-05 after it was measured at ~440k tokens
-per push (CLAUDE.md §2). There is also no review sub-agent (retired
+per push (AGENTS.md §4). There is also no review sub-agent (retired
2026-08-12): a release ships commits that already exist, and that code was
reviewed when it was written — never spawn `code-reviewer` for a version
bump, changelog entry, tag, or push. If you catch yourself preparing a clean
@@ -50,7 +50,7 @@ Verify each **with evidence**; report every item as **PASS** or **STOP**:
- **Completeness** — scan the diff since the last tag for
`TODO`/`FIXME`/`NotImplementedError`/stub markers in non-test code. No
half-built user-facing feature ships.
-- **Works for an ARBITRARY downloader (CLAUDE.md §3, AP-23)** — the touched
+- **Works for an ARBITRARY downloader (AGENTS.md §2, AP-23)** — the touched
surface must not be pinned to the maintainer's keys, provider, or OS.
Confirm by test or honest trace: fresh-install-with-one-key, headless-Linux
boot, cross-family fallback. If you cannot verify, say so and STOP.
diff --git a/.claude/agents/code-reviewer.md b/.claude/agents/code-reviewer.md
index 597c3ba6d4..73105fb928 100644
--- a/.claude/agents/code-reviewer.md
+++ b/.claude/agents/code-reviewer.md
@@ -1,13 +1,13 @@
---
name: code-reviewer
-description: Use proactively after writing or modifying substantial code in the current session. NEVER as part of a push or release — version bumps, changelog entries, tags, and pushing already-committed work spawn no review (maintainer directive 2026-08-12; CLAUDE.md §2, a push is `git push`). Senior code review against the rules in CLAUDE.md.
+description: Use proactively after writing or modifying substantial code in the current session. NEVER as part of a push or release — version bumps, changelog entries, tags, and pushing already-committed work spawn no review (AGENTS.md §4, a push is `git push`). Senior code review against AGENTS.md.
tools: Read, Grep, Glob
model: sonnet
role: reviewer
domain: generic
phase: any
must_read:
- - CLAUDE.md
+ - AGENTS.md
when_to_use: Diff review after writing substantial code in the session — generic, any area, BLOCKER/MAJOR/MINOR findings with file:line evidence. Never at push/release time; publishing existing commits is not a code change.
---
@@ -16,8 +16,8 @@ problems and propose concrete fixes with `file:line` evidence.
## Mandatory reading before every review
-1. `CLAUDE.md` — the whole rulebook, single source. (`AGENTS.md` is its
- byte-identical twin, not a second document; reading both is reading one.)
+1. `AGENTS.md` — the whole rulebook and source of truth. `CLAUDE.md` is its
+ byte-identical compatibility copy; reading both is unnecessary.
2. `docs/BUGS.md` — what these traps cost in production, when you need the
history behind a rule or an `AP-nn` marker you found in a code comment.
3. The changed files themselves, read in full, not just the diff.
@@ -101,7 +101,7 @@ is worse than no review.
## Review checklist — MINOR
-- **Everything committed is English** (CLAUDE.md §1, highest priority): code,
+- **Everything committed is English** (AGENTS.md §2): code,
comments, docstrings, log and error messages, test names, CLI help. German is
allowed only on the closed product surface — runtime voice/chat output, i18n
files, speech-input vocabulary, and tests quoting them. Pre-existing German in
@@ -139,5 +139,5 @@ is worse than no review.
```
If the review is fully clean, say so explicitly — `Clean review — no issues
-found, conforms to CLAUDE.md` — and return
+found, conforms to AGENTS.md` — and return
`APPROVE`. Do not invent findings to look thorough.
diff --git a/.claude/agents/docs-privacy-reviewer.md b/.claude/agents/docs-privacy-reviewer.md
index 86b9ee6e00..b4cfb949c8 100644
--- a/.claude/agents/docs-privacy-reviewer.md
+++ b/.claude/agents/docs-privacy-reviewer.md
@@ -7,12 +7,12 @@ role: reviewer
domain: generic
phase: docs
must_read:
- - CLAUDE.md
+ - AGENTS.md
- scripts/ci/docs_privacy_scan.py
when_to_use: After a Write/Edit under docs/ — the deterministic hook flagged a hit, or a substantial new/changed doc needs a semantic privacy pass before it could ship publicly.
---
-You are the documentation privacy reviewer for Personal Jarvis. The project ships from ONE public repo whose history is world-readable forever (see `CLAUDE.md` §2): one leaked key, real name, personal path, private email, or Windows SID in a single commit is permanent. Your job is to read a documentation file end-to-end and report everything personal or secret that must not ship. You write NO fixes — you find problems with `file:line` evidence; the main agent applies the masking.
+You are the documentation privacy reviewer for Personal Jarvis. The project ships from ONE public repo whose history is world-readable forever (see `AGENTS.md` §2): one leaked key, real name, personal path, private email, or Windows SID in a single commit is permanent. Your job is to read a documentation file end-to-end and report everything personal or secret that must not ship. You write NO fixes — you find problems with `file:line` evidence; the main agent applies the masking.
You are the *semantic* half of a two-layer defence. The *deterministic* half is `scripts/ci/docs_privacy_scan.py`, which reuses the canonical masking manifest when it is present and otherwise falls back to generic patterns (`_generic_manifest()`). The manifest itself is deliberately NOT in the public tree — it would name the very identifiers it masks — so on a public checkout the deterministic half runs in its generic mode and your semantic pass carries proportionally more weight. Always run the script first, then read for what a regex cannot judge.
diff --git a/.claude/agents/jarvis-critic-design-reviewer.md b/.claude/agents/jarvis-critic-design-reviewer.md
index 5dc6f71389..d76b33b117 100644
--- a/.claude/agents/jarvis-critic-design-reviewer.md
+++ b/.claude/agents/jarvis-critic-design-reviewer.md
@@ -7,7 +7,7 @@ role: reviewer
domain: specialist
phase: 6
must_read:
- - CLAUDE.md
+ - AGENTS.md
- docs/adr/0009-self-healing-worker-critic.md
when_to_use: Phase-6 Critic-Loop design review — checks prompts, verdict schema, MAX_CRITIC_LOOPS=3 hardcoding, anchor token, adversarial framing
---
diff --git a/.claude/agents/phase7-selfmod-auditor.md b/.claude/agents/phase7-selfmod-auditor.md
index 4e3a31523f..ee647d5e95 100644
--- a/.claude/agents/phase7-selfmod-auditor.md
+++ b/.claude/agents/phase7-selfmod-auditor.md
@@ -7,7 +7,7 @@ role: reviewer
domain: phase-spezifisch
phase: 7
must_read:
- - CLAUDE.md
+ - AGENTS.md
- docs/self_mod.md
when_to_use: Phase-7 self-mod code review — allowlist hardcoding, pre-validate pipeline, backup atomicity, echo-confirmation pattern match, skill-draft forcing
---
@@ -20,7 +20,7 @@ You are paranoid. You write NO code. You deliver PASS/FAIL verdicts with `file:l
1. **The AP-SM1..SM14 checks below — this file carries them in full.** They are
the register for this area; there is no separate document to fetch.
-2. `CLAUDE.md` section 3 — the project-wide rules these checks specialise
+2. `AGENTS.md` section 3 — the project-wide rules these checks specialise
(atomic config writes, risk tiers, `ToolExecutor`, skills stay draft), plus
`docs/self_mod.md` for the pipeline itself.
3. The reviewed files themselves COMPLETELY — typically under `jarvis/core/self_mod/`, `jarvis/core/config_writer.py`, `jarvis/setup/wizard.py`, `jarvis/plugins/tool/` (self-mod tools), `jarvis/skills/` (skill-authoring path), `jarvis/ui/web/` (audit UI).
diff --git a/.claude/agents/plan-verifier.md b/.claude/agents/plan-verifier.md
index 1e8d4e07a2..bb85f1a4de 100644
--- a/.claude/agents/plan-verifier.md
+++ b/.claude/agents/plan-verifier.md
@@ -7,7 +7,7 @@ role: verifier
domain: generic
phase: any
must_read:
- - CLAUDE.md
+ - AGENTS.md
when_to_use: Check the acceptance criteria of a named plan against the implementation, with file:line or test-name evidence; a hard-negative violation is a merge-stop
---
diff --git a/.claude/agents/win32-specialist.md b/.claude/agents/win32-specialist.md
index 821166e013..1ec409133d 100644
--- a/.claude/agents/win32-specialist.md
+++ b/.claude/agents/win32-specialist.md
@@ -7,7 +7,7 @@ role: worker
domain: specialist
phase: vision+awareness
must_read:
- - CLAUDE.md
+ - AGENTS.md
- jarvis/vision/screenshot.py
- jarvis/vision/uia_tree.py
when_to_use: Win32 API / pywin32 / SetWinEventHook / GetLastInputInfo / UIA / DPI-Awareness — lazy imports + hook lifecycle (UnhookWinEvent + thread join timeout 2s)
@@ -21,7 +21,7 @@ You are a senior Windows systems engineer for Personal Jarvis. You are called wh
2. `jarvis/vision/uia_tree.py` — reference for UIA walking + pruning + thread discipline.
3. `jarvis/awareness/watchers/window.py` and `idle.py` — the two live watchers;
they are the reference for hook lifecycle and the one permitted polling site.
-4. `CLAUDE.md` — sections 1 (traps) and 3 (architecture).
+4. `AGENTS.md` — sections 1 (traps) and 3 (architecture).
## Binding patterns
@@ -41,9 +41,9 @@ You are a senior Windows systems engineer for Personal Jarvis. You are called wh
## Output
-When you write code: Edit/Write directly into the target file. Everything you commit is English (CLAUDE.md section 2) — identifiers, comments, docstrings, log and error messages. Comments explain the WHY, not the WHAT.
+When you write code: Edit/Write directly into the target file. Everything you commit is English (AGENTS.md section 2) — identifiers, comments, docstrings, log and error messages. Comments explain the WHY, not the WHAT.
-Windows is one of three first-class targets, never the baseline (CLAUDE.md section 2). Every Win32 backend sits behind a capability probe with an honest, English-language no-op on macOS and Linux, and a tracked entry in `docs/os-parity.md` when a sibling backend is still missing.
+Windows is one of three first-class targets, never the baseline (AGENTS.md section 2). Every Win32 backend sits behind a capability probe with an honest, English-language no-op on macOS and Linux, and a tracked entry in `docs/os-parity.md` when a sibling backend is still missing.
When you review: findings as a numbered list with severity (BLOCKER/MAJOR/MINOR), file-path:line, concrete fix.
diff --git a/.claude/skills/phase6-adr-update/SKILL.md b/.claude/skills/phase6-adr-update/SKILL.md
index 29edb1f70f..92769d9ba0 100644
--- a/.claude/skills/phase6-adr-update/SKILL.md
+++ b/.claude/skills/phase6-adr-update/SKILL.md
@@ -56,7 +56,7 @@ This skill writes a new ADR or amends an existing ADR in the Phase-6 family. Sty
- ADR-0015 Worker-Backend-Containerized
- ADR-0016 Mission-Reattach-Strategy
-5. **Update CLAUDE.md:** the Phase-6 section in `CLAUDE.md` references the current ADRs. If the new ADR is Phase-6-relevant: add it.
+5. **Update AGENTS.md:** the Phase-6 section in `AGENTS.md` references the current ADRs. If the new ADR is Phase-6-relevant: add it.
6. **Verification:**
- `markdown-lint` if available (otherwise visually).
diff --git a/.claude/skills/publish-new-version/SKILL.md b/.claude/skills/publish-new-version/SKILL.md
index 9447a87d61..ca9e67bf3d 100644
--- a/.claude/skills/publish-new-version/SKILL.md
+++ b/.claude/skills/publish-new-version/SKILL.md
@@ -7,7 +7,7 @@ description: >-
"mach ein Release", "publish the new version", "cut a release", "neue
Public-Version". NOT for an ordinary push — "push", "push nach GitHub",
"sichere den Stand", "commit and push" mean `git push`, no skill, no
- ceremony (CLAUDE.md §2). NOT for untangling git chaos (use git-rescue).
+ ceremony (AGENTS.md §4). NOT for untangling git chaos (use git-rescue).
---
# Cut a New Release
@@ -18,7 +18,7 @@ A release is a **normal push plus four things**: a version bump, a CHANGELOG
entry, a tag, and a published GitHub Release. Nothing else. There is no
snapshot build, no staging tree, no parallel clone, no privacy sub-agent —
that ceremony was retired on 2026-08-05 after it was measured at ~440k tokens
-per push (CLAUDE.md §2). There is also no review sub-agent (retired
+per push (AGENTS.md §4). There is also no review sub-agent (retired
2026-08-12): a release ships commits that already exist, and that code was
reviewed when it was written — never spawn `code-reviewer` for a version
bump, changelog entry, tag, or push. If you catch yourself preparing a clean
@@ -50,7 +50,7 @@ Verify each **with evidence**; report every item as **PASS** or **STOP**:
- **Completeness** — scan the diff since the last tag for
`TODO`/`FIXME`/`NotImplementedError`/stub markers in non-test code. No
half-built user-facing feature ships.
-- **Works for an ARBITRARY downloader (CLAUDE.md §3, AP-23)** — the touched
+- **Works for an ARBITRARY downloader (AGENTS.md §2, AP-23)** — the touched
surface must not be pinned to the maintainer's keys, provider, or OS.
Confirm by test or honest trace: fresh-install-with-one-key, headless-Linux
boot, cross-family fallback. If you cannot verify, say so and STOP.
diff --git a/.codex/agents/code-reviewer.toml b/.codex/agents/code-reviewer.toml
index faccf58dcd..ffdc64d987 100644
--- a/.codex/agents/code-reviewer.toml
+++ b/.codex/agents/code-reviewer.toml
@@ -1,13 +1,13 @@
name = "code-reviewer"
-description = "Use proactively after writing or modifying substantial code in the current session. NEVER as part of a push or release — version bumps, changelog entries, tags, and pushing already-committed work spawn no review (maintainer directive 2026-08-12; CLAUDE.md §2, a push is `git push`). Senior code review against the rules in CLAUDE.md."
+description = "Use proactively after writing or modifying substantial code in the current session. NEVER as part of a push or release — version bumps, changelog entries, tags, and pushing already-committed work spawn no review (AGENTS.md §4, a push is `git push`). Senior code review against AGENTS.md."
developer_instructions = '''
You are the senior code reviewer for Personal Jarvis. You write NO code; you find
problems and propose concrete fixes with `file:line` evidence.
## Mandatory reading before every review
-1. `CLAUDE.md` — the whole rulebook, single source. (`AGENTS.md` is its
- byte-identical twin, not a second document; reading both is reading one.)
+1. `AGENTS.md` — the whole rulebook and source of truth. `CLAUDE.md` is its
+ byte-identical compatibility copy; reading both is unnecessary.
2. `docs/BUGS.md` — what these traps cost in production, when you need the
history behind a rule or an `AP-nn` marker you found in a code comment.
3. The changed files themselves, read in full, not just the diff.
@@ -91,7 +91,7 @@ is worse than no review.
## Review checklist — MINOR
-- **Everything committed is English** (CLAUDE.md §1, highest priority): code,
+- **Everything committed is English** (AGENTS.md §2): code,
comments, docstrings, log and error messages, test names, CLI help. German is
allowed only on the closed product surface — runtime voice/chat output, i18n
files, speech-input vocabulary, and tests quoting them. Pre-existing German in
@@ -129,6 +129,6 @@ is worse than no review.
```
If the review is fully clean, say so explicitly — `Clean review — no issues
-found, conforms to CLAUDE.md` — and return
+found, conforms to AGENTS.md` — and return
`APPROVE`. Do not invent findings to look thorough.
'''
diff --git a/.codex/agents/docs-privacy-reviewer.toml b/.codex/agents/docs-privacy-reviewer.toml
index 14317634bc..9b8c99e149 100644
--- a/.codex/agents/docs-privacy-reviewer.toml
+++ b/.codex/agents/docs-privacy-reviewer.toml
@@ -1,7 +1,7 @@
name = "docs-privacy-reviewer"
description = "Use after writing or editing any file under docs/. Reviews a documentation file for personal data and secrets that must never reach the world-readable public repo — the maintainer's real name/email/handle, personal filesystem paths, machine identifiers, private life details, and real credentials. Read-only; reports findings with file:line evidence."
developer_instructions = '''
-You are the documentation privacy reviewer for Personal Jarvis. The project ships from ONE public repo whose history is world-readable forever (see `CLAUDE.md` §2): one leaked key, real name, personal path, private email, or Windows SID in a single commit is permanent. Your job is to read a documentation file end-to-end and report everything personal or secret that must not ship. You write NO fixes — you find problems with `file:line` evidence; the main agent applies the masking.
+You are the documentation privacy reviewer for Personal Jarvis. The project ships from ONE public repo whose history is world-readable forever (see `AGENTS.md` §2): one leaked key, real name, personal path, private email, or Windows SID in a single commit is permanent. Your job is to read a documentation file end-to-end and report everything personal or secret that must not ship. You write NO fixes — you find problems with `file:line` evidence; the main agent applies the masking.
You are the *semantic* half of a two-layer defence. The *deterministic* half is `scripts/ci/docs_privacy_scan.py`, which reuses the canonical masking manifest when it is present and otherwise falls back to generic patterns (`_generic_manifest()`). The manifest itself is deliberately NOT in the public tree — it would name the very identifiers it masks — so on a public checkout the deterministic half runs in its generic mode and your semantic pass carries proportionally more weight. Always run the script first, then read for what a regex cannot judge.
diff --git a/.codex/agents/phase7-selfmod-auditor.toml b/.codex/agents/phase7-selfmod-auditor.toml
index 1900f5b634..3cd6953456 100644
--- a/.codex/agents/phase7-selfmod-auditor.toml
+++ b/.codex/agents/phase7-selfmod-auditor.toml
@@ -9,7 +9,7 @@ You are paranoid. You write NO code. You deliver PASS/FAIL verdicts with `file:l
1. **The AP-SM1..SM14 checks below — this file carries them in full.** They are
the register for this area; there is no separate document to fetch.
-2. `CLAUDE.md` section 3 — the project-wide rules these checks specialise
+2. `AGENTS.md` section 3 — the project-wide rules these checks specialise
(atomic config writes, risk tiers, `ToolExecutor`, skills stay draft), plus
`docs/self_mod.md` for the pipeline itself.
3. The reviewed files themselves COMPLETELY — typically under `jarvis/core/self_mod/`, `jarvis/core/config_writer.py`, `jarvis/setup/wizard.py`, `jarvis/plugins/tool/` (self-mod tools), `jarvis/skills/` (skill-authoring path), `jarvis/ui/web/` (audit UI).
diff --git a/.codex/agents/win32-specialist.toml b/.codex/agents/win32-specialist.toml
index 5d32992c68..013df55fc1 100644
--- a/.codex/agents/win32-specialist.toml
+++ b/.codex/agents/win32-specialist.toml
@@ -9,7 +9,7 @@ You are a senior Windows systems engineer for Personal Jarvis. You are called wh
2. `jarvis/vision/uia_tree.py` — reference for UIA walking + pruning + thread discipline.
3. `jarvis/awareness/watchers/window.py` and `idle.py` — the two live watchers;
they are the reference for hook lifecycle and the one permitted polling site.
-4. `CLAUDE.md` — sections 1 (traps) and 3 (architecture).
+4. `AGENTS.md` — sections 1 (traps) and 3 (architecture).
## Binding patterns
@@ -29,9 +29,9 @@ You are a senior Windows systems engineer for Personal Jarvis. You are called wh
## Output
-When you write code: Edit/Write directly into the target file. Everything you commit is English (CLAUDE.md section 2) — identifiers, comments, docstrings, log and error messages. Comments explain the WHY, not the WHAT.
+When you write code: Edit/Write directly into the target file. Everything you commit is English (AGENTS.md section 2) — identifiers, comments, docstrings, log and error messages. Comments explain the WHY, not the WHAT.
-Windows is one of three first-class targets, never the baseline (CLAUDE.md section 2). Every Win32 backend sits behind a capability probe with an honest, English-language no-op on macOS and Linux, and a tracked entry in `docs/os-parity.md` when a sibling backend is still missing.
+Windows is one of three first-class targets, never the baseline (AGENTS.md section 2). Every Win32 backend sits behind a capability probe with an honest, English-language no-op on macOS and Linux, and a tracked entry in `docs/os-parity.md` when a sibling backend is still missing.
When you review: findings as a numbered list with severity (BLOCKER/MAJOR/MINOR), file-path:line, concrete fix.
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
index 9fc2736431..31a46f3808 100755
--- a/.githooks/pre-commit
+++ b/.githooks/pre-commit
@@ -1,27 +1,17 @@
#!/bin/sh
-# pre-commit: keep AGENTS.md and CLAUDE.md byte-identical on every commit.
+# pre-commit: keep generated agent compatibility files aligned.
#
-# CLAUDE.md (the long-standing agent contract) and AGENTS.md (the cross-tool
-# standard name) are intentional twins -- edit one, the other follows. This hook
-# is the hard guarantee: whatever is about to be committed has both files in
-# sync, no matter who edited them (Claude, the maintainer, a parallel session, a
-# plain editor). The sync engine is scripts/ci/sync_agents_md.py.
+# AGENTS.md and .agents/ are authoritative. This hook projects them into the
+# paths Claude Code and Codex still use for project instructions and subagents.
#
-# Behaviour:
-# * already in sync -> no-op, commit proceeds.
-# * one side edited -> the other is rewritten to match and re-staged
-# (so the commit carries both, in sync).
-# * both edited and they differ-> CONFLICT: the commit is BLOCKED so the two
-# edits can be reconciled by hand.
+# Behaviour: a staged source also stages its generated copy. Generated copies
+# are overwritten when they differ from their source.
#
# This hook is VERSIONED in .githooks/; git runs it via core.hooksPath=.githooks
# (set by scripts/ci/install_git_hooks.py on a fresh clone). It never sets that
# itself.
#
-# Bypass once: git commit --no-verify
-#
-# Fail-open when the engine genuinely cannot run (no python) -- a sync miss is
-# caught at the next commit; fail-closed only on a real, confirmed conflict.
+# Fail-open when Python cannot run; CI checks the projections independently.
# Prefer the known-good interpreter (a bare 'python' may be a deps-less venv on
# this machine); fall back to whatever 'python'/'python3' resolves to. The sync
@@ -36,42 +26,26 @@ sync="scripts/ci/sync_agents_md.py"
"$PY" "$sync" --stage --quiet </dev/null
rc=$?
-# rc 0 = in sync (or just synced + re-staged); rc 2 = unresolvable conflict.
-# Any other rc (setup error) fails open -- never wedge a commit on tooling noise.
-if [ "$rc" -eq 2 ]; then
- echo ""
- echo "pre-commit BLOCKED: AGENTS.md and CLAUDE.md were both edited and now differ."
- echo " They must stay byte-identical. Reconcile the two by hand, re-stage, retry."
- echo " Bypass once with: git commit --no-verify"
+# A missing source is a real error; do not commit a stale compatibility copy.
+if [ "$rc" -ne 0 ]; then
+ echo "pre-commit BLOCKED: AGENTS.md could not be projected to CLAUDE.md."
exit 1
fi
-# --- .claude/ <-> .agents/ tree sync (same twin rule, one level up) -----------
-# The versioned team knowledge under .claude/{agents,commands,skills} and its
-# tool-neutral twin .agents/{agents,commands,skills} must carry the same
-# content on every commit, so every coding agent (not just Claude Code) reads
-# the same material. Engine: scripts/ci/sync_agents_dir.py (same semantics as
-# the MD engine; rc 2 = the same pair edited on both sides -> block).
+# --- .agents/ -> .claude/ compatibility copies -------------------------------
syncdir="scripts/ci/sync_agents_dir.py"
if [ -f "$syncdir" ]; then
"$PY" "$syncdir" --stage --quiet </dev/null
- if [ "$?" -eq 2 ]; then
- echo ""
- echo "pre-commit BLOCKED: .claude/ and .agents/ were both edited and now differ."
- echo " The two trees must stay in sync. Reconcile the pair(s) listed above by"
- echo " hand, re-stage, retry. Bypass once with: git commit --no-verify"
+ if [ "$?" -ne 0 ]; then
+ echo "pre-commit BLOCKED: .agents/ could not be projected to .claude/."
exit 1
fi
fi
-# --- .claude/agents/ -> .codex/agents/ projection ----------------------------
-# The third tree. Not a twin but a generated projection (Markdown -> Codex TOML),
-# so there is no both-sides-edited conflict to resolve: .claude/ always wins and
-# a hand-edit in .codex/ is simply overwritten. Never blocks — worst case the
-# projection is rewritten and staged under the commit that changed its source.
+# --- .agents/agents/ -> .codex/agents/ projection ----------------------------
synccodex="scripts/ci/sync_codex_agents.py"
if [ -f "$synccodex" ]; then
- "$PY" "$synccodex" --stage --quiet </dev/null
+ "$PY" "$synccodex" --stage --quiet </dev/null || exit 1
fi
# --- LANGUAGE gate (FAIL-CLOSED on confirmed German) --------------------------
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9d38e5b817..b836c96592 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -557,12 +557,8 @@ jobs:
- name: Brand-logo gate (BLOCKING)
run: python scripts/ci/check_brand_logos.py
- # CLAUDE.md §0 promises the agent-knowledge mirrors are held by "hook +
- # pre-commit + CI". The CI leg did not exist until 2026-08-20, so a commit
- # made with hooks uninstalled (`install_git_hooks.py` is a manual step)
- # could drift the trees with nothing to catch it. Three trees, two
- # engines: .claude <-> .agents is byte-identical, .codex is a generated
- # projection. Both are cheap — stdlib and git only.
+ # AGENTS.md and .agents/ are authoritative. Claude and Codex compatibility
+ # copies must match them, even when local hooks were not installed.
- name: Agent-knowledge mirrors (BLOCKING)
run: |
python scripts/ci/sync_agents_md.py --check
diff --git a/AGENTS.md b/AGENTS.md
index 20fd9069a4..859c40c0f8 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,14 +1,15 @@
-# CLAUDE.md
+# Personal Jarvis agent rules
The binding rules for every coding agent in this repo — Claude Code, Codex,
Gemini CLI, whichever. This is the whole rulebook; there is no longer a fuller
version to read first. Write everything here so it addresses ANY agent.
-**Twin:** `AGENTS.md` is byte-identical to this file. `.claude/{agents,skills}/`
-↔ `.agents/{…}`, and `.codex/agents/*.toml` is a generated projection of
-`.claude/agents/*.md` — never hand-edit it. Three sync engines hold all of it
-(`sync_agents_md.py`, `sync_agents_dir.py`, `sync_codex_agents.py`); a hook,
-pre-commit and CI run them. Edit the canonical side and let them work.
+**Source of truth:** Edit `AGENTS.md` and `.agents/{agents,skills}/`.
+`CLAUDE.md` and `.claude/{agents,skills}/` are compatibility copies because
+Claude Code does not discover project subagents or skills under `.agents/`, and
+its `AGENTS.md` support is conditional. `.codex/agents/*.toml` is generated
+from `.agents/agents/*.md` for Codex. The sync scripts and CI check these
+copies; never edit a generated copy directly.
---
diff --git a/CLAUDE.md b/CLAUDE.md
index 20fd9069a4..859c40c0f8 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -1,14 +1,15 @@
-# CLAUDE.md
+# Personal Jarvis agent rules
The binding rules for every coding agent in this repo — Claude Code, Codex,
Gemini CLI, whichever. This is the whole rulebook; there is no longer a fuller
version to read first. Write everything here so it addresses ANY agent.
-**Twin:** `AGENTS.md` is byte-identical to this file. `.claude/{agents,skills}/`
-↔ `.agents/{…}`, and `.codex/agents/*.toml` is a generated projection of
-`.claude/agents/*.md` — never hand-edit it. Three sync engines hold all of it
-(`sync_agents_md.py`, `sync_agents_dir.py`, `sync_codex_agents.py`); a hook,
-pre-commit and CI run them. Edit the canonical side and let them work.
+**Source of truth:** Edit `AGENTS.md` and `.agents/{agents,skills}/`.
+`CLAUDE.md` and `.claude/{agents,skills}/` are compatibility copies because
+Claude Code does not discover project subagents or skills under `.agents/`, and
+its `AGENTS.md` support is conditional. `.codex/agents/*.toml` is generated
+from `.agents/agents/*.md` for Codex. The sync scripts and CI check these
+copies; never edit a generated copy directly.
---
diff --git a/scripts/ci/sync_agents_dir.py b/scripts/ci/sync_agents_dir.py
index 4c093df562..1fec9ff38b 100644
--- a/scripts/ci/sync_agents_dir.py
+++ b/scripts/ci/sync_agents_dir.py
@@ -1,50 +1,28 @@
#!/usr/bin/env python3
-"""Keep the ``.claude/`` and ``.agents/`` team-knowledge trees in sync.
+"""Copy shared agent knowledge from ``.agents/`` into ``.claude/``.
-Sibling of ``sync_agents_md.py`` (which twins CLAUDE.md and AGENTS.md), same
-idea one level up: the versioned agent knowledge under ``.claude/`` — the
-``agents/``, ``commands/`` and ``skills/`` subtrees — is addressed to EVERY
-coding agent, not just Claude Code. ``.agents/`` is the tool-neutral twin
-other agents (Codex, Gemini CLI, ...) can read without knowing anything about
-Claude. ``.claude/`` is canonical; edit either side and the other follows.
+Claude Code discovers project subagents and skills in ``.claude/``. The shared
+source lives in ``.agents/``; generated Claude copies are never authoritative.
This script is the single sync engine, used from three places:
- * ``.githooks/pre-commit`` (with ``--stage``) -- the hard guarantee: every
- commit lands both trees in sync, regardless of who edited them.
- * the Claude Code ``PostToolUse`` hook -- live mirroring while an
- edit happens, so the working tree is already in sync before any commit.
+ * ``.githooks/pre-commit`` (with ``--stage``) -- commits carry both trees.
* ``--check`` in CI / manual verification -- exit non-zero on drift,
change nothing.
-Per file pair (same relative path in both trees) the decision mirrors the
-MD engine exactly:
-
- * same content -> nothing to do.
- * exactly one side changed vs HEAD -> the other side follows (creation,
- rewrite, and deletion all propagate).
- * both changed vs HEAD and differ -> genuine conflict: that pair is left
- untouched and reported, exit 2.
- Clean pairs are still synced.
- * neither changed vs HEAD but differ -> pre-existing drift: ``.claude/`` is
- the canonical tie-breaker — except
- when one side simply does not exist
- yet (no working copy, no HEAD
- baseline): then the existing side is
- the source, so a brand-new file on
- either side is never destroyed.
+Per file pair (same relative path in both trees), the ``.agents/`` content
+wins. Creation, edits, and deletion of a source file propagate to ``.claude/``.
Privacy guard: any path that git ignores on EITHER side (e.g. the private
``.claude/skills/security-github/``) is excluded from the mirror entirely —
the sync must never copy a deliberately-untracked file into a tracked tree.
-``--stage`` additionally re-stages both members of every pair that already has
-staged changes on at least one side, so a commit can never carry a half-synced
-pair (the MD engine gets this for free by always adding both files).
+``--stage`` stages both members only when a pair was already staged.
stdlib-only; resolves the repo root via ``git rev-parse`` so it works in
linked worktrees too. Cheap no-op on the common path (trees equal).
"""
+
from __future__ import annotations
import argparse
@@ -56,11 +34,9 @@ CLAUDE_ROOT = ".claude"
AGENTS_ROOT = ".agents"
SYNC_SUBDIRS = ("agents", "commands", "skills")
-# Exit codes: 0 = in sync (or synced), 1 = drift found in --check mode,
-# 2 = unresolvable conflict (both sides edited differently), 3 = setup error.
+# Exit codes: 0 = in sync (or synced), 1 = drift found, 3 = setup error.
EXIT_OK = 0
EXIT_DRIFT = 1
-EXIT_CONFLICT = 2
EXIT_SETUP = 3
@@ -69,9 +45,7 @@ def _git(*args: str, repo: Path, stdin: bytes | None = None) -> subprocess.Compl
def _repo_root() -> Path | None:
- proc = subprocess.run(
- ["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True
- )
+ proc = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True)
if proc.returncode != 0:
return None
return Path(proc.stdout.strip())
@@ -91,41 +65,21 @@ def _norm(data: bytes | None) -> bytes | None:
return data.replace(b"\r\n", b"\n").replace(b"\r", b"\n")
-def _in_head(posix_path: str, repo: Path) -> bool:
- return _git("cat-file", "-e", f"HEAD:{posix_path}", repo=repo).returncode == 0
-
-
-def _changed_vs_head(posix_path: str, repo: Path, working: bytes | None) -> bool:
- """Has this path's content changed vs its committed HEAD version?
-
- "changed" means "present in HEAD AND its text differs from the HEAD blob"
- (a deleted-in-worktree tracked file therefore counts as changed). A path
- with no HEAD version has no committed baseline to have diverged from, so
- it is never "changed" — same rule as the MD engine.
- """
- show = _git("cat-file", "-p", f"HEAD:{posix_path}", repo=repo)
- if show.returncode != 0:
- return False # not in HEAD -> no committed baseline
- return _norm(working) != _norm(show.stdout)
-
-
def _collect_relpaths(repo: Path) -> set[str]:
"""Union of file relpaths (posix, relative to the tree root) in scope.
- Includes index-tracked paths as well as on-disk files, so a pair whose
- working copies were BOTH already deleted still gets its staged deletion
- completed on the twin side.
+ Includes source files and index-tracked paths. An untracked local Claude
+ definition with no shared source must never be removed by this projection.
"""
rels: set[str] = set()
scope = [f"{root}/{sub}" for root in (CLAUDE_ROOT, AGENTS_ROOT) for sub in SYNC_SUBDIRS]
- for root_name in (CLAUDE_ROOT, AGENTS_ROOT):
- for sub in SYNC_SUBDIRS:
- base = repo / root_name / sub
- if not base.is_dir():
- continue
- for f in base.rglob("*"):
- if f.is_file():
- rels.add(f.relative_to(repo / root_name).as_posix())
+ for sub in SYNC_SUBDIRS:
+ base = repo / AGENTS_ROOT / sub
+ if not base.is_dir():
+ continue
+ for f in base.rglob("*"):
+ if f.is_file():
+ rels.add(f.relative_to(repo / AGENTS_ROOT).as_posix())
tracked = _git("ls-files", "-z", "--", *scope, repo=repo)
if tracked.returncode == 0:
for raw in tracked.stdout.split(b"\x00"):
@@ -135,7 +89,7 @@ def _collect_relpaths(repo: Path) -> set[str]:
for root_name in (CLAUDE_ROOT, AGENTS_ROOT):
prefix = f"{root_name}/"
if path.startswith(prefix):
- rels.add(path[len(prefix):])
+ rels.add(path[len(prefix) :])
return rels
@@ -144,7 +98,10 @@ def _ignored_paths(repo: Path, candidates: list[str]) -> set[str]:
if not candidates:
return set()
proc = _git(
- "check-ignore", "-z", "--stdin", repo=repo,
+ "check-ignore",
+ "-z",
+ "--stdin",
+ repo=repo,
stdin=b"\x00".join(c.encode("utf-8") for c in candidates) + b"\x00",
)
# rc 0 = some ignored, 1 = none ignored, anything else = setup trouble
@@ -159,31 +116,11 @@ def _ignored_paths(repo: Path, candidates: list[str]) -> set[str]:
def _decide_source(
claude: bytes | None,
agents: bytes | None,
- claude_changed: bool,
- agents_changed: bool,
) -> tuple[str, bytes | None] | None:
- """Return (target_root, content_to_write) or None if already in sync.
-
- ``content_to_write`` of None means "delete the target". Raises ValueError
- on an unresolvable conflict.
- """
+ """Return the Claude copy to update, or None when it already matches."""
if _norm(claude) == _norm(agents):
return None
-
- if claude_changed and agents_changed:
- raise ValueError("both sides were changed and now differ")
-
- if agents_changed and not claude_changed:
- return (CLAUDE_ROOT, agents)
- if claude_changed and not agents_changed:
- return (AGENTS_ROOT, claude)
-
- # Neither side changed vs HEAD. A side that does not exist at all (and,
- # being unchanged, has no HEAD baseline either) is simply not born yet:
- # the existing side is the source. Otherwise .claude/ is canonical.
- if claude is None:
- return (CLAUDE_ROOT, agents)
- return (AGENTS_ROOT, claude)
+ return (CLAUDE_ROOT, agents)
def _write_target(repo: Path, target_root: str, rel: str, content: bytes | None) -> None:
@@ -203,8 +140,14 @@ def _write_target(repo: Path, target_root: str, rel: str, content: bytes | None)
def _staged_paths(repo: Path) -> set[str]:
proc = _git(
- "diff", "--cached", "--name-only", "-z", "--",
- CLAUDE_ROOT, AGENTS_ROOT, repo=repo,
+ "diff",
+ "--cached",
+ "--name-only",
+ "-z",
+ "--",
+ CLAUDE_ROOT,
+ AGENTS_ROOT,
+ repo=repo,
)
if proc.returncode != 0:
return set()
@@ -253,7 +196,6 @@ def main(argv: list[str] | None = None) -> int:
both_sides = [f"{root}/{rel}" for rel in rels for root in (CLAUDE_ROOT, AGENTS_ROOT)]
ignored = _ignored_paths(repo, both_sides)
- conflicts: list[str] = []
drifted: list[tuple[str, str, bytes | None]] = [] # (rel, target_root, content)
for rel in rels:
@@ -264,16 +206,7 @@ def main(argv: list[str] | None = None) -> int:
claude = _read_bytes(repo / CLAUDE_ROOT / rel)
agents = _read_bytes(repo / AGENTS_ROOT / rel)
- try:
- decision = _decide_source(
- claude,
- agents,
- _changed_vs_head(claude_posix, repo, claude),
- _changed_vs_head(agents_posix, repo, agents),
- )
- except ValueError:
- conflicts.append(rel)
- continue
+ decision = _decide_source(claude, agents)
if decision is not None:
target_root, content = decision
drifted.append((rel, target_root, content))
@@ -283,10 +216,6 @@ def main(argv: list[str] | None = None) -> int:
sys.stderr.write(
f"sync_agents_dir: DRIFT -- {rel} (would rewrite {target_root}/{rel}).\n"
)
- for rel in conflicts:
- sys.stderr.write(f"sync_agents_dir: CONFLICT -- {rel} (both sides edited).\n")
- if conflicts:
- return EXIT_CONFLICT
if drifted:
return EXIT_DRIFT
if not args.quiet:
@@ -296,7 +225,8 @@ def main(argv: list[str] | None = None) -> int:
for rel, target_root, content in drifted:
_write_target(repo, target_root, rel, content)
verb = "deleted" if content is None else "rewrote"
- print(f"sync_agents_dir: {verb} {target_root}/{rel} to match its twin.")
+ if not args.quiet:
+ print(f"sync_agents_dir: {verb} {target_root}/{rel} from .agents/.")
if args.stage:
# Only pairs with staged involvement are (re-)staged: a live working-
@@ -312,14 +242,6 @@ def main(argv: list[str] | None = None) -> int:
sys.stderr.write(f"sync_agents_dir: 'git add' failed for pair {rel}.\n")
return EXIT_SETUP
- if conflicts:
- for rel in conflicts:
- sys.stderr.write(
- f"sync_agents_dir: CONFLICT -- {rel} was changed on both sides and "
- "now differs; reconcile by hand, then retry.\n"
- )
- return EXIT_CONFLICT
-
if not drifted and not args.quiet:
print("sync_agents_dir: .claude/ and .agents/ already in sync.")
return EXIT_OK
diff --git a/scripts/ci/sync_agents_md.py b/scripts/ci/sync_agents_md.py
index 5df052ef01..b7efa08f4e 100644
--- a/scripts/ci/sync_agents_md.py
+++ b/scripts/ci/sync_agents_md.py
@@ -1,44 +1,26 @@
#!/usr/bin/env python3
-"""Keep ``AGENTS.md`` and ``CLAUDE.md`` carrying the same content.
+"""Copy the shared ``AGENTS.md`` instructions to Claude's compatibility file.
-The two files are intentional twins: ``CLAUDE.md`` is the long-standing agent
-contract for this repo, and ``AGENTS.md`` is the cross-tool standard name that
-other coding agents look for. The maintainer wants them to always hold the
-*exact same content* -- edit one and the other follows, in either direction.
+``AGENTS.md`` is authoritative. ``CLAUDE.md`` remains byte-identical because
+Claude Code's AGENTS.md support is conditional and older releases need it.
This script is the single sync engine, used from three places:
* ``.githooks/pre-commit`` (with ``--stage``) -- the hard guarantee: every
- commit lands both files in sync, regardless of who edited them (Claude, the
- maintainer, a parallel session, a plain editor).
- * the Claude Code ``PostToolUse`` hook -- live mirroring while an
- edit happens, so the working tree is already in sync before any commit.
+ commit lands both files in sync.
* ``--check`` in CI / manual verification -- exit non-zero on drift,
change nothing.
-Sync direction ("and the other way around"):
-
- * same content -> nothing to do.
- * exactly one changed vs HEAD -> the unchanged file is rewritten to
- match the changed one (true bidirec-
- tional follow).
- * both changed vs HEAD and differ -> genuine conflict: STOP, change
- nothing, exit 2. No silent clobber.
- * neither changed vs HEAD but differ -> pre-existing drift: CLAUDE.md is the
- canonical tie-breaker; AGENTS.md is
- rewritten to match it.
-
-Line-ending discipline (this repo runs ``core.autocrlf=true`` and CLAUDE.md is
-NOT pinned in .gitattributes): "changed vs HEAD" is answered by git itself
-(``git diff --quiet HEAD``), so a pure CRLF/LF skew between the working tree and
-the HEAD blob never looks like an edit. The content-equality check normalises
-line endings, because "the same stuff" means the same text, not the same
-invisible CR bytes. When a real sync happens, the target is written with the
-*exact* bytes of the source, so the two files end up byte-identical in the tree.
+Any difference is fixed by copying ``AGENTS.md`` to ``CLAUDE.md``. A missing
+source is a setup error, not a reason to replace it with the generated copy.
+
+Line endings are normalized for comparison because Git may check out CRLF on
+Windows. When a real sync happens, exact source bytes are written to the copy.
stdlib-only; resolves the repo root via ``git rev-parse`` so it works in linked
worktrees too. Designed to be a cheap no-op on the common path (files equal).
"""
+
from __future__ import annotations
import argparse
@@ -49,11 +31,9 @@ from pathlib import Path
CLAUDE_NAME = "CLAUDE.md"
AGENTS_NAME = "AGENTS.md"
-# Exit codes: 0 = in sync (or synced), 1 = drift found in --check mode,
-# 2 = unresolvable conflict (both sides edited differently), 3 = setup error.
+# Exit codes: 0 = in sync (or synced), 1 = drift found, 3 = setup error.
EXIT_OK = 0
EXIT_DRIFT = 1
-EXIT_CONFLICT = 2
EXIT_SETUP = 3
@@ -62,9 +42,7 @@ def _git(*args: str, repo: Path) -> subprocess.CompletedProcess[bytes]:
def _repo_root() -> Path | None:
- proc = subprocess.run(
- ["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True
- )
+ proc = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True)
if proc.returncode != 0:
return None
return Path(proc.stdout.strip())
@@ -84,54 +62,32 @@ def _norm(data: bytes | None) -> bytes | None:
return data.replace(b"\r\n", b"\n").replace(b"\r", b"\n")
-def _changed_vs_head(name: str, repo: Path, working: bytes | None) -> bool:
- """Has ``name``'s content changed vs its committed HEAD version?
-
- "changed" means "tracked AND its text differs from the HEAD blob". A file
- with no HEAD version (untracked / brand-new) has no committed baseline to
- have diverged *from*, so it is NOT "changed" -- it can therefore never be
- one half of a conflict, and CLAUDE.md (the canonical file, which does have
- history) wins instead.
-
- The comparison is done on line-ending-normalised content rather than via
- ``git diff``, so it is fully deterministic regardless of how the HEAD blob
- happens to be stored (this repo runs ``core.autocrlf=true`` and CLAUDE.md's
- blob still carries legacy CRLF) -- a pure CRLF/LF skew is never an "edit".
- """
- show = _git("cat-file", "-p", f"HEAD:{name}", repo=repo)
- if show.returncode != 0:
- return False # untracked / not in HEAD -> no committed baseline
- return _norm(working) != _norm(show.stdout)
-
-
def _decide_source(
claude: bytes | None,
agents: bytes | None,
- claude_changed: bool,
- agents_changed: bool,
) -> tuple[str, bytes] | None:
- """Return (target_name, content_to_write) or None if already in sync.
-
- Raises ValueError on an unresolvable conflict.
- """
+ """Return the Claude copy to update, or None when it already matches."""
if _norm(claude) == _norm(agents):
- return None # same content (covers both-missing -> handled by caller)
-
- if claude_changed and agents_changed:
- # Both edited away from their committed state, and they differ. We must
- # not guess which wins -- that would silently destroy one side's edit.
- raise ValueError(
- "both CLAUDE.md and AGENTS.md were changed and now differ; "
- "reconcile them by hand, then re-stage."
- )
+ return None
+ return (CLAUDE_NAME, agents if agents is not None else b"")
+
+
+def _pair_staged(repo: Path) -> bool:
+ staged = _git(
+ "diff",
+ "--cached",
+ "--name-only",
+ "-z",
+ "--",
+ AGENTS_NAME,
+ CLAUDE_NAME,
+ repo=repo,
+ )
+ return staged.returncode == 0 and bool(staged.stdout)
- if agents_changed and not claude_changed:
- # AGENTS.md is the freshly edited side -> CLAUDE.md follows it.
- return (CLAUDE_NAME, agents if agents is not None else b"")
- # CLAUDE.md is the edited side, OR neither changed but they drifted
- # (CLAUDE.md is the canonical tie-breaker) -> AGENTS.md follows CLAUDE.md.
- return (AGENTS_NAME, claude if claude is not None else b"")
+def _stage_pair(repo: Path) -> bool:
+ return _git("add", "--", AGENTS_NAME, CLAUDE_NAME, repo=repo).returncode == 0
def main(argv: list[str] | None = None) -> int:
@@ -164,24 +120,16 @@ def main(argv: list[str] | None = None) -> int:
claude = _read_bytes(claude_path)
agents = _read_bytes(agents_path)
- if claude is None and agents is None:
- sys.stderr.write(
- f"sync_agents_md: neither {CLAUDE_NAME} nor {AGENTS_NAME} exists.\n"
- )
+ if agents is None:
+ sys.stderr.write(f"sync_agents_md: missing source {AGENTS_NAME}.\n")
return EXIT_SETUP
- try:
- decision = _decide_source(
- claude,
- agents,
- _changed_vs_head(CLAUDE_NAME, repo, claude),
- _changed_vs_head(AGENTS_NAME, repo, agents),
- )
- except ValueError as exc:
- sys.stderr.write(f"sync_agents_md: CONFLICT -- {exc}\n")
- return EXIT_CONFLICT
+ decision = _decide_source(claude, agents)
if decision is None:
+ if args.stage and _pair_staged(repo) and not _stage_pair(repo):
+ sys.stderr.write("sync_agents_md: 'git add' failed.\n")
+ return EXIT_SETUP
if not args.quiet:
print(f"sync_agents_md: {CLAUDE_NAME} and {AGENTS_NAME} already in sync.")
return EXIT_OK
@@ -196,15 +144,12 @@ def main(argv: list[str] | None = None) -> int:
return EXIT_DRIFT
(repo / target_name).write_bytes(content)
- print(f"sync_agents_md: rewrote {target_name} to match its twin.")
-
- if args.stage:
- add = _git("add", "--", CLAUDE_NAME, AGENTS_NAME, repo=repo)
- if add.returncode != 0:
- sys.stderr.write(
- "sync_agents_md: 'git add' failed:\n"
- + add.stderr.decode("utf-8", "replace")
- )
+ if not args.quiet:
+ print(f"sync_agents_md: rewrote {target_name} from {AGENTS_NAME}.")
+
+ if args.stage and _pair_staged(repo):
+ if not _stage_pair(repo):
+ sys.stderr.write("sync_agents_md: 'git add' failed.\n")
return EXIT_SETUP
return EXIT_OK
diff --git a/scripts/ci/sync_codex_agents.py b/scripts/ci/sync_codex_agents.py
index ba4ddd846e..a70d34c339 100644
--- a/scripts/ci/sync_codex_agents.py
+++ b/scripts/ci/sync_codex_agents.py
@@ -1,10 +1,10 @@
#!/usr/bin/env python3
-"""Project the ``.claude/agents/`` definitions into the ``.codex/agents/`` twin.
+"""Project shared agent definitions into Codex's required TOML format.
The repo carries THREE copies of the same agent knowledge:
-* ``.claude/agents/*.md`` — canonical, YAML front matter + Markdown body.
-* ``.agents/agents/*.md`` — byte-identical twin, kept by ``sync_agents_dir.py``.
+* ``.agents/agents/*.md`` — canonical, YAML front matter + Markdown body.
+* ``.claude/agents/*.md`` — compatibility copy, kept by ``sync_agents_dir.py``.
* ``.codex/agents/*.toml`` — the same agents in the shape Codex reads.
The first two were synced by a script from the day they existed; the third was
@@ -13,7 +13,7 @@ maintained by hand and drifted silently for months — by 2026-08-20 its
a plan file that no longer exists, while its Markdown twin had moved on. A
mirror nothing verifies is not a mirror. This script closes that gap.
-Direction is one-way on purpose: ``.claude/`` is canonical, ``.codex/`` is a
+Direction is one-way on purpose: ``.agents/`` is canonical, ``.codex/`` is a
projection. Editing a ``.toml`` by hand is not supported — the next run
overwrites it, and ``--check`` fails the build until the Markdown side carries
the change instead.
@@ -43,7 +43,7 @@ import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[2]
-SOURCE_DIR = REPO_ROOT / ".claude" / "agents"
+SOURCE_DIR = REPO_ROOT / ".agents" / "agents"
TARGET_DIR = REPO_ROOT / ".codex" / "agents"
# ``INDEX.md`` is a human-facing catalogue of the other files, not an agent
@@ -120,24 +120,47 @@ def render_toml(name: str, description: str, body: str) -> str:
)
-def git_add(paths: list[Path]) -> None:
+def git_add(paths: list[Path]) -> bool:
"""Stage exactly the files this script touched.
Scoped to explicit paths on purpose: the working tree is frequently shared
with other agent sessions, and a broad ``git add`` sweeps their in-flight
- work into someone else's commit (CLAUDE.md §9).
+ work into someone else's commit (AGENTS.md §1).
"""
if not paths:
- return
+ return True
try:
- subprocess.run(
+ result = subprocess.run(
["git", "add", "--", *(str(p) for p in paths)],
cwd=REPO_ROOT,
check=False,
capture_output=True,
)
except OSError:
- pass # no git on PATH: the projection is still written, just not staged
+ return False
+ return result.returncode == 0
+
+
+def staged_agent_stems() -> set[str]:
+ """Find source or projection paths already staged in this commit."""
+ proc = subprocess.run(
+ [
+ "git",
+ "diff",
+ "--cached",
+ "--name-only",
+ "-z",
+ "--",
+ ".agents/agents",
+ ".codex/agents",
+ ],
+ cwd=REPO_ROOT,
+ capture_output=True,
+ check=False,
+ )
+ if proc.returncode != 0:
+ return set()
+ return {Path(path.decode("utf-8")).stem for path in proc.stdout.split(b"\0") if path}
def project(check_only: bool, stage: bool = False, quiet: bool = False) -> int:
@@ -186,7 +209,7 @@ def project(check_only: bool, stage: bool = False, quiet: bool = False) -> int:
print(f"sync_codex_agents: ORPHANED .codex/agents/{name}")
print(
"\nThe Codex mirror is out of date. Edit the Markdown side under "
- ".claude/agents/, then run:\n"
+ ".agents/agents/, then run:\n"
" python scripts/ci/sync_codex_agents.py",
file=sys.stderr,
)
@@ -202,9 +225,12 @@ def project(check_only: bool, stage: bool = False, quiet: bool = False) -> int:
say(f"sync_codex_agents: {len(expected)} agents already in sync.")
if stage:
- touched = [TARGET_DIR / n for n in stale]
- touched += [TARGET_DIR / n for n in orphaned]
- git_add(touched)
+ involved = staged_agent_stems()
+ touched = [path for path in expected if path.stem in involved]
+ touched += [TARGET_DIR / n for n in orphaned if Path(n).stem in involved]
+ if not git_add(touched):
+ print("sync_codex_agents: 'git add' failed", file=sys.stderr)
+ return 1
return 0
diff --git a/tests/unit/ci/test_agent_projection.py b/tests/unit/ci/test_agent_projection.py
new file mode 100644
index 0000000000..fafd8434bd
--- /dev/null
+++ b/tests/unit/ci/test_agent_projection.py
@@ -0,0 +1,126 @@
+"""Verify that shared agent sources produce complete staged compatibility files."""
+
+from __future__ import annotations
+
+import subprocess
+from pathlib import Path
+
+from scripts.ci import sync_agents_dir, sync_agents_md, sync_codex_agents
+
+
+def _git(repo: Path, *args: str) -> bytes:
+ result = subprocess.run(
+ ["git", "-C", str(repo), *args],
+ capture_output=True,
+ check=True,
+ )
+ return result.stdout
+
+
+def _set_roots(monkeypatch, repo: Path) -> None:
+ monkeypatch.setattr(sync_agents_md, "_repo_root", lambda: repo)
+ monkeypatch.setattr(sync_agents_dir, "_repo_root", lambda: repo)
+ monkeypatch.setattr(sync_codex_agents, "REPO_ROOT", repo)
+ monkeypatch.setattr(sync_codex_agents, "SOURCE_DIR", repo / ".agents" / "agents")
+ monkeypatch.setattr(sync_codex_agents, "TARGET_DIR", repo / ".codex" / "agents")
+
+
+def test_shared_sources_generate_and_stage_compatibility_files(tmp_path, monkeypatch):
+ _git(tmp_path, "init", "-q")
+ _set_roots(monkeypatch, tmp_path)
+ (tmp_path / "AGENTS.md").write_text("shared rules\n", encoding="utf-8")
+ (tmp_path / "CLAUDE.md").write_text("stale rules\n", encoding="utf-8")
+ source = tmp_path / ".agents" / "agents" / "reviewer.md"
+ source.parent.mkdir(parents=True)
+ source.write_text(
+ "---\nname: reviewer\ndescription: Reviews code\n---\n\nReview carefully.\n",
+ encoding="utf-8",
+ )
+ _git(tmp_path, "add", "--", "AGENTS.md", ".agents/agents/reviewer.md")
+
+ assert sync_agents_md.main(["--check", "--quiet"]) == 1
+ assert sync_agents_dir.main(["--check", "--quiet"]) == 1
+ assert sync_codex_agents.project(check_only=True, quiet=True) == 1
+
+ assert sync_agents_md.main(["--stage", "--quiet"]) == 0
+ assert sync_agents_dir.main(["--stage", "--quiet"]) == 0
+ assert sync_codex_agents.project(check_only=False, stage=True, quiet=True) == 0
+
+ assert (tmp_path / "CLAUDE.md").read_bytes() == (tmp_path / "AGENTS.md").read_bytes()
+ assert (tmp_path / ".claude" / "agents" / "reviewer.md").read_bytes() == source.read_bytes()
+ assert "Review carefully." in (tmp_path / ".codex" / "agents" / "reviewer.toml").read_text(
+ encoding="utf-8"
+ )
+ staged = set(_git(tmp_path, "diff", "--cached", "--name-only").decode().splitlines())
+ assert staged == {
+ "AGENTS.md",
+ "CLAUDE.md",
+ ".agents/agents/reviewer.md",
+ ".claude/agents/reviewer.md",
+ ".codex/agents/reviewer.toml",
+ }
+
+
+def test_deleted_source_removes_claude_copy(tmp_path, monkeypatch):
+ _git(tmp_path, "init", "-q")
+ _set_roots(monkeypatch, tmp_path)
+ source = tmp_path / ".agents" / "agents" / "reviewer.md"
+ target = tmp_path / ".claude" / "agents" / "reviewer.md"
+ source.parent.mkdir(parents=True)
+ target.parent.mkdir(parents=True)
+ source.write_text("old definition\n", encoding="utf-8")
+ target.write_text("old definition\n", encoding="utf-8")
+ _git(tmp_path, "add", "--", ".agents/agents/reviewer.md", ".claude/agents/reviewer.md")
+ source.unlink()
+ _git(tmp_path, "add", "--", ".agents/agents/reviewer.md")
+
+ assert sync_agents_dir.main(["--check", "--quiet"]) == 1
+ assert sync_agents_dir.main(["--stage", "--quiet"]) == 0
+ assert not target.exists()
+ assert b".claude/agents/reviewer.md" not in _git(tmp_path, "ls-files", "--cached")
+
+
+def test_matching_copies_are_staged_with_the_source(tmp_path, monkeypatch):
+ _git(tmp_path, "init", "-q")
+ _set_roots(monkeypatch, tmp_path)
+ rules = "shared rules\n"
+ (tmp_path / "AGENTS.md").write_text(rules, encoding="utf-8")
+ (tmp_path / "CLAUDE.md").write_text(rules, encoding="utf-8")
+ source = tmp_path / ".agents" / "agents" / "reviewer.md"
+ target = tmp_path / ".claude" / "agents" / "reviewer.md"
+ source.parent.mkdir(parents=True)
+ target.parent.mkdir(parents=True)
+ definition = "---\nname: reviewer\ndescription: Reviews code\n---\nReview carefully.\n"
+ source.write_text(definition, encoding="utf-8")
+ target.write_text(definition, encoding="utf-8")
+ codex_target = tmp_path / ".codex" / "agents" / "reviewer.toml"
+ codex_target.parent.mkdir(parents=True)
+ fields, body = sync_codex_agents.split_front_matter(definition, source)
+ codex_target.write_text(
+ sync_codex_agents.render_toml(fields["name"], fields["description"], body),
+ encoding="utf-8",
+ )
+ _git(tmp_path, "add", "--", "AGENTS.md", ".agents/agents/reviewer.md")
+
+ assert sync_agents_md.main(["--stage", "--quiet"]) == 0
+ assert sync_agents_dir.main(["--stage", "--quiet"]) == 0
+ assert sync_codex_agents.project(check_only=False, stage=True, quiet=True) == 0
+ staged = set(_git(tmp_path, "diff", "--cached", "--name-only").decode().splitlines())
+ assert staged == {
+ "AGENTS.md",
+ "CLAUDE.md",
+ ".agents/agents/reviewer.md",
+ ".claude/agents/reviewer.md",
+ ".codex/agents/reviewer.toml",
+ }
+
+
+def test_untracked_claude_agent_without_shared_source_is_preserved(tmp_path, monkeypatch):
+ _git(tmp_path, "init", "-q")
+ _set_roots(monkeypatch, tmp_path)
+ local_agent = tmp_path / ".claude" / "agents" / "personal.md"
+ local_agent.parent.mkdir(parents=True)
+ local_agent.write_text("local only\n", encoding="utf-8")
+
+ assert sync_agents_dir.main(["--stage", "--quiet"]) == 0
+ assert local_agent.read_text(encoding="utf-8") == "local only\n"