# Stop Duplicating Your Claude Code and Codex Configurations

> Source: <https://dev.to/cardene777/stop-duplicating-your-claude-code-and-codex-configurations-4f9d>
> Published: 2026-11-26 05:37:21+00:00

**Recommendation:** 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.
More in the playbook "Working with AI coding agents": <https://wpnews.pro/playbooks/coding-agents>

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.

AI assistance generated this article and its diagrams. The author reviewed the claims, commands, and final text.

Rules 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.

I 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.

On 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.

The 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.

Suppose the shared review workflow consists of a skill, a rule requiring tests, and a hook attached to shell operations.

With 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.

Stale 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.

Instead, 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.

Check 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.

The 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.

Hooks 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.

The agent table in v0.3.0 defines these destinations for personal configuration:

| Component | Claude Code | Codex | GitHub Copilot CLI | 
|---|---|---|---|
| Skill directory | ~/.claude/skills | ~/.agents/skills | Reads the shared agents skill directory | 
| Rules | Individual files in ~/.claude/rules | Managed block in ~/.codex/AGENTS.md | Managed block in ~/.copilot/copilot-instructions.md | 
| Hooks | ~/.claude/settings.json | ~/.codex/hooks.json | ~/.copilot/hooks/agent-shared.json | 

For 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.

Copying 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.

Why 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.

For 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.

```
~/.shared/
├── skills/
│   └── review-change/
│       └── SKILL.md
└── rules/
    └── testing.md
```

Neither 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.

Leave 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.

Before 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.

A 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.

You'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.

Install the revision used in this article rather than whatever happens to be on the default branch today:

```
uv tool install "git+https://github.com/cardene777/agent-shared@02fb752d62b72506ef7085d9623a8aa8d1612002"
agent-shared --version
```

Expect `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.

Create the review skill and testing rule in a fresh lab home directory.

```
mkdir -p ~/.shared/skills/review-change ~/.shared/rules

cat > ~/.shared/skills/review-change/SKILL.md <<'EOF'
---
name: review-change
description: Review a proposed code change for defects and missing tests.
---

# Review a change

1. Read the diff and the relevant surrounding code.
2. Identify changed behavior and affected tests.
3. Report findings with evidence and impact.
4. State which checks could not be performed.
EOF

cat > ~/.shared/rules/testing.md <<'EOF'
# Testing

Run relevant tests after changing business logic.
Report the command, result, and any checks that could not run.
EOF
```

The 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.

The 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.

Now check the source without writing destination files.

```
agent-shared check --source ~/.shared
```

`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.

Apply the configuration and inspect what was placed.

```
agent-shared deploy
agent-shared placed --source ~/.shared
```

`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:

```
ls -l ~/.claude/skills/review-change
ls -l ~/.agents/skills/review-change
ls -l ~/.claude/rules/testing.md
cat ~/.codex/AGENTS.md
```

With 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`.

If 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.

The 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.

Once 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.

Codex 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.

Add a new instruction to the source rule:

```
printf '\nInclude the exit status when reporting a test result.\n' \
  >> ~/.shared/rules/testing.md
```

Before running `deploy` again, read the two destinations. Expect the new sentence in the linked Claude Code rule but not in Codex's generated block.

```
cat ~/.claude/rules/testing.md
cat ~/.codex/AGENTS.md
agent-shared deploy
cat ~/.codex/AGENTS.md
```

After 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.

You 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.

``` python
import tempfile
from pathlib import Path

with tempfile.TemporaryDirectory() as folder:
    root = Path(folder)
    source = root / "testing.md"
    link = root / "linked.md"
    generated = root / "AGENTS.md"
    source.write_text("Run tests.\n")
    link.symlink_to(source)
    generated.write_text(source.read_text())

    source.write_text("Run tests.\nReport exit status.\n")
    assert link.read_text() == source.read_text()
    assert "Report exit status." not in generated.read_text()

    generated.write_text(source.read_text())
    assert generated.read_text() == source.read_text()
```

All 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.

Rollback 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.

How 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.

The 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.

For example, a generated block uses the same ID in its opening and closing markers:

``` php
<!-- agent-shared begin source=0123456789ab -->
<!-- agent-shared rule testing.md -->
# Testing
Run relevant tests.
<!-- agent-shared end source=0123456789ab -->
```

The 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.

Edit the source, not the generated block. A hand edit inside that block may disappear the next time you deploy.

To 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.

Put the script in a separate source so you can test approval without changing the already-approved personal directory.

```
mkdir -p ~/review-lab-extension/hooks

cat > ~/review-lab-extension/hooks/observe.sh <<'EOF'
#!/bin/sh
cat >/dev/null
exit 0
EOF
```

Create its hook declaration:

```
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "sh ${CLAUDE_PLUGIN_ROOT}/hooks/observe.sh",
            "tools": ["Claude Code"]
          }
        ]
      }
    ]
  }
}
```

Save 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.

Run a deployment with the new source:

```
agent-shared check --source ~/review-lab-extension
agent-shared deploy --source ~/review-lab-extension
agent-shared placed --source ~/review-lab-extension
```

For 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.

The 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.

```
agent-shared approve --source ~/review-lab-extension
agent-shared deploy --source ~/review-lab-extension
agent-shared placed --source ~/review-lab-extension
```

Once 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.

Codex 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.

Consider 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.

Review the hook script and its matcher together. Permission settings, operating-system restrictions, restricted credentials, and the actual tool runtime remain separate security controls.

You can deploy application-provided settings alongside your personal ones by repeating `--source`. Each source has its own identity and recorded placements.

This 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.

What 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.

For 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.

```
agent-shared off --source ~/.shared --agent Codex rules/testing.md
agent-shared deploy
agent-shared on --source ~/.shared --agent Codex rules/testing.md
agent-shared deploy
```

`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.

When the review-lab extension is no longer needed, remove its managed entries:

```
agent-shared remove --source ~/review-lab-extension
```

Check 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.

By 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.

The 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:

```
example-service/
├── .shared/
│   ├── skills/
│   │   └── service-review/
│   │       └── SKILL.md
│   └── rules/
│       └── service-testing.md
├── .agents/
│   └── skills/
│       └── service-review -> ../../.shared/skills/service-review
├── .claude/
│   └── skills/
│       └── service-review -> ../../.shared/skills/service-review
└── AGENTS.md
```

At 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.

To try this in the disposable environment, create a new repository and populate its `.shared` directory before running the deployment commands below:

```
mkdir -p example-service
cd example-service
git init -q
mkdir -p .shared/skills/service-review .shared/rules
cat > .shared/skills/service-review/SKILL.md <<'EOF'
---
name: service-review
description: Review changes to this service.
---

# Service review

Inspect the diff and identify affected tests.
EOF
printf '%s\n' 'Run the service tests before merging.' > .shared/rules/service-testing.md
agent-shared check --source .shared
agent-shared deploy --repo .
```

The `--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.

Repository 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.

Keep 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.

There 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.

If 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.

| Approach | Good fit | Main limitation | 
|---|---|---|
| Manual configuration | One agent or a few independent settings | Changes must be repeated across copies | 
| Direct symbolic links | Identical files read by several tools | Does not translate differing settings formats | 
| Shared source plus deployment | Several agents with skills, rules and hooks | Adds a tool and a managed-state lifecycle | 
| Repository-owned instructions | Teams that need reproducible project conventions | Does not replace personal settings or runtime permissions | 

There 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.

The 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.

If 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.

When `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.

Check 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.

Use 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.
