sync-branch
The sync-branch command synchronizes a Git branch with the default branch by fetching remote changes, then applying them via rebase or merge. Use this when you need to update your current branch with the latest code from main or master while preserving local work through automatic stashing and conflict detection.
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/CloudAI-X/claude-workflow-v2/HEAD/commands/sync-branch.md -o ~/.claude/commands/sync-branch.mdsync-branch.md
## Context - Current branch: !`git branch --show-current` - Default branch: !`git remote show origin 2>/dev/null | grep 'HEAD branch' | cut -d' ' -f5 || echo "main"` - Uncommitted changes: !`git status --porcelain` - Commits ahead/behind: !`git rev-list --left-right --count origin/$(git remote show origin 2>/dev/null | grep 'HEAD branch' | cut -d' ' -f5 || echo "main")...HEAD 2>/dev/null || echo "unknown"` - Current remote: !`git remote -v | head -2` ## Task Safely sync the current branch with the default branch: 1. Check for uncommitted changes - if any, stash them 2. Fetch the latest from origin 3. Based on argument (default: rebase): - **rebase**: `git rebase origin/<default-branch>` - **merge**: `git merge origin/<default-branch>` 4. Handle any conflicts by reporting them clearly 5. If changes were stashed, pop them 6. Report the sync status Strategy: $ARGUMENTS
Add tests for recently changed files or specified code
Analyzes codebases to understand structure, tech stack, patterns, and conventions. Use when onboarding to a new project, exploring unfamiliar code, or when asked "how does this work?" or "what's the architecture?
System design and architecture planning mode. Focuses on high-level design, trade-offs, and technical decisions before implementation.
Explore the repository with 10 parallel subagents to create comprehensive documentation. Creates CODEBASE.md with full architecture analysis.
Expert code review specialist. Use PROACTIVELY after writing or modifying code, before commits, when asked to review changes, PR review, code quality check, lint, or standards audit. Focuses on quality, security, performance, and maintainability.
Simplifies code after implementation. Reviews recent changes and suggests/applies simplifications while preserving behavior.
Create a conventional commit with auto-generated message
Commit staged changes, push to remote, and create a pull request