$npx -y skills add avibebuilder/claude-prime --skill prime-syncSyncs Claude config between prime repo and target projects. Trigger on 'sync', 'prime-sync', 'push config', 'pull config', 'update prime', 'sync claude config'. Push mode deploys to targets; pull mode imports changes back.
| 1 | Ultrathink. |
| 2 | |
| 3 | ## Mode Detection |
| 4 | |
| 5 | Detect operating mode before anything else: |
| 6 | |
| 7 | 1. `VERSION` file exists in CWD → **push mode** (CWD is the prime repo) |
| 8 | 2. `.claude/.prime-version` exists in CWD → **pull mode** (CWD is a target project) |
| 9 | 3. Neither detected → ask user which mode and for the required path |
| 10 | |
| 11 | ## Push Mode — Resolve Target |
| 12 | |
| 13 | Source = CWD (prime repo). Target = resolved project path. |
| 14 | |
| 15 | **State file:** `.claude/prime-projects.json` |
| 16 | |
| 17 | Tracks known target paths, last sync time, and version. Shape: |
| 18 | ```json |
| 19 | { "projects": [{ "path": "/absolute/path", "lastSynced": "2025-12-30T10:30:00Z", "version": "1.4.2" }] } |
| 20 | ``` |
| 21 | Create as `{ "projects": [] }` if missing. |
| 22 | |
| 23 | **Resolution flow:** |
| 24 | 1. **Argument provided** → Use that path, then record it after a successful sync |
| 25 | 2. **No argument, known projects exist** → Ask the user which project(s) to sync, including an **All projects** option |
| 26 | 3. **No argument, no known projects** → Ask the user for a path |
| 27 | |
| 28 | **State file management:** |
| 29 | - Create `.claude/` only if you need to persist the state file |
| 30 | - Update the synced project's time/version only after a successful sync |
| 31 | - Keep one entry per absolute path |
| 32 | |
| 33 | ## Pull Mode — Clone Prime |
| 34 | |
| 35 | Source = cloned prime repo. Target = CWD. |
| 36 | |
| 37 | **Flow:** |
| 38 | 1. Read current version from `.claude/.prime-version` in CWD |
| 39 | 2. Generate timestamp: `date +%Y%m%d%H%M%S` |
| 40 | 3. Clone prime repo: `git clone https://github.com/avibebuilder/claude-prime.git /tmp/claude-prime-sync-<timestamp>/` |
| 41 | 4. Set source = `/tmp/claude-prime-sync-<timestamp>/`, target = CWD |
| 42 | 5. Continue to shared process below |
| 43 | 6. Clean up `/tmp/claude-prime-sync-<timestamp>/` after sync completes (success or failure) |
| 44 | |
| 45 | No state file in pull mode — the target project is self-contained. |
| 46 | |
| 47 | ## Process |
| 48 | |
| 49 | ### 1. Validate Target |
| 50 | - Check that the target path exists, is a directory, and is not the same location as the source repo |
| 51 | - Treat a valid target as a project root where writing `.claude/` is appropriate |
| 52 | - Read versions from target (`.claude/.prime-version`) and prime (`VERSION`) |
| 53 | |
| 54 | If the path fails those checks, abort and explain why. |
| 55 | |
| 56 | ### 2. Parallel Analysis |
| 57 | |
| 58 | **Change Detection**: |
| 59 | - Detect relevant changes in prime's `.claude/` based on the target's recorded version state |
| 60 | - If the target has no recorded version, or already matches the current prime version, sync only uncommitted prime changes |
| 61 | - If the target is on an older prime version, diff from that version tag to `HEAD` and include uncommitted changes; warn if the tag is missing |
| 62 | - Categorize changes into commands, agents, hooks, settings, skills, and starter-skills |
| 63 | |
| 64 | **Stack Detection** (only if skills or starter-skills changed): check target for stack indicators relevant to each changed skill/starter. |
| 65 | |
| 66 | **File Comparison**: compare each changed file with target. Detect: NEW, UPDATE, IDENTICAL, CONFLICT. |
| 67 | |
| 68 | ### 3. Build Sync Plan |
| 69 | Aggregate results and present: |
| 70 | ``` |
| 71 | CHANGED (will sync): ... |
| 72 | IDENTICAL (skip): ... |
| 73 | CONFLICTS (will ask): ... |
| 74 | IRRELEVANT (skip, wrong stack): ... |
| 75 | ``` |
| 76 | |
| 77 | **GATE**: User approves sync plan. |
| 78 | |
| 79 | ### 4. Handle Conflicts |
| 80 | For each conflict, show the relevant diff and ask the user how to proceed: |
| 81 | - **Overwrite** — Replace the target copy with the prime version |
| 82 | - **Skip** — Leave the target copy unchanged |
| 83 | - **Merge** — Surface the full diff and let the user choose which parts to keep before writing anything |
| 84 | |
| 85 | ### 5. Execute Sync |
| 86 | 1. Create `.claude/` in target if needed |
| 87 | 2. Copy approved files (skills as entire folders) |
| 88 | 3. Sync approved starter-skills to `.claude/starter-skills/` in target |
| 89 | 4. Update `.prime-version` with prime's VERSION |
| 90 | |
| 91 | ### 6. Report |
| 92 | ``` |
| 93 | Sync complete! (prime vX.X.X) |
| 94 | Updated: ... |
| 95 | Skipped: ... |
| 96 | Version: X.X.X → written to .prime-version |
| 97 | ``` |
| 98 | |
| 99 | Push mode only: update state file (`lastSynced` timestamp + `version`). |
| 100 | Pull mode only: clean up `/tmp/claude-prime-sync-*` clone directory. |
| 101 | |
| 102 | ## Gotchas |
| 103 | |
| 104 | - **`prime-sync` stays in prime** — do not copy this skill into target projects. |
| 105 | - **Push and pull keep different state** — state file is push-only; pull mode treats the target as self-contained. |
| 106 | - **Version history can be incomplete** — if the expected tag is missing, warn and continue with that uncertainty explicit. |
| 107 | |
| 108 | ## Constraints |
| 109 | |
| 110 | - NEVER modify the target project's source code |
| 111 | - NEVER sync without user approval at the plan gate |
| 112 | - In push mode, preserve one state entry per target path and update it only after success |
| 113 | - In pull mode, always clean up the temporary clone, even on failure |
| 114 | |
| 115 | ## Target Path |
| 116 | |
| 117 | <target-path>$ARGUMENTS</target-path> |