Skip to content

Commit 1c49677

Browse files
stranmaclaude
andcommitted
feat: Auto-reset /sync to master when nothing blocks
Previously /sync only reported state and suggested manual commands. Now it automatically runs git checkout master && git pull --rebase when the working tree is clean, the branch has no unpushed commits, and we're not already on master. If blockers exist (dirty files, unpushed commits), it reports them and asks what to do instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5c58f88 commit 1c49677

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

.claude/skills/sync/SKILL.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ Pre-flight workspace sync. Run this before starting any work.
1818
- Run `git status` to see dirty files, staged changes, untracked files
1919
- Run `git branch -vv` to see current branch, tracking info, ahead/behind counts
2020

21-
3. **Warn on problems**
22-
- If behind remote: warn and suggest `git pull --rebase` or `git rebase origin/<branch>`
23-
- If on main/master with dirty working tree: warn that uncommitted changes exist on the base branch
24-
- If no upstream tracking branch: note that the branch is local-only
21+
3. **Auto-reset to master if nothing is blocking**
22+
23+
If ALL of the following are true, automatically run `git checkout master && git pull --rebase` without asking:
24+
- Working tree is clean (no staged, unstaged, or untracked changes that matter)
25+
- Current branch is NOT master (already on a feature branch that can be left)
26+
- The feature branch has no unpushed commits (ahead 0, or branch was already merged)
27+
28+
If any blocker exists, do NOT auto-reset. Instead report the blocker and ask what to do:
29+
- **Dirty working tree**: list the files and ask whether to stash, commit, or discard
30+
- **Unpushed commits on current branch**: warn and ask whether to push first or switch anyway
31+
- **Already on master**: just `git pull --rebase` to update
2532

2633
4. **Show recent context**
27-
- Run `git log --oneline -3` to show the last 3 commits
34+
- Run `git log --oneline -3` to show the last 3 commits (after any branch switch)
2835

2936
5. **Output structured report**
3037

@@ -35,19 +42,14 @@ Branch: <name> (tracking: <remote>/<branch>)
3542
Status: <clean | N dirty files | N staged, M unstaged>
3643
Remote: <up to date | N ahead, M behind>
3744
38-
## Warnings
39-
- <any warnings from step 3, or "None">
45+
## Actions Taken
46+
- <e.g. "Switched to master and pulled 5 new commits", or "None -- already on clean master">
47+
48+
## Blockers (if any)
49+
- <e.g. "Unstaged changes in .claude/settings.json -- stash, commit, or discard?">
4050
4151
## Recent Commits
4252
- <hash> <message>
4353
- <hash> <message>
4454
- <hash> <message>
4555
```
46-
47-
## What This Skill Does NOT Do
48-
49-
- Does NOT classify the task as Q/S/P
50-
- Does NOT read DECISIONS.md or IMPLEMENTATION_PLAN.md
51-
- Does NOT modify any files
52-
53-
This is purely a workspace readiness check.

0 commit comments

Comments
 (0)