{"slug": "stop-duplicating-your-claude-code-and-codex-configurations", "title": "Stop Duplicating Your Claude Code and Codex Configurations", "summary": "A developer built agent-shared, an open-source tool (v0.3.0) that deploys a single set of skills, rules and hooks to multiple coding agents instead of maintaining duplicate configs. The tool symlinks skill directories into each agent's expected location, writes shared rules into Claude Code's individual rule files and managed blocks in Codex's AGENTS.md and Copilot's instructions file, and adds hook declarations to each agent's settings. The author tested personal-scope filesystem and CLI behavior on macOS with Python 3.15.2 and uv 0.9.7, noting that repository-scope checks passed but personal-scope fresh-session loading and runtime hook execution were not run.", "body_md": "Claude Code looks for personal skills in `~/.claude/skills`; Codex uses `~/.agents/skills`. If you use both, there's no need to keep a separate copy of every skill. Both directories can contain a symlink to the same skill directory.\n\nAI assistance generated this article and its diagrams. The author reviewed the claims, commands, and final text.\n\nRules are trickier. Claude Code reads individual Markdown files, whereas Codex reads instructions from `AGENTS.md`. Hooks need separate treatment because the two agents don't support exactly the same events.\n\nI built [agent-shared](https://github.com/cardene777/agent-shared) to handle these differences without maintaining separate configurations for every agent. It links skill directories, writes shared rules into the appropriate files, and adds hook declarations to each agent's configuration. The examples use v0.3.0 and distinguish what the tool writes from what the agent actually does.\n\nOn November 26, 2026, I tested personal-scope filesystem and CLI behavior with agent-shared 0.3.0 at the pinned commit. The checks passed and matched this article.\n\nThe test used macOS (Darwin arm64), Python 3.15.2, uv 0.9.7, a temporary `HOME`, and `AGENT_SHARED_STATE`. Repository-scope checks, covering deployment and fresh-session loading, ran separately and passed; personal-scope fresh-session loading and runtime hook execution were not run.\n\nSuppose the shared review workflow consists of a skill, a rule requiring tests, and a hook attached to shell operations.\n\nWith separate copies, every change to the review skill or testing rule requires two edits. The hook may also need different event or settings syntax. Add a third agent and you have another destination to maintain, even if the review procedure itself stays the same.\n\nStale instructions are hard to spot. If you add a requirement to check the test's exit status in one copy but forget the other, both Markdown files still look valid. You might not notice the difference until you read the review results.\n\nInstead, keep one copy of the review procedure and let the deployment tool handle the differences between agents. Think of it as generating service configuration from a template, except that you can skip generation entirely when a symlink will do.\n\nCheck the files on disk after deployment, then open a fresh agent session to check what the agent actually loads. These tests answer different questions. A hook declaration in the right settings file does not prove that a prohibited tool call will be blocked.\n\nThe review skill describes how to perform a particular task: inspect a diff, trace the affected code, collect evidence, and report findings. A testing rule belongs outside that skill if it should also apply when the agent implements a feature. Even then, a rule is an instruction, not proof that any test ran.\n\nHooks work at a different level. Rather than asking the model to remember an instruction, a hook declares a command for the agent's runtime to execute at a particular event. A pre-tool-use hook can inspect a proposed call; a later event may expose its result. The available events, matchers, inputs, and decisions vary between runtimes. Identical hook JSON doesn't necessarily give you identical enforcement.\n\nThe agent table in v0.3.0 defines these destinations for personal configuration:\n\n| Component | Claude Code | Codex | GitHub Copilot CLI | \n|---|---|---|---|\n| Skill directory | ~/.claude/skills | ~/.agents/skills | Reads the shared agents skill directory | \n| Rules | Individual files in ~/.claude/rules | Managed block in ~/.codex/AGENTS.md | Managed block in ~/.copilot/copilot-instructions.md | \n| Hooks | ~/.claude/settings.json | ~/.codex/hooks.json | ~/.copilot/hooks/agent-shared.json | \n\nFor Copilot, agent-shared writes rules and hooks only if it finds `copilot` on `PATH`. Its agent table lists the events each agent supports and the versions against which the tool was checked. If a hook's event is missing from an agent's supported list, the tool skips that hook for that agent and reports the omission. An agent that reads the common skills directory doesn't necessarily have its own rules or hooks adapter.\n\nCopying the entire configuration directory would put the Claude Code rules in the wrong format for Codex. The source files are reusable; the destination layout is not.\n\nWhy not use symlinks for everything? A symlink can point to a file or directory, but it cannot insert the contents of several Markdown files into one existing `AGENTS.md` while leaving the instructions already in that file alone. That is why agent-shared uses two representations for rules. Linking avoids another copy where the destination supports it; a managed block lets the tool update only its own section where it does not. The cost is that Codex needs another deployment when a rule changes.\n\nFor this example, the personal source directory contains just one skill and one rule. The source has no credentials, project secrets, private prompts, or plugin trust settings.\n\n```\n~/.shared/\n├── skills/\n│   └── review-change/\n│       └── SKILL.md\n└── rules/\n    └── testing.md\n```\n\nNeither file needs to be tied to Claude Code or Codex. The `review-change` skill contains the review procedure; `testing.md` holds the testing convention both agents should follow.\n\nLeave API keys and provider credentials in a secret store. Keep model selection and permissions for private repositories in each agent's own configuration. Sharing a review skill shouldn't grant another agent access to a repository.\n\nBefore putting this directory in Git, decide which files are safe to commit. Markdown, small review scripts, and public examples can be reviewed like application code. Credentials and machine-specific absolute paths should not become Git history. If a script requires local configuration, give it a documented input rather than hard-coding a secret in the shared source.\n\nA preference for the format of review findings can live in your personal rules. The command that everyone must run before merging a change belongs in the repository. That way, another contributor can follow the project's workflow without inheriting your personal settings.\n\nYou'll need macOS or Linux, Python 3.11 or later, and `uv`. For the first run, use a disposable VM or container with no production credentials. Changing `HOME` alone is not a security boundary: deployment can modify agent configuration and invoke agent commands if they are installed.\n\nInstall the revision used in this article rather than whatever happens to be on the default branch today:\n\n```\nuv tool install \"git+https://github.com/cardene777/agent-shared@02fb752d62b72506ef7085d9623a8aa8d1612002\"\nagent-shared --version\n```\n\nExpect `agent-shared 0.3.0` from the version command. Inspect the pinned source before installing it. The Git installation needs network access, although `pyproject.toml` declares no third-party Python runtime dependencies.\n\nCreate the review skill and testing rule in a fresh lab home directory.\n\n```\nmkdir -p ~/.shared/skills/review-change ~/.shared/rules\n\ncat > ~/.shared/skills/review-change/SKILL.md <<'EOF'\n---\nname: review-change\ndescription: Review a proposed code change for defects and missing tests.\n---\n\n# Review a change\n\n1. Read the diff and the relevant surrounding code.\n2. Identify changed behavior and affected tests.\n3. Report findings with evidence and impact.\n4. State which checks could not be performed.\nEOF\n\ncat > ~/.shared/rules/testing.md <<'EOF'\n# Testing\n\nRun relevant tests after changing business logic.\nReport the command, result, and any checks that could not run.\nEOF\n```\n\nThe commands overwrite files of the same name, which is why they belong in a fresh environment. On your real machine, inspect existing files and merge the instructions deliberately.\n\nThe front matter of the skill identifies the skill and describes its intended use. The body defines the actual task. The testing rule is separate because it applies when implementing a change, not just when reviewing one.\n\nNow check the source without writing destination files.\n\n```\nagent-shared check --source ~/.shared\n```\n\n`check` can detect a skill with an invalid name or a hook declaration without a command. Exit status 0 means the source passed its structural checks. It says nothing about whether the review skill finds bugs.\n\nApply the configuration and inspect what was placed.\n\n```\nagent-shared deploy\nagent-shared placed --source ~/.shared\n```\n\n`placed` reports the entries from that source that are still present in the agent configurations. To check the filesystem directly, inspect the links and the generated rule block:\n\n```\nls -l ~/.claude/skills/review-change\nls -l ~/.agents/skills/review-change\nls -l ~/.claude/rules/testing.md\ncat ~/.codex/AGENTS.md\n```\n\nWith both agent destinations available and no conflicting plugin, expect three links and one generated rule block. The links cover each agent's skill plus the Claude Code rule, and Codex receives the block in `AGENTS.md`.\n\nIf a link is missing, check the deployment messages before creating it manually. agent-shared may skip a skill already supplied by a plugin or an agent below its checked minimum version. A newer or unreadable version produces a warning and doesn't stop placement on its own. In this walkthrough, Claude Code 2.1.332 was newer than the agent table's checked maximum of 2.1.330, so every deployment printed that warning and continued.\n\nThe repository-scope fresh-session result appears in the repository section below. Personal-scope runtime sessions remain unverified, so repeat the same check in a harmless test repository before relying on your personal setup.\n\nOnce the links are in place, change `testing.md` and read it through the link in Claude Code's configuration directory. The link points to the source file, so reading it should return the new text immediately.\n\nCodex is different: agent-shared copies the rule's text into a managed block in `AGENTS.md`. That block won't change until you run `deploy` again.\n\nAdd a new instruction to the source rule:\n\n```\nprintf '\\nInclude the exit status when reporting a test result.\\n' \\\n  >> ~/.shared/rules/testing.md\n```\n\nBefore running `deploy` again, read the two destinations. Expect the new sentence in the linked Claude Code rule but not in Codex's generated block.\n\n```\ncat ~/.claude/rules/testing.md\ncat ~/.codex/AGENTS.md\nagent-shared deploy\ncat ~/.codex/AGENTS.md\n```\n\nAfter deployment, the managed block should contain the updated rule. An active agent might cache instructions or require a new session, depending on its loader. Do not infer live reload support from the fact that a file changed.\n\nYou can reproduce the filesystem behavior without installing any agent. The following Python example creates one source file, a symbolic link, and a separate generated copy in a temporary directory. It changes the source and then tests the two different views.\n\n``` python\nimport tempfile\nfrom pathlib import Path\n\nwith tempfile.TemporaryDirectory() as folder:\n    root = Path(folder)\n    source = root / \"testing.md\"\n    link = root / \"linked.md\"\n    generated = root / \"AGENTS.md\"\n    source.write_text(\"Run tests.\\n\")\n    link.symlink_to(source)\n    generated.write_text(source.read_text())\n\n    source.write_text(\"Run tests.\\nReport exit status.\\n\")\n    assert link.read_text() == source.read_text()\n    assert \"Report exit status.\" not in generated.read_text()\n\n    generated.write_text(source.read_text())\n    assert generated.read_text() == source.read_text()\n```\n\nAll three assertions passed on Linux with Python 3.13.5. That verifies the filesystem behavior, but it doesn't test agent-shared's block generation or either agent's instruction loader. Those need separate checks.\n\nRollback works the same way: revert the source file and the link exposes the previous text. Run `deploy` to regenerate the Codex block. If the rollback also changes a hook or script, recheck its trust status and runtime behavior.\n\nHow does agent-shared know which lines in `AGENTS.md` belong to a particular source? It wraps its generated rules in markers that contain a source ID. The ID is the first 12 hexadecimal characters of the SHA-256 digest of the source's resolved path. Editing the rule leaves the ID unchanged; moving the source to a different location may require removing its old placements.\n\nThe distinction matters when updating a managed block. If the ID were a hash of the rule contents, editing the rule would change the ID before the next deployment could find the old block by that ID. A path-based ID lets the tool find the same source across edits. It is an ownership label, not a checksum of the files or proof that their contents are safe. Moving a source has the opposite trade-off: its old path may still identify placements that need cleaning up.\n\nFor example, a generated block uses the same ID in its opening and closing markers:\n\n``` php\n<!-- agent-shared begin source=0123456789ab -->\n<!-- agent-shared rule testing.md -->\n# Testing\nRun relevant tests.\n<!-- agent-shared end source=0123456789ab -->\n```\n\nThe ID in this example is illustrative. On redeployment, the markers tell the tool where its own block begins and ends, so it can update that block without replacing unrelated instructions. Symlinks can't carry markers in the same way, so agent-shared keeps a record of the links it created.\n\nEdit the source, not the generated block. A hand edit inside that block may disappear the next time you deploy.\n\nTo test hook placement, use a shell script that discards its input and exits with status 0. This is a fixture, not a security hook: it neither blocks operations nor logs their contents.\n\nPut the script in a separate source so you can test approval without changing the already-approved personal directory.\n\n```\nmkdir -p ~/review-lab-extension/hooks\n\ncat > ~/review-lab-extension/hooks/observe.sh <<'EOF'\n#!/bin/sh\ncat >/dev/null\nexit 0\nEOF\n```\n\nCreate its hook declaration:\n\n```\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"sh ${CLAUDE_PLUGIN_ROOT}/hooks/observe.sh\",\n            \"tools\": [\"Claude Code\"]\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\nSave this as `hooks.json` in the extension directory. During deployment, agent-shared substitutes the source path for the placeholder and uses `tools` to select the agent. It leaves `tools` out of the generated native configuration. The sample command assumes a lab path without spaces; quote paths correctly in real scripts.\n\nRun a deployment with the new source:\n\n```\nagent-shared check --source ~/review-lab-extension\nagent-shared deploy --source ~/review-lab-extension\nagent-shared placed --source ~/review-lab-extension\n```\n\nFor this new source, expect an empty `hooks` array for Claude Code and Codex in the output from `placed`. agent-shared requires approval before placing its hooks; skills and rules from an unapproved source can still be placed. The default personal source, `~/.shared`, already counts as approved. Approval is recorded once per source, not once per hook invocation or script revision. Review later changes to the approved scripts, too.\n\nThe approval command prints the hook commands, then asks `Approve them, so deploy places this source's hooks in every agent? [y/N]`. Read the script itself as well as the printed command, then answer `y` only if you approve it; any other answer writes nothing and exits with status 1. A script can change without its file name changing, so inspecting the command string is not enough.\n\n```\nagent-shared approve --source ~/review-lab-extension\nagent-shared deploy --source ~/review-lab-extension\nagent-shared placed --source ~/review-lab-extension\n```\n\nOnce you approve the source and deploy again, expect to find the declaration in Claude Code's settings file. Codex should receive nothing from this hook because `tools` names only Claude Code.\n\nCodex has its own hook trust mechanism, separate from the source approval above. agent-shared can call `codex app-server` to register trust for deployed personal hooks. If the command is unavailable or doesn't respond, the tool reports the problem and asks you to review hooks in Codex. Repository hooks require a separate trust step.\n\nConsider a shared source from a teammate. You may want its review instructions without allowing its shell scripts to run on your machine. The source approval gate lets you deploy the instructions first and decide about the hooks separately. Codex then has its own trust rules for the hooks it receives. Neither gate turns the script into sandboxed code, and source approval does not pin a particular revision of that script.\n\nReview the hook script and its matcher together. Permission settings, operating-system restrictions, restricted credentials, and the actual tool runtime remain separate security controls.\n\nYou can deploy application-provided settings alongside your personal ones by repeating `--source`. Each source has its own identity and recorded placements.\n\nThis makes it possible to uninstall one source without clearing the entire settings file. Managed rules have source markers, managed hooks carry a source marker in their command, and managed links are identified through the record. The removal operation uses that information to target entries associated with the selected source.\n\nWhat if two sources both contain a rule called `testing.md`? The implementation checks for duplicate names before it writes the planned configuration and refuses the conflicting deployment. The same check applies to skill names. Decide which source should own the rule, rename the other if necessary, and retry. Don't solve the collision by deleting unrelated agent files.\n\nFor a smaller exception, suppose Codex should not receive the personal testing rule. The switch commands record a per-agent omission without modifying the source itself.\n\n```\nagent-shared off --source ~/.shared --agent Codex rules/testing.md\nagent-shared deploy\nagent-shared on --source ~/.shared --agent Codex rules/testing.md\nagent-shared deploy\n```\n\n`off` and `on` change the switch list, not the destination files. The next `deploy` applies the change. Record why Codex should omit this rule so another developer doesn't mistake the omission for a deployment failure.\n\nWhen the review-lab extension is no longer needed, remove its managed entries:\n\n```\nagent-shared remove --source ~/review-lab-extension\n```\n\nCheck the Claude Code settings afterward. The extension's hook should be gone, while unrelated manually configured entries should remain. The tool also documents removing a source after its directory has been deleted, using its record and markers. Still, keep a backup before altering your real configuration; manual edits to managed files, damaged markers, or missing records can complicate recovery.\n\nBy default, agent-shared stores its placement and switch records under `~/.local/share/agent-shared/`. Set `AGENT_SHARED_STATE` to use another location. Back up the record before troubleshooting: without it, the tool loses information about which links it placed.\n\nThe same source layout can be used at repository scope. A repository can keep a project-specific review skill and testing rule in `.shared`. `agent-shared deploy --repo .` creates the relative skill links and manages the rules block in `AGENTS.md`; it does not create `CLAUDE.md`. After deployment, the relevant files should look like this:\n\n```\nexample-service/\n├── .shared/\n│   ├── skills/\n│   │   └── service-review/\n│   │       └── SKILL.md\n│   └── rules/\n│       └── service-testing.md\n├── .agents/\n│   └── skills/\n│       └── service-review -> ../../.shared/skills/service-review\n├── .claude/\n│   └── skills/\n│       └── service-review -> ../../.shared/skills/service-review\n└── AGENTS.md\n```\n\nAt repository scope, agent-shared uses relative links for skills and writes a managed rules block in the repository's `AGENTS.md`. If you want Claude Code to import those instructions through `@AGENTS.md`, write that `CLAUDE.md` file yourself. Repository hooks still need source approval and any trust configuration required by the receiving agent.\n\nTo try this in the disposable environment, create a new repository and populate its `.shared` directory before running the deployment commands below:\n\n```\nmkdir -p example-service\ncd example-service\ngit init -q\nmkdir -p .shared/skills/service-review .shared/rules\ncat > .shared/skills/service-review/SKILL.md <<'EOF'\n---\nname: service-review\ndescription: Review changes to this service.\n---\n\n# Service review\n\nInspect the diff and identify affected tests.\nEOF\nprintf '%s\\n' 'Run the service tests before merging.' > .shared/rules/service-testing.md\nagent-shared check --source .shared\nagent-shared deploy --repo .\n```\n\nThe `--repo` option selects the repository, but it doesn't disable the personal source: `deploy` also processes `~/.shared` when that directory exists. The walkthrough confirmed both relative skill links and the managed rule block, then fresh Claude Code and codex-cli sessions reported the skill and rule, including the updated rule after redeployment. Before committing the repository changes, inspect the new files with `git status --short` and review their contents. Once staged for review, inspect `git diff --cached`. Relative links should survive a clone because their targets belong to the repository, not to another developer's home directory.\n\nRepository hook declarations deserve particular care because distributing executable configuration affects everyone who enables it. Review changes to the script and to the event that runs it. Require a harmless test fixture and a clear explanation of what happens if the script fails. An approval of one source on your computer is not authorization on behalf of every teammate.\n\nKeep personal and project configuration separate even if both are versioned. The project owns the requirements for its service. A developer's own workflow can adapt how those requirements are presented, but it should not silently change the project's intended behavior.\n\nThere is no need to introduce a dedicated deployment layer if you only use one agent or share one compatible skill file. A repository containing a common instruction and the agent-specific import may already be enough.\n\nIf two agents read the same file format, a manual symlink may be all you need. You can inspect it with `ls -l` without learning a new tool. The more formats, managed blocks, event filters, and trust settings you need to maintain, the more work a link-only approach leaves to you.\n\n| Approach | Good fit | Main limitation | \n|---|---|---|\n| Manual configuration | One agent or a few independent settings | Changes must be repeated across copies | \n| Direct symbolic links | Identical files read by several tools | Does not translate differing settings formats | \n| Shared source plus deployment | Several agents with skills, rules and hooks | Adds a tool and a managed-state lifecycle | \n| Repository-owned instructions | Teams that need reproducible project conventions | Does not replace personal settings or runtime permissions | \n\nThere are already tools for sharing agent configuration. [Rulesync](https://rulesync.dyoshikawa.com/reference/cli-commands) generates tool-specific files from its source trees, with configurable targets and features. [Microsoft APM](https://microsoft.github.io/apm/reference/cli/install/) goes further into dependency management: its install command resolves packages and records the result in a lockfile. Both are worth looking at if those are the problems you need to solve.\n\nThe narrower question in this article is what happens to files already on your machine when you edit or remove one local source. agent-shared defines a common source layout and ownership marks in its public specification. Its path-based source IDs help preserve unrelated settings, but they are not a substitute for locking package versions. The comparison here is based on the documented models, not a benchmark or a claim that other tools cannot perform similar operations.\n\nIf your only shared asset is `SKILL.md`, try a link first. A deployment tool becomes more useful when you also need generated rules, agent-specific hooks and a way to remove one source. Before adopting one, check supported agent versions, inspect the generated files and test rollback.\n\nWhen `deploy` refuses a change, don't start deleting destination files. Run `check` against the source, inspect `placed`, and read the reported refusal. A duplicate rule name and a malformed hook declaration require different fixes. If the file was written but a hook doesn't run, check the event, matcher, runtime trust, and agent version instead.\n\nCheck the exit status as well as the messages. `check` returns 1 when it finds a source validation problem. `deploy` returns 1 when it refuses a deployment. Both return 2 for the documented usage or input errors. Even a deployment that returns 0 can print warnings.\n\nUse a symlink when every consumer reads an identical format. Add a deployment layer only when you need generated rules, agent-specific hooks, or ownership-aware removal; then inspect its files and test its runtime behavior separately.", "url": "https://wpnews.pro/news/stop-duplicating-your-claude-code-and-codex-configurations", "canonical_source": "https://dev.to/cardene777/stop-duplicating-your-claude-code-and-codex-configurations-4f9d", "published_at": "2026-11-26 05:37:21+00:00", "updated_at": "2026-11-26 05:43:34.967630+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools"], "entities": ["agent-shared", "Claude Code", "Codex", "GitHub Copilot CLI", "Anthropic", "OpenAI", "GitHub"], "also_reported_by": [], "takeaway": "Symlink one skill directory into both ~/.claude/skills and ~/.agents/skills, and generate rules and hooks per agent, since identical hook JSON does not guarantee identical enforcement across runtimes.", "recommendation": {"advice": "Keep one copy of each skill and symlink it into every agent's skills directory, then verify on disk and in a fresh session that each agent actually loads it.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/stop-duplicating-your-claude-code-and-codex-configurations", "markdown": "https://wpnews.pro/news/stop-duplicating-your-claude-code-and-codex-configurations.md", "text": "https://wpnews.pro/news/stop-duplicating-your-claude-code-and-codex-configurations.txt", "jsonld": "https://wpnews.pro/news/stop-duplicating-your-claude-code-and-codex-configurations.jsonld"}}