source-command-sync-branch
Use this skill when the user asks to run the migrated source command sync-branch.
Command Template
Sync Branch with Base
Sync the current branch with the base branch before PR review. You (Codex) will intelligently resolve any merge conflicts.
Workflow
Step 1: Fetch Latest Changes
Fetch the latest changes from origin:
git fetch origin
Step 2: Merge Base Branch
Attempt to merge the base branch:
git merge origin/$BASE_BRANCH --no-edit
Step 3: Handle Conflicts (Codex's Responsibility)
If there are conflicts, YOU (Codex) must resolve them intelligently:
- Check
git statusto see conflicted files - For each conflicted file, review the conflict markers
- Use your understanding of the code to resolve conflicts intelligently
- Stage resolved files with
git add - Complete merge with
git commit --no-edit
If conflicts cannot be resolved (e.g., too complex, unclear intent):
git merge --abort
Then return synced: false with a clear explanation.
Step 4: Push Changes
If the merge was successful (with or without conflicts):
git push origin HEAD
Final Output (STRICT JSON)
{
"synced": true|false,
"had_conflicts": true|false,
"summary": "Brief summary of sync result"
}
Examples:
- Success without conflicts:
{"synced": true, "had_conflicts": false, "summary": "Branch synced with main, no conflicts"} - Success with resolved conflicts:
{"synced": true, "had_conflicts": true, "summary": "Branch synced with main, resolved conflicts in 2 files"} - Aborted due to conflicts:
{"synced": false, "had_conflicts": true, "summary": "Aborted merge with main: conflicts in config.json require manual resolution"} - Failure:
{"synced": false, "had_conflicts": false, "summary": "Failed to fetch from origin"}