prime-sync
npx machina-cli add skill Vibe-Builders/claude-prime/prime-sync --openclawUltrathink.
Role
You are a sync orchestrator. Analyze and sync Claude configurations between prime and target projects.
Mode Detection
Detect operating mode before anything else:
VERSIONfile exists in CWD → push mode (CWD is the prime repo).claude/.prime-versionexists in CWD → pull mode (CWD is a target project)- Neither detected → ask user which mode and for the required path
Push Mode — Resolve Target
Source = CWD (prime repo). Target = resolved project path.
State file: .claude/prime-projects.json
{
"projects": [
{ "path": "/absolute/path", "lastSynced": "2025-12-30T10:30:00Z", "version": "1.4.2" }
]
}
Resolution flow:
- Argument provided → Use path directly, save to state after sync
- No argument, state file has projects → Ask user (multiSelect, include "All projects" option)
- No argument, no state file → Ask user for path
State file management:
- Create
.claude/if needed - Update
lastSyncedandversionafter successful sync - No duplicate paths
Pull Mode — Clone Prime
Source = cloned prime repo. Target = CWD.
Flow:
- Read current version from
.claude/.prime-versionin CWD - Generate timestamp:
date +%Y%m%d%H%M%S - Clone prime repo:
git clone https://github.com/Vibe-Builders/claude-prime.git /tmp/claude-prime-sync-<timestamp>/ - Set source =
/tmp/claude-prime-sync-<timestamp>/, target = CWD - Continue to shared process below
- Clean up
/tmp/claude-prime-sync-<timestamp>/after sync completes (success or failure)
No state file in pull mode — the target project is self-contained.
Process
Check conversation context and skip completed steps.
1. Validate Target
- Check path exists and is a valid project
- Read versions from target (
.claude/.prime-version) and prime (VERSION)
If invalid → abort with error.
2. Parallel Analysis
Change Detection:
- Detect git changes in prime's
.claude/based on version state - If
NO_VERSIONorSAME_VERSION→ uncommitted changes only - If
DIFFERENT_VERSION→ diff from tag to HEAD + uncommitted (warn if tag missing) - Categorize: commands, agents, hooks, settings, skills, starter-skills
Stack Detection (only if skills or starter-skills changed):
- For each changed skill/starter, check if target has matching stack indicators
- Only scan indicators relevant to that skill/starter
File Comparison:
- Compare each changed file with target
- Detect: NEW, UPDATE, IDENTICAL, CONFLICT
3. Build Sync Plan
Aggregate results and present:
CHANGED (will sync): ...
IDENTICAL (skip): ...
CONFLICTS (will ask): ...
IRRELEVANT (skip, wrong stack): ...
GATE: User approves sync plan.
4. Handle Conflicts
For each conflict, show diff and ask user:
- Overwrite — Replace with prime version
- Skip — Keep target version
- Merge — Show full diff for selection
5. Execute Sync
- Create
.claude/in target if needed - Copy approved files (skills as entire folders)
- Sync approved starter-skills to
.claude/starter-skills/in target - Update
.prime-versionwith prime's VERSION
6. Report
Sync complete! (prime vX.X.X)
Updated: ...
Skipped: ...
Version: X.X.X → written to .prime-version
Push mode only: update state file (lastSynced timestamp + version).
Pull mode only: clean up /tmp/claude-prime-sync-* clone directory.
Constraints
- NEVER sync
prime-syncskill — it belongs only in prime repo - NEVER touch:
project/,.mcp.json,settings.local.jsonin target - NEVER modify target project's source code or run commands in target
- NEVER sync without user approval at the gate
- NEVER lose project history — append to state file, no duplicates (push mode)
- ALWAYS clean up
/tmpclone after sync, even on failure (pull mode) - NEVER use state file in pull mode — target is self-contained
Target Path
<target-path>$ARGUMENTS</target-path>
Source
git clone https://github.com/Vibe-Builders/claude-prime/blob/main/.claude/skills/prime-sync/SKILL.mdView on GitHub Overview
prime-sync orchestrates Claude configuration synchronization between the prime repository and target projects. It supports push mode (prime -> targets) and pull mode (target -> prime) with versioned state tracking and safety gates.
How This Skill Works
It first detects the operating mode by checking for a VERSION file in the CWD (push) or a .claude/.prime-version in the CWD (pull); if neither, it prompts for mode and path. In push mode, it uses the prime repo as the source and updates a .claude/prime-projects.json state file to track lastSynced and version after a successful sync. In pull mode, it clones the prime repo to a temp location, then runs the same shared sync process, finally cleaning up the temp clone.
When to Use It
- Publish updates from the prime repo's Claude config to one or more target projects
- Synchronize a target project's Claude config back to prime when it diverges
- Prepare a new target project by pulling the latest prime configuration during initial setup
- Resolve differences between prime and target configurations, with a manual gate approval
- Clone the Claude-prime repository into a target project to align configuration before work
Quick Start
- Step 1: Determine mode from CWD (VERSION for push, .claude/.prime-version for pull). If neither, prompt.
- Step 2: In push mode, specify the target project path or select from state; in pull mode, clone the prime repo to a temp location and set source/target.
- Step 3: Review the sync plan at the gate, approve, and let the tool apply changes; update state and clean up.
Best Practices
- Ensure you have a defined target path or use the state file to manage targets
- Review the generated plan at the gate before applying changes
- Never sync the prime-sync skill itself; it should stay in the prime repo
- Keep .claude and .prime-version updated to reflect the latest prime version
- Avoid modifying target source code or running commands in the target during sync
Example Use Cases
- Push prime's Claude config to /projects/company-a
- Pull updated target Claude config into prime from /projects/target-b
- Sync after prime version update 1.4.2 to a target with old config
- Resolve a conflict where target has a different starter-skills version
- Initial alignment: clone prime into /tmp and sync to /projects/new-client