Skip to main content
skill CX Codex

rebase-latest-main — Claude Code skill: rebase onto latest main

A skill that walks the agent through fetching origin/main, rebasing the current branch and resolving conflicts. Handy when your branch has drifted behind main.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add dyoshikawa/rulesync --skill rebase-latest-main -a claude-code
Open on GitHub

What rebase-latest-main does

The skill lays out a git procedure step by step. First the agent checks the current branch and looks for uncommitted changes. If any exist, it either commits them or asks you how to proceed — commit, stash or abort.

Then come git fetch origin main and git rebase origin/main. On conflicts the agent lists files with git diff --name-only --diff-filter=U, reads each one, compares both sides and stages the fix with git add <resolved-file> before continuing the rebase. If it cannot sort things out, it shows the conflict markers and waits for your call; git rebase --abort rolls back.

After a clean rebase the skill pushes with git push --force-with-lease, which is safer than --force because it will not clobber someone else's work. Worth knowing: if your workflow forbids force-pushing a shared branch, you skip that step by hand. At the end the agent reports how many commits moved and which conflicts it closed.

What it helps with

  • pull the latest origin/main into your branch
  • work through rebase conflicts
  • check for uncommitted changes before rebasing
  • roll back a failed rebase with git rebase --abort
  • update the remote branch after moving commits

Example prompts for the agent

  • rebase onto the latest main
  • update my branch with the latest main
  • sync my branch with upstream

How to install rebase-latest-main

1Skills CLI (Vercel)

npx skills add dyoshikawa/rulesync --skill rebase-latest-main -a claude-code

2Manually: put the files in place

~/.claude/skills/rebase-latest-main/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/rebase-latest-main/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about rebase-latest-main

How do I install rebase-latest-main in Claude?

Run npx skills add dyoshikawa/rulesync --skill rebase-latest-main -a claude-code. The skill lands at ~/.claude/skills/rebase-latest-main/SKILL.md.

What does rebase-latest-main do?

It drives the agent through checking the branch and working tree, git fetch origin main, the rebase, conflict resolution and a --force-with-lease push.

Does the skill commit my changes on its own?

No. When it finds uncommitted changes it asks what to do: commit them, stash them or abort the operation.

Source text

SKILL.md · MIT
---
name: rebase-latest-main
description: >-
  Fetch latest origin/main and rebase it onto the current branch, resolving
  conflicts if necessary. Use when the user wants to rebase on main, update
  their branch with latest main, or sync with upstream.
targets:
  - "*"
---

# Rebase Latest Main

Fetch the latest `origin/main` and rebase it onto the current working branch.

## Step 1: Verify Current State

1. Check the current branch:

   ```bash
   git branch --show-current
   ```

2. Ensure there are no uncommitted changes:

   ```bash
   git status --porcelain
   ```

   If there are uncommitted changes, either:
   - Commit them first, or
   - Ask the user how to proceed (commit, stash, or abort)

## Step 2: Fetch Latest Changes

Fetch the latest changes from the remote:

```bash
git fetch origin main
```

## Step 3: Rebase onto origin/main

Start the rebase:

```bash
git rebase origin/main
```

### If rebase succeeds without conflicts:

Proceed to Step 5.

### If conflicts occur:

1. Identify conflicting files:

   ```bash
   git diff --name-only --diff-filter=U
   ```

2. For each conflicting file:
   - Read the file content to understand the conflict
   - Analyze both versions (HEAD and origin/main)
   - Resolve the conflict by choosing the appropriate changes or merging them
   - Stage the resolved file:
     ```bash
     git add <resolved-file>
     ```

3. Continue the rebase:

   ```bash
   git rebase --continue
   ```

4. Repeat until all conflicts are resolved and rebase is complete.

## Step 4: Handle Rebase Failure

If unable to resolve conflicts automatically:

- Show the conflicting files and conflict markers to the user
- Ask for guidance on how to resolve
- If the user wants to abort:
  ```bash
  git rebase --abort
  ```

## Step 5: Push Changes

After successful rebase, force push to update the remote branch:

```bash
git push --force-with-lease
```

Note: `--force-with-lease` is safer than `--force` as it prevents overwriting others' work.

## Step 6: Report Result

Summarize the operation:

1. Number of commits rebased
2. Any conflicts that were resolved
3. Confirmation that the branch is now up-to-date with origin/main

© dyoshikawa · MIT · dyoshikawa/rulesync

Similar skills

All skills for Git and GitHub →

From the same set11

rulesync-feature-research Maps rulesync features against coding-agent docs: what is supported, where the gaps are, how clients differ. CX Codex +1 ★ 1,552repo stars resolve-scrap-issues This skill walks the newest GitHub issues labeled maintainer-scrap, validates each one, then either closes it or opens a single pull request that fixes the rest. CX Codex +1 ★ 1,552repo stars prs-awaiting-author Lists open pull requests where the next move belongs to the author: failing CI, unaddressed review comments, or a maintainer question waiting on a reply. CX Codex +1 ★ 1,552repo stars porting-another-repository Reads a feature in your current repo and the target repo's conventions, then writes a porting plan into tmp/ as files you apply yourself. CX Codex +1 ★ 1,552repo stars goal-release Drives a release end to end: opens the PR, waits for green CI, merges it and updates the Homebrew formula. Handy when a version has to ship in one go. CX Codex +1 ★ 1,552repo stars git-worktree-runner A skill that teaches the agent to drive git worktrees through the gtr CLI: create, open in an editor, run commands, remove. CX Codex +1 ★ 1,552repo stars draft-issue-to-external-repository Drafts a GitHub issue for a repository you do not own: reads the project's templates and title style, settles scope with you, and saves the body to a file. CX Codex +1 ★ 1,552repo stars create-issue A skill that walks through issue creation step by step: gathers context, checks the codebase, drafts English text, and assigns labels. Handy when you want a tidy issue without doing it manually. CX Codex +1 ★ 1,552repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor