GitHub-specific sync mechanism - file copying, pattern matching, and safety checks
Implements GitHub-specific file sync operations with pattern matching and safety checks. Called by project-syncer to copy files between repositories while validating deletion thresholds and supporting dry-run mode.
/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.
scripts/parse-frontmatter.shscripts/sync-docs.shscripts/validate-sync.shworkflow/sync-files.mdYour responsibility is to implement the GitHub-specific sync mechanism. You are a HANDLER skill - you provide the concrete implementation of sync operations for GitHub repositories, following the handler pattern.
You handle:
You are called by project-syncer and org-syncer skills. When cache_mode: true, you write to the local cache directory and update the cache index. When cache_mode: false (legacy), you delegate git operations to the fractary-repo plugin.
Handler Contract:
<CRITICAL_RULES> IMPORTANT: HANDLER IMPLEMENTATION ONLY
IMPORTANT: USE SCRIPTS FOR DETERMINISTIC OPERATIONS
IMPORTANT: SAFETY FIRST
IMPORTANT: DELEGATE GIT OPERATIONS
Cache Mode (v3.0 - default):
{
"operation": "sync-docs",
"source_repo": "<org>/<codex-repo>",
"target_path": ".fractary/plugins/codex/cache/<org>/<project>",
"target_branch": "test",
"direction": "to-cache",
"patterns": {
"include": ["docs/**", "CLAUDE.md", ...],
"exclude": ["**/.git/**", "**/node_modules/**", ...]
},
"options": {
"dry_run": false,
"deletion_threshold": 50,
"deletion_threshold_percent": 20,
"sparse_checkout": true,
"cache_mode": true,
"update_cache_index": true
}
}
Legacy Mode (git-to-git):
{
"operation": "sync-docs",
"source_repo": "<org>/<source-repo>",
"target_repo": "<org>/<target-repo>",
"target_branch": "main",
"direction": "to-target",
"patterns": {
"include": ["docs/**", "CLAUDE.md", ...],
"exclude": ["**/.git/**", "**/node_modules/**", ...]
},
"options": {
"dry_run": false,
"deletion_threshold": 50,
"deletion_threshold_percent": 20,
"sparse_checkout": true,
"cache_mode": false,
"create_commit": true,
"commit_message": "sync: Update docs from project",
"push": true
},
"repo_plugin": {
"use_for_git_ops": true
}
}
Required Parameters:
operation: Must be "sync-docs"source_repo: Source (codex) repository full nametarget_path (cache mode) OR target_repo (legacy): Target locationtarget_branch: Branch to checkout in codex repository (from environment mapping)patterns: Include and exclude patternsOptional Parameters:
direction: "to-cache" (v3.0) or "to-target" (legacy)options.cache_mode: true (default in v3.0) to write to cache directoryoptions.update_cache_index: true to update cache index after syncoptions: Other configuration options with defaultsrepo_plugin: Repo plugin integration config (legacy mode only)Environment/Branch Parameters:
target_branch: The git branch in the codex repository to sync with
Output:
šÆ STARTING: GitHub Sync Handler
Source: <source_repo>
Target: <target_repo>
Branch: <target_branch>
Patterns: <include_count> include, <exclude_count> exclude
Dry Run: <yes|no>
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Execute validation:
If validation fails:
Based on the operation, read the appropriate workflow file:
For operation = "sync-docs":
READ: skills/handler-sync-github/workflow/sync-files.md
EXECUTE: Steps from workflow
This workflow will:
Branch Checkout Details:
target_branchgit checkout test for test environmentgit checkout main for production environmentThe workflow returns:
{
"status": "success|failure",
"files_synced": 25,
"files_deleted": 2,
"files_modified": 15,
"files_added": 10,
"deletion_threshold_exceeded": false,
"dry_run": false
}
If status is "failure":
If status is "success":
Output:
ā
COMPLETED: GitHub Sync Handler
Branch: <target_branch>
Files synced: <files_synced>
Files added: <files_added>
Files modified: <files_modified>
Files deleted: <files_deleted>
Deletion threshold: <passed|exceeded>
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Next: Caller will create commit and push
Return structured results to caller:
{
"status": "success",
"handler": "github",
"target_branch": "<target_branch>",
"files_synced": 25,
"files_deleted": 2,
"files_modified": 15,
"files_added": 10,
"deletion_threshold_exceeded": false,
"files_list": {
"added": ["file1.md", "file2.md", ...],
"modified": ["file3.md", ...],
"deleted": ["file4.md", ...]
},
"dry_run": false
}
</WORKFLOW>
<COMPLETION_CRITERIA> This skill is complete when:
ā For successful sync:
ā For failed sync:
ā For dry-run:
ā In all cases:
{
"status": "success",
"handler": "github",
"mode": "cache",
"target_branch": "test",
"files_synced": 25,
"files_deleted": 2,
"files_modified": 15,
"files_added": 10,
"deletion_threshold_exceeded": false,
"cache_path": ".fractary/plugins/codex/cache/org/project",
"cache_index_updated": true,
"files_list": {
"added": [...],
"modified": [...],
"deleted": [...]
},
"dry_run": false
}
{
"status": "success",
"handler": "github",
"mode": "git",
"target_branch": "main",
"files_synced": 25,
"files_deleted": 2,
"files_modified": 15,
"files_added": 10,
"deletion_threshold_exceeded": false,
"files_list": {
"added": [...],
"modified": [...],
"deleted": [...]
},
"dry_run": false
}
{
"status": "failure",
"handler": "github",
"target_branch": "test",
"error": "Error message",
"phase": "clone|checkout|sync|cache-index|validate",
"partial_results": null
}
{
"status": "success",
"handler": "github",
"target_branch": "test",
"files_synced": 25,
"files_deleted": 2,
"deletion_threshold_exceeded": false,
"would_add": [...],
"would_modify": [...],
"would_delete": [...],
"dry_run": true,
"recommendation": "Safe to proceed|Review deletions"
}
</OUTPUTS>
<ERROR_HANDLING> <PATTERN_VALIDATION_FAILURE> If pattern validation fails:
<SCRIPT_EXECUTION_FAILURE> If sync-docs.sh script fails:
Common script errors:
<DELETION_THRESHOLD_EXCEEDED> If too many deletions detected:
<REPO_PLUGIN_FAILURE> If repo plugin operations fail:
Common repo plugin errors:
<BRANCH_NOT_FOUND> If the target branch doesn't exist in the codex repository:
Example error:
{
"status": "failure",
"handler": "github",
"target_branch": "test",
"error": "Branch 'test' not found in repository fractary/codex.fractary.com",
"phase": "checkout",
"resolution": "Create the branch or update environments config to use an existing branch"
}
Common causes:
Key Components:
Handler Benefits:
Future Handlers:
handler-sync-vector: Sync to vector databasehandler-sync-mcp: Sync via MCP serverCreate employment contracts, offer letters, and HR policy documents following legal best practices. Use when drafting employment agreements, creating HR policies, or standardizing employment documentation.
Implement GDPR-compliant data handling with consent management, data subject rights, and privacy by design. Use when building systems that process EU personal data, implementing privacy controls, or conducting GDPR compliance reviews.