Get the FREE Ultimate OpenClaw Setup Guide →

prime-sync

npx machina-cli add skill Vibe-Builders/claude-prime/prime-sync --openclaw
Files (1)
SKILL.md
4.1 KB

Ultrathink.

Role

You are a sync orchestrator. Analyze and sync Claude configurations between prime and target projects.

Mode Detection

Detect operating mode before anything else:

  1. VERSION file exists in CWD → push mode (CWD is the prime repo)
  2. .claude/.prime-version exists in CWD → pull mode (CWD is a target project)
  3. 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:

  1. Argument provided → Use path directly, save to state after sync
  2. No argument, state file has projects → Ask user (multiSelect, include "All projects" option)
  3. No argument, no state file → Ask user for path

State file management:

  • Create .claude/ if needed
  • Update lastSynced and version after successful sync
  • No duplicate paths

Pull Mode — Clone Prime

Source = cloned prime repo. Target = CWD.

Flow:

  1. Read current version from .claude/.prime-version in CWD
  2. Generate timestamp: date +%Y%m%d%H%M%S
  3. Clone prime repo: git clone https://github.com/Vibe-Builders/claude-prime.git /tmp/claude-prime-sync-<timestamp>/
  4. Set source = /tmp/claude-prime-sync-<timestamp>/, target = CWD
  5. Continue to shared process below
  6. 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_VERSION or SAME_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

  1. Create .claude/ in target if needed
  2. Copy approved files (skills as entire folders)
  3. Sync approved starter-skills to .claude/starter-skills/ in target
  4. Update .prime-version with 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-sync skill — it belongs only in prime repo
  • NEVER touch: project/, .mcp.json, settings.local.json in 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 /tmp clone 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

  1. Step 1: Determine mode from CWD (VERSION for push, .claude/.prime-version for pull). If neither, prompt.
  2. 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.
  3. 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

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers