Deterministic submodule sync — script handles Steps 1-7 mechanics, LLM only parses output and handles semantics (commit message, conflict options)
.claude/skills/git-sync-submodule-deterministic/scripts/sync-submodule.sh .claude main
Parse stdout KEY=VALUE pairs. Stderr has phase markers (informational only).
STATUS=synced (exit 0)Report: "Already synced at OLD_HEAD." Done.
STATUS=catch-up or STATUS=diverged-safe (exit 0)Proceed to Step 3 (commit parent).
STATUS=conflict (exit 2)STOP. Present these 3 options to user:
Divergence detected with conflicting changes. Overlapping files:
OVERLAP_FILESDetails:DIFF_SUMMARY
- Rebase submodule onto hub —
git -C .claude pull --rebase <HUB_REMOTE> main- Discard submodule-only commits — move pointer to hub HEAD
- Abort — leave as-is, investigate manually
Do NOT proceed without user choice.
STATUS=submodule-ahead (exit 3)Report: "Submodule is ahead of hub — use git-create-commit-skill to push instead." Done.
STATUS=error (exit 1)Report the ERROR value. Do NOT retry blindly.
Stage and commit pointer update in parent repo using git-create-commit-skill format:
chore(deps): update .claude submodule with <summary of hub changes>
git -C .claude remote/fetch/checkout/log manually — WRONG. Script handles Steps 1-7.STATUS=error without investigating — WRONG.STATUS=conflict without user choice — WRONG.HUB_REMOTE from script output.Based on: git-sync-submodule SKILL.md Pattern: setup-worktree.sh — "script handles mechanics, LLM handles semantics"