Skip to main content
command CX Codex

sync-branch · softaworks — Claude Code command: sync feature branch with main

Claude Code command that syncs a feature branch with the latest main via rebase. Runs on /sync-branch and updates the PR with force-push.

MIT ★ 2,707 updated 2026-03-05

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/commands/sync-branch.md
Open on GitHub

What sync-branch does

The command fetches latest commits from origin, rebases the current branch onto main (or another branch if you pass an argument), and pushes changes back with git push --force-with-lease. Works with Claude Code, Codex, GitHub Copilot and Gemini CLI — each has its own install path.

Rebase may hit conflicts — the command stops and you resolve them manually. After that, force-push updates the remote branch and the PR. Force-with-lease is safer than plain force, but still rewrites history — avoid it on branches where others are working.

What it helps with

  • bring a feature branch up to date before merging
  • pull fresh commits from main into an active branch
  • update a PR after rebase
  • sync multiple feature branches with a shared base

Example prompts for the agent

  • Sync the current branch with main
  • Run /sync-branch to update the PR
  • Rebase onto develop instead of main

How to install sync-branch

Manually: put the files in place

.claude/commands/sync-branch.md

Call it with /sync-branch. For all projects use ~/.claude/commands/

Questions about sync-branch

How do I install sync-branch in Claude Code?

Put the file in .claude/commands/sync-branch.md — the command will appear in the available list.

What does sync-branch do?

The command syncs a feature branch with the latest main via rebase and updates the PR with force-push. You can pass a different target branch as an argument.

What is force-with-lease?

A safer variant of --force: push succeeds only if the remote branch has not changed since the last fetch. Protects against accidentally overwriting someone else's commits.

Source text

sync-branch.md · MIT
---
description: Sync feature branch with the latest main branch.
argument-hint: [target]
---

1. Fetch latest upstream refs: `git fetch origin --prune`.
2. Identify target branch (default `main`, or override via argument).
3. Rebase current branch onto target:
   ```bash
   git rebase origin/${target:-main}
   ```
4. Resolve any conflicts
5. Force-with-lease push to update the PR:
   ```bash
   git push --force-with-lease origin $(git branch --show-current)
   ```

© softaworks · MIT · softaworks/agent-toolkit

Similar slash commands

All slash commands for Git and GitHub →

sync-branch by other authors comes first.

sync-branch CloudAI-X sync-branch fetches origin, then rebases or merges the default branch into your current one, stashing uncommitted work first. Useful right before a push or a pull request. CX Codex +1 ★ 1,424repo stars update-branch rohitg00 update-branch — a Claude Code plugin that rebases feature branches onto the main branch and resolves merge conflicts. Runs when syncing long-lived branches before a merge. ★ 2,858repo stars standup thedotmack standup is a Claude Code skill that compares Git worktrees, branches, or selected PRs through a shared agent discussion. It produces a consolidation plan without merging changes. CX Codex +1 3,800installs ops-merge Lifecycle Innovations Limited The ops-merge Claude Code skill scans repositories, sends subagents to fix issues in open pull requests, and merges those that are ready. It automates PR merging. CX Codex +1 ★ 3,785repo stars git-safety tamagui git-safety prevents the agent from running destructive git operations without explicit permission: force push, git reset --hard, git clean -fd. CX Codex +1 ★ 14,319repo stars branch-cleanup davila7 branch-cleanup — a Claude slash command that finds merged and stale branches, checks them before deletion, and tidies up both local and remote refs. CX Codex +1 342installs create-branch getsentry create-branch is a Claude Code skill that creates Git branches using Sentry naming conventions. It activates on requests to start a branch or begin work from the default branch. CX Codex +1 4,400installs

From the same set79

The whole set →
lesson-learned lesson-learned analyzes recent git changes and extracts engineering takeaways directly from your code. Helpful when you want to reflect on architectural choices or review what a feature branch teaches. CX Codex +1 3,000installs gepetto gepetto turns a Markdown spec into an implementation plan, using research, user interviews, and reviews from Gemini and Codex. Use it before building a feature that needs careful planning. CX Codex +1 1,600installs web-to-markdown web-to-markdown converts JavaScript-heavy web pages into clean Markdown via a local browser CLI. Helpful for archiving articles and docs without layout junk. CX Codex +1 796installs communication-excellence-coach communication-excellence-coach reviews communication drafts, calibrates tone for different audiences, and runs roleplay practice for difficult conversations. CX Codex ★ 2,707repo stars compose-email compose-email — a command for drafting professional emails using the What-Why-How framework. Provide context and get a ready-to-send draft with clear structure, matching tone, and concrete next steps. CX Codex +1 ★ 2,707repo stars viral-tweet viral-tweet converts rough draft thoughts into high-engagement posts tailored to the recommendation system of X. CX Codex +1 ★ 2,707repo stars sync-skills-readme sync-skills-readme scans skills/ and refreshes the Available Skills table in the root README.md. Use it after adding or changing skills. CX Codex +1 ★ 2,707repo stars explain-pr-changes explain-pr-changes — a command that generates detailed pull request summaries with architectural visualizations. Helps reviewers grasp the essence and impact of changes in minutes. CX Codex +1 ★ 2,707repo stars

Project sponsors

Companies that keep this analytics open