-
Notifications
You must be signed in to change notification settings - Fork 1
Sync Claude and Codex skills & subagents #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| --- | ||
| name: manage-agent-config | ||
| description: Use whenever creating, editing, renaming, or deleting any file under .claude/skills/, .claude/agents/, .agents/skills/, or .codex/agents/. Teaches the dual-tool Claude/Codex layout and reminds to run `make sync-agent-config`. | ||
| --- | ||
|
|
||
| # Managing Claude ↔ Codex skills and subagents in this repo | ||
|
|
||
| This repo is dual-tool. Before you create or edit anything under `.claude/`, `.agents/`, or `.codex/`, read this and the detailed rule at `.claude/rules/codex-claude-sync.md`. | ||
|
|
||
| ## Decision tree | ||
|
|
||
| **Creating a new skill?** | ||
|
|
||
| 1. Does it need Claude-only features (`allowed-tools`, `$ARGUMENTS`, `` !`shell` `` preprocessing, `${CLAUDE_SKILL_DIR}`)? | ||
| - **Yes** → `.claude/skills/<name>/SKILL.md` (real directory, no symlink). Claude-only. | ||
| - **No** → `.agents/skills/<name>/SKILL.md`. Shared; `make sync-agent-config` creates the `.claude/skills/<name>` symlink. | ||
|
|
||
| **Creating a new subagent?** | ||
|
|
||
| - Always edit `.claude/agents/<name>.md` (markdown + YAML frontmatter). That is the source of truth. | ||
| - `.codex/agents/<name>.toml` is **generated** - never hand-edit. | ||
| - Run `make sync-agent-config` - the TOML appears. | ||
|
|
||
| **Renaming or deleting?** | ||
|
|
||
| - Rename or delete the source file (under `.agents/skills/` or `.claude/agents/`). | ||
| - Run `make sync-agent-config` - stale symlinks and orphaned TOMLs are pruned automatically. | ||
|
|
||
| ## Frontmatter rules for shared skills | ||
|
|
||
| `.agents/skills/<name>/SKILL.md` must only use: | ||
|
|
||
| - `name` (required, lowercase-hyphens, ≤64 chars) | ||
| - `description` (required, ≤250 chars - Codex and Claude use this for implicit matching) | ||
| - Plain markdown body | ||
|
|
||
| Do **not** use any of these in a shared skill: | ||
|
|
||
| - `allowed-tools`, `disable-model-invocation`, `user-invocable`, `context`, `agent`, `model`, `effort`, `hooks`, `paths`, `shell`, `argument-hint` | ||
| - `$ARGUMENTS`, `$1`…`$N`, `${CLAUDE_SKILL_DIR}`, `${CLAUDE_SESSION_ID}` substitutions | ||
| - `` !`cmd` `` or ```` ```! ```` shell preprocessing blocks | ||
|
|
||
| All of those are Claude-only. In Codex they pass through literally and confuse the model. If you need them, make the skill Claude-only (see decision tree above). | ||
|
|
||
| ## Subagent format notes | ||
|
|
||
| Claude `.md` frontmatter keys that don't exist in Codex (`tools`, `model`, `color`) are preserved as TOML comments in the generated `.codex/agents/<name>.toml` for human reference. They do not affect Codex behavior. If tool restrictions matter to the agent's job, describe them in the prose body so both tools read them. | ||
|
|
||
| ## After any change | ||
|
|
||
| Always run `make sync-agent-config`. The prek pre-commit hook will block the commit otherwise. The script is idempotent and silent when there's nothing to do. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| --- | ||
| paths: | ||
| - ".claude/skills/**" | ||
| - ".claude/agents/**" | ||
| - ".agents/skills/**" | ||
| - ".codex/agents/**" | ||
| --- | ||
|
|
||
| # Codex ↔ Claude skill & subagent sync | ||
|
|
||
| This repo is dual-tool: both Claude Code and Codex CLI are expected to work. Skills and subagents are shared where possible. Read this before creating, editing, or moving any skill or subagent in this repo. | ||
|
|
||
| ## Layout | ||
|
|
||
| ``` | ||
| .agents/skills/<name>/SKILL.md # single source - both tools auto-discover | ||
| .claude/skills/<name> # symlink -> ../../.agents/skills/<name> | ||
| .claude/agents/<name>.md # source of truth (markdown + YAML frontmatter) | ||
| .codex/agents/<name>.toml # GENERATED from the .md; commit it | ||
| scripts/sync_agent_config.py # converter (uv run) | ||
| ``` | ||
|
|
||
| Codex auto-scans `.agents/skills/` walking up from cwd to repo root. Claude auto-scans `.claude/skills/`. The symlink is the only reason both find the same file. | ||
|
|
||
| ## Skills: the shared-frontmatter rule | ||
|
|
||
| Every `SKILL.md` under `.agents/skills/` MUST be readable by both tools. The overlap is narrow - stick to it: | ||
|
|
||
| **Always safe (both tools):** | ||
| - `name` - required, lowercase-hyphens, ≤64 chars | ||
| - `description` - required, ≤250 chars, written for implicit matching | ||
| - Plain markdown body | ||
|
|
||
| **Claude-only - DO NOT use in shared skills:** | ||
| - `allowed-tools:` - Codex has no equivalent | ||
| - `context: fork`, `agent:`, `model:`, `effort:`, `hooks:`, `paths:`, `shell:`, `argument-hint`, `disable-model-invocation`, `user-invocable` | ||
| - `$ARGUMENTS`, `$1`, `$2`, ... - Claude substitutes these at runtime; Codex passes them through literally | ||
| - `` !`shell command` `` and ```` ```! ```` blocks - Claude preprocesses; Codex does not | ||
| - `${CLAUDE_SKILL_DIR}`, `${CLAUDE_SESSION_ID}` - Claude-only interpolations | ||
|
|
||
| **Codex-only - OK to include (Claude ignores unknown keys):** | ||
| - Sibling `agents/openai.yaml` for Codex UI metadata, invocation policy, tool dependencies | ||
|
|
||
| If a skill genuinely needs Claude-only features, keep it at `.claude/skills/<name>/` as a real directory (no symlink) and do not mirror it to `.agents/skills/`. Note this with a `<!-- claude-only -->` comment at the top of the body. | ||
|
|
||
| ## Subagents: convert, don't symlink | ||
|
|
||
| The formats are structurally different: | ||
| - Claude: `.claude/agents/<name>.md` - YAML frontmatter (`name`, `description`, `tools`, `model`) + markdown body as system prompt | ||
| - Codex: `.codex/agents/<name>.toml` - TOML with `name`, `description`, `developer_instructions = """..."""` (body as triple-quoted string) | ||
|
|
||
| Rules: | ||
| - `.claude/agents/*.md` is the **source of truth**. Never hand-edit `.codex/agents/*.toml`. | ||
| - Run `make sync-agent-config` after editing a subagent. The pre-commit hook will refuse the commit if the generated TOML is out of date. | ||
| - Claude-only frontmatter keys (`tools`, `model`) don't translate - document tool expectations in the prose body instead so both sides pick them up. | ||
| - Inside the body, avoid literal `"""` sequences (they'd close the TOML string); the converter escapes them but it's easier to just not use them. | ||
|
|
||
| ## Do not try to sync these | ||
|
|
||
| - `.claude/rules/*.md` vs `.codex/rules/*.rules` - different languages (prose vs permission DSL). Maintain separately. | ||
| - `.claude/commands/*.md` - Claude-only; Codex has no slash-command runtime. | ||
| - `CLAUDE.md` vs `AGENTS.md` - both auto-read by their respective tool; keep them as separate documents, though content may overlap. | ||
|
|
||
| ## Tooling | ||
|
|
||
| - `make sync-agent-config` - idempotent. Creates missing `.claude/skills/` symlinks for every shared skill under `.agents/skills/`, regenerates `.codex/agents/*.toml` from `.claude/agents/*.md`, auto-prunes dangling symlinks and orphan TOMLs silently. | ||
| - Pre-commit: [`prek`](https://prek.j178.dev/installation/), configured in `prek.toml` at repo root. Register once per clone with `prek install`. Runs `make sync-agent-config` then fails the commit if it produced drift. | ||
| - Python scripts in `scripts/` use `uv` and PEP 723 inline metadata for standalones. | ||
|
|
||
| ## When adding a new skill or subagent | ||
|
|
||
| The `manage-agent-config` skill (at `.agents/skills/manage-agent-config/`) has the full decision tree and is invoked automatically when an agent touches any of these directories. The short version: | ||
|
|
||
| 1. Shared skill (works in both tools) → `.agents/skills/<name>/SKILL.md`. Run `make sync-agent-config`. | ||
| 2. Claude-only skill (uses `$ARGUMENTS`, `allowed-tools`, etc.) → `.claude/skills/<name>/SKILL.md` as a real directory. No symlink. | ||
| 3. Subagent → edit `.claude/agents/<name>.md`. Never hand-edit `.codex/agents/*.toml`. Run `make sync-agent-config`. Commit both files. | ||
| 4. Delete or rename → edit/remove the source, then `make sync-agent-config` cleans up the mirror. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../.agents/skills/manage-agent-config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.