Sync the Agent rule system from the GitHub repository nangongwentian-fe/Awesome-GlobalRule to the global configuration directories of the two local AI tools.
Sync mapping
| Repository source | Claude Code target | Codex target |
|---|---|---|
AGENTS.md |
~/.claude/CLAUDE.md |
~/.codex/AGENTS.md |
docs/agent-rules/* (11 files) |
~/.claude/docs/agent-rules/ |
~/.codex/docs/agent-rules/ |
Status tracking
The last sync information is saved in ~/.claude/.sync_state.json, including the synced commit SHA.
This way, each check only needs to compare the SHA, without downloading all the content.
Workflow
Scenario 1: Check whether there are updates (recommended to run first)
bash ~/.claude/skills/sync-global-rules/scripts/check_updates.sh
Output interpretation:
- Exit code
0+ output starts withupdates-available:→ there is a new version, perform sync - Exit code
1+ output starts withup-to-date:→ already up to date, no action needed - Exit code
2+ outputERROR:→ environment issue (gh not installed or not logged in)
Scenario 2: Perform a full sync
When there are updates (or when the user explicitly requests a sync):
bash ~/.claude/skills/sync-global-rules/scripts/sync.sh
The script will automatically:
- Check the remote SHA against the locally recorded SHA
- In
~/.claude/backups/<timestamp>/automatically back up existing files - Download all files and write them to the two target directories
- Update
~/.claude/.sync_state.json
Scenario 3: Force sync (even if the SHA is the same)
bash ~/.claude/skills/sync-global-rules/scripts/sync.sh --force
Scenario 4: Preview mode (do not write files)
bash ~/.claude/skills/sync-global-rules/scripts/sync.sh --dry-run
Standard execution order
When the user triggers this skill, execute in the following order:
- Run
check_updates.sh - Interpret the output:
- There are updates → tell the user "New version found:", and ask whether to sync (or sync directly, depending on the user's instruction)
- Already up to date → tell the user "Currently up to date (SHA: <short_sha>, last sync: )", and end
- Error → tell the user the specific error and give repair suggestions
- When there are updates, run
sync.sh - Report the sync result (SHA, backup path, number of files)
Prerequisites
ghCLI is installed and logged in (gh auth status)python3is available- For
~/.claude/and~/.codex/have write permission
Notes
- Syncing will overwrite existing rule files, but an automatic backup is made before every sync(saved in
~/.claude/backups/) - The backup only saves the main rule files (
CLAUDE.mdandAGENTS.md), files in the docs directory are not backed up (they can be restored from GitHub) - If the user has local personalized modifications (such as language preferences, etc.), they need to be manually appended after syncing