| name | sync-main |
| description | Deploy documentation and infrastructure changes to production immediately without waiting for a new npm release. Use this skill whenever the user mentions 'hotfix docs', 'push doc changes live now', 'promote docs to main', 'bypass package release for docs', 'sync-main', 'sync main', or wants to rescue already-merged doc commits from dev. It handles cherry-picking to main and merging main back into dev to prevent git drift. |
| metadata | {"internal":true} |
Sync Main
This skill enables you to safely sync documentation and tooling changes from the dev branch to main without waiting for the next package release, while ensuring that the dev and main branches remain in a clean, compatible topological state (preventing future merge conflicts).
Analysis Step (Do This First)
Before performing any Git actions, you must analyze the changes between dev and main to classify the sync:
Run the following command to check the list of changed files:
git fetch origin
git diff --name-only origin/main...origin/dev
Based on the file list, classify the sync into one of the following three categories:
- Doc-Only (Easy Case): All changed files are strictly under
docs/, apps/www/, or are root-level Markdown files (matching the regex ^(docs/|apps/www/|[^/]+\.md)$).
- Infra-Only (Easy Case + Force): There are no changes to package code, tests, or examples, but there are changes to workflows, scripts, or skills (e.g.
.github/workflows/, scripts/, skills/).
- Code Changes (Hard Case): There are modifications to files in the
packages/, tests/, examples/, or apps/ directories (unreleased library features, fixes, or test/example updates).
Easy Case Workflows
Category 1: Doc-Only Sync
Since the changes are strictly doc-only, they are safe to sync directly:
Category 2: Infra-Only Sync
Since the changes contain tooling or workflow updates but do not touch the library package code, they can be synced, but the workflow's safety check will block them unless overridden:
Hard Case Workflow
If there are changes in the packages/ directory, do not execute any git commands automatically. You must stop and interview the user in the chat to align on how to proceed.
The Interview
Present the user with a clear summary of the unreleased package files that were detected, outline their choices, and make a recommendation based on the situation:
- Option 1: Wait for Release
- Keep the doc changes on
dev and let them deploy naturally on the next package release.
- Recommendation: Use this if the doc fix is not urgent.
- Option 2: Run a Patch Release
- Release a patch version of the packages (
pnpm changeset -> trigger release workflow).
- Recommendation: Use this if the doc fix is urgent, and the unreleased library code on
dev is stable and ready to go live.
- Option 3: Cherry-Pick/Rescue
- Cherry-pick only the doc commits onto
main (if the doc fixes are isolated in their own clean commits).
- Recommendation: Use this if the doc fix is urgent, the library code on
dev cannot be released, AND the doc commits do not contain unreleased code.
- Option 4: Manual Recreation (Tangled Commits)
- If the urgent doc fix is bundled in the exact same commit as unreleased package code, do not cherry-pick. Instead, manually recreate the doc fix directly against
main using your code editing tools.
- Recommendation: Use this if the doc fix is urgent but the commits are hopelessly tangled with unreleased code.
Executing Option 3 (Cherry-Pick / Rescue)
If the user explicitly approves Option 3, follow these steps using the helper script:
- Identify Commit Hashes:
Locate the specific commit hashes on
dev containing the doc changes.
- Run Rescue Script:
Execute the helper script to cherry-pick these commits onto a branch from
origin/main:
./scripts/sync-main.sh rescue <commit-hash-1> [commit-hash-2 ...]
- Submit PR:
The script will attempt to create a PR to
main via gh CLI. If it fails, help the user open the PR manually.
- Deploy:
Once the PR is merged to
main, the production docs deploy immediately.
- Reconcile:
Merge
main back into dev to prevent drift:
./scripts/sync-main.sh reconcile
If conflicts occur during reconciliation, prompt the user to help resolve them, commit, and push dev.