Sync a single project bidirectionally with codex core repository. Delegates to fractary CLI for sync operations.
Bidirectionally syncs a project with the codex repository using the fractary CLI. Triggered when syncing documentation between project and central codex for specific environments or branches.
/plugin marketplace add fractary/claude-plugins/plugin install fractary-codex@fractaryThis skill inherits all available tools. When active, it can use any tool Claude has access to.
workflow/analyze-patterns.mdworkflow/sync-from-codex.mdworkflow/sync-to-codex.mdworkflow/validate-inputs.mdworkflow/validate-sync.mdYour responsibility is to synchronize documentation between a single project repository and the central codex repository by delegating to the cli-helper skill which invokes the fractary codex sync project CLI command.
Architecture (v4.0):
project-syncer skill
↓ (delegates to)
cli-helper skill
↓ (invokes)
fractary codex sync project
↓ (uses)
@fractary/codex SDK (SyncManager, GitHandler)
This provides bidirectional synchronization with:
All via the TypeScript SDK. </CONTEXT>
<CRITICAL_RULES>
Output:
🎯 STARTING: Project Sync
Project: {project}
Environment: {environment} (branch: {target_branch})
Direction: {direction}
Dry Run: {yes|no}
───────────────────────────────────────
Construct arguments array from inputs:
args = ["sync", "project", project]
// Add environment or target branch
if (environment) {
args.push("--environment", environment)
} else if (target_branch) {
args.push("--branch", target_branch)
}
// Add direction
args.push("--direction", direction)
// Add patterns if provided
if (patterns && patterns.length > 0) {
patterns.forEach(p => args.push("--pattern", p))
}
// Add excludes if provided
if (exclude && exclude.length > 0) {
exclude.forEach(e => args.push("--exclude", e))
}
// Add dry-run flag
if (dry_run) {
args.push("--dry-run")
}
USE SKILL: cli-helper Operation: invoke-cli Parameters:
{
"command": "sync",
"args": ["project", "<name>", ...environment, ...direction, ...patterns, ...dry_run],
"parse_output": true
}
The cli-helper will:
fractary codex sync project <name> [--environment <env>|--branch <branch>] --direction <direction> [--pattern <p>] [--exclude <e>] [--dry-run] --jsonThe CLI returns JSON like:
Successful Sync:
{
"status": "success",
"operation": "sync-project",
"project": "auth-service",
"environment": "test",
"target_branch": "test",
"direction": "bidirectional",
"to_codex": {
"files_synced": 25,
"files_deleted": 2,
"commit_sha": "abc123...",
"commit_url": "https://github.com/org/codex/commit/abc123"
},
"from_codex": {
"files_synced": 15,
"files_deleted": 0,
"commit_sha": "def456...",
"commit_url": "https://github.com/org/project/commit/def456"
},
"dry_run": false,
"duration_seconds": 12.5
}
Dry-Run Preview:
{
"status": "success",
"operation": "sync-project",
"project": "auth-service",
"environment": "test",
"target_branch": "test",
"direction": "bidirectional",
"dry_run": true,
"would_sync": {
"to_codex": {
"files": 25,
"deletions": 2,
"exceeds_threshold": false
},
"from_codex": {
"files": 15,
"deletions": 0,
"exceeds_threshold": false
}
},
"recommendation": "Safe to proceed"
}
IF status == "success":
IF status == "failure":
Output:
✅ COMPLETED: Project Sync
Project: {project}
Environment: {environment} (branch: {target_branch})
Direction: {direction}
Results:
- Files synced to codex: {count}
- Files synced from codex: {count}
- Commits created: {count}
- Deletions: {count}
Summary:
{brief description of what was synced}
───────────────────────────────────────
Next: Verify changes in repositories
Return structured JSON with sync results (pass through from CLI).
COMPLETION: Operation complete when sync results shown.
</WORKFLOW><COMPLETION_CRITERIA> Operation is complete when:
✅ For successful sync:
✅ For failed sync:
✅ For dry-run:
✅ In all cases:
{
"status": "success",
"project": "auth-service",
"environment": "test",
"target_branch": "test",
"direction": "bidirectional",
"to_codex": {
"files_synced": 25,
"files_deleted": 2,
"commit_sha": "abc123...",
"commit_url": "https://github.com/org/codex/commit/abc123"
},
"from_codex": {
"files_synced": 15,
"files_deleted": 0,
"commit_sha": "def456...",
"commit_url": "https://github.com/org/project/commit/def456"
},
"dry_run": false,
"duration_seconds": 12.5
}
{
"status": "success",
"project": "auth-service",
"environment": "test",
"target_branch": "test",
"direction": "bidirectional",
"dry_run": true,
"would_sync": {
"to_codex": {
"files": 25,
"deletions": 2,
"exceeds_threshold": false
},
"from_codex": {
"files": 15,
"deletions": 0,
"exceeds_threshold": false
}
},
"recommendation": "Safe to proceed|Review deletions before proceeding"
}
{
"status": "failure",
"operation": "sync-project",
"project": "auth-service",
"environment": "test",
"error": "Target branch 'test' not found in codex repository",
"phase": "to-codex",
"cli_error": {
"message": "Branch 'test' does not exist",
"suggested_fixes": [
"Create the branch: git checkout -b test && git push -u origin test",
"Or update config to use existing branch"
]
},
"partial_results": {
"to_codex": null,
"from_codex": null
}
}
{
"status": "failure",
"operation": "sync-project",
"error": "Deletion threshold exceeded",
"cli_error": {
"message": "Would delete 75 files (threshold: 50 files, 20%)",
"details": {
"would_delete": 75,
"threshold": 50,
"threshold_percent": 20
},
"suggested_fixes": [
"Review file list to ensure this is intentional",
"Adjust deletion_threshold in config",
"Fix sync patterns if incorrect",
"Proceed with --force flag (use carefully!)"
]
}
}
{
"status": "failure",
"operation": "sync-project",
"error": "CLI not available",
"suggested_fixes": [
"Install globally: npm install -g @fractary/cli",
"Or ensure npx is available"
]
}
</OUTPUTS>
<ERROR_HANDLING>
When direction is not valid:
When CLI reports branch doesn't exist:
When CLI reports too many deletions:
When CLI reports auth issues:
When CLI reports invalid patterns:
When cli-helper reports CLI unavailable:
When CLI returns error:
</ERROR_HANDLING>
<DOCUMENTATION> Upon completion, output:Success:
🎯 STARTING: project-syncer
Project: {project}
Environment: {environment} (branch: {target_branch})
Direction: {direction}
Dry Run: {yes|no}
───────────────────────────────────────
[Sync execution via CLI]
✅ COMPLETED: project-syncer
Project: {project}
Environment: {environment}
Direction: {direction}
Results:
- To Codex: {files} files synced, {deletions} deleted
- From Codex: {files} files synced, {deletions} deleted
- Commits: {commit_urls}
Source: CLI (via cli-helper)
───────────────────────────────────────
Next: Verify changes in repositories
Dry-Run:
🎯 STARTING: project-syncer (DRY-RUN)
Project: {project}
Environment: {environment} (branch: {target_branch})
Direction: {direction}
───────────────────────────────────────
[Preview from CLI]
✅ COMPLETED: project-syncer (dry-run)
Would sync:
- To Codex: {files} files, {deletions} deletions
- From Codex: {files} files, {deletions} deletions
Recommendation: {Safe to proceed|Review deletions}
Source: CLI (via cli-helper)
───────────────────────────────────────
Run without --dry-run to execute
Failure:
🎯 STARTING: project-syncer
───────────────────────────────────────
❌ FAILED: project-syncer
Error: {error_message}
Phase: {to-codex|from-codex|validation}
Suggested fixes:
- {fix 1}
- {fix 2}
───────────────────────────────────────
</DOCUMENTATION>
<NOTES>
v3.0 (bash scripts + workflows):
project-syncer
├─ workflow/validate-inputs.md
├─ workflow/analyze-patterns.md
├─ workflow/sync-to-codex.md
├─ workflow/sync-from-codex.md
└─ workflow/validate-sync.md
↓ (delegates to)
handler-sync-github
↓ (uses)
bash scripts for git operations
v4.0 (CLI delegation):
project-syncer
└─ delegates to cli-helper
└─ invokes: fractary codex sync project
Benefits:
This skill delegates to:
fractary codex sync project <name> \
[--environment <env>|--branch <branch>] \
--direction <to-codex|from-codex|bidirectional> \
[--pattern <pattern>]... \
[--exclude <pattern>]... \
[--dry-run] \
--json
Via the CLI, this skill benefits from:
SyncManager.syncProject() - Main sync orchestrationGitHandler.clone() - Repository cloningGitHandler.commit() - Commit creationGitHandler.push() - Remote pushPatternMatcher.filter() - File filteringDeletionValidator.check() - Safety threshold checkingto-codex (Project → Codex):
from-codex (Codex → Project):
bidirectional (Both):
Environments map to target branches:
environments:
dev:
branch: develop
test:
branch: test
staging:
branch: staging
prod:
branch: main
When environment: test is provided:
target_branch: testtest branchDeletion Thresholds:
Dry-Run Mode:
Branch Validation:
Pattern Safety:
To test this skill:
# Ensure CLI installed
npm install -g @fractary/cli
# Initialize codex config
fractary codex init --org fractary
# Test dry-run
USE SKILL: project-syncer
Parameters: {
"project": "auth-service",
"environment": "test",
"direction": "bidirectional",
"dry_run": true
}
# Test actual sync
USE SKILL: project-syncer
Parameters: {
"project": "auth-service",
"environment": "test",
"direction": "to-codex"
}
If sync fails:
fractary --version.fractary/codex.yamlfractary codex sync project <name> --dry-rungit ls-remote origin <branch>fractary codex health
</NOTES>