|
| 1 | +--- |
| 2 | +name: sync-channels |
| 3 | +description: Fetch and merge all channel remotes (telegram, gmail, etc.) into main, then push to origin. Handles package-lock.json conflicts automatically. |
| 4 | +--- |
| 5 | + |
| 6 | +# About |
| 7 | + |
| 8 | +Channel code lives in separate upstream repos (e.g., `nanoclaw-telegram`, `nanoclaw-gmail`) added as git remotes. This skill fetches all remotes, merges any new commits from each channel's `main` branch into your local `main`, and pushes to origin. |
| 9 | + |
| 10 | +Run `/sync-channels` in Claude Code. |
| 11 | + |
| 12 | +## How it works |
| 13 | + |
| 14 | +**Step 1 — Preflight**: |
| 15 | +- Verify working tree is clean (`git status --porcelain`). If dirty, ask user to commit or stash first. |
| 16 | +- Verify current branch is `main`. If not, ask to switch. |
| 17 | + |
| 18 | +**Step 2 — Fetch**: |
| 19 | +- Run `git fetch --all` to pull latest from every remote. |
| 20 | + |
| 21 | +**Step 3 — Identify channel remotes**: |
| 22 | +- List all remotes (`git remote -v`). |
| 23 | +- Exclude `origin` and `upstream` — everything else is a channel remote. |
| 24 | +- For each channel remote, check if `<remote>/main` exists. |
| 25 | + |
| 26 | +**Step 4 — Check for updates**: |
| 27 | +- For each channel remote with a `main` branch, run `git log --oneline main..<remote>/main`. |
| 28 | +- If no new commits, skip that remote. |
| 29 | +- Show the user a summary of which channels have updates and how many commits. |
| 30 | + |
| 31 | +**Step 5 — Merge**: |
| 32 | +- For each channel with new commits, merge `<remote>/main` into `main`: |
| 33 | + ```bash |
| 34 | + git merge <remote>/main --no-edit -m "Merge <remote>/main: <summary>" |
| 35 | + ``` |
| 36 | +- If merge conflicts occur: |
| 37 | + - For `package-lock.json`: resolve with `git checkout --theirs package-lock.json && git add package-lock.json` |
| 38 | + - For other files: stop and show the user the conflicting files, ask how to proceed. |
| 39 | +- After all merges, run `npm install` if `package-lock.json` was updated, to ensure it's consistent. |
| 40 | + |
| 41 | +**Step 6 — Push**: |
| 42 | +- Push `main` to `origin`: `git push origin main` |
| 43 | +- Report success with a summary of what was merged. |
| 44 | + |
| 45 | +## Important |
| 46 | + |
| 47 | +- Never remove channel remotes — they're kept for future syncing. |
| 48 | +- All remotes besides `origin` and `upstream` are treated as channel remotes. |
| 49 | +- Only merges `main` branches from channel remotes, not feature/fix branches. |
0 commit comments