# Rebase2main

> Rebase2main is an open-source agent skill for developer tools. Rebases your current dev branch onto main, pushes main, and switches back. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/ruan-cat/monorepo/tree/main/ai-plugins/common-tools/skills/rebase2main
- **Repository:** https://github.com/ruan-cat/monorepo
- **GitHub stars:** 5
- **License:** MIT
- **Skill name:** rebase2main
- **Collection:** https://github.com/ruan-cat/monorepo
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

This skill walks an agent through syncing the commits of the branch you are on into main. It records the current branch, checks that the working tree has no uncommitted changes, checks out main, rebases main onto the original branch, and pushes main to origin with a normal push.

The workflow is built around safety. It stops if you are already on main, stops on a dirty working tree, halts and reports if the rebase hits conflicts, and reports the reason if the push fails. It never uses a force push, and it finishes by checking out the original branch again.

The instructions are written in Chinese and rely on git and access to an origin remote. No scripts or extra reference files are bundled with the skill.

## When your agent uses it

> 将当前开发分支（通常是 dev）的提交通过 git rebase 同步到 main 分支，推送到远端， 然后切回原分支。当用户提及「同步到 main」「rebase 到 main」「更新 main」 「推送到主分支」「把 dev 合到 main」等关键词时使用此技能。 即使用户没有明确说 rebase，只要意图是把开发分支内容同步到 main，就应触发此技能。

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/ruan-cat/monorepo/tree/HEAD/ai-plugins/common-tools/skills/rebase2main)
- [License: MIT](https://github.com/ruan-cat/monorepo/tree/HEAD/ai-plugins/common-tools/skills/rebase2main)

## Features

- **Branch Recording:** Saves the name of the current branch so the agent can return to it at the end.
- **Clean Tree Check:** Confirms there are no uncommitted changes before any checkout or rebase runs.
- **Rebase onto Main:** Checks out main and rebases it onto the original development branch.
- **Safe Push:** Pushes main with a regular push and never uses force.
- **Conflict Handling:** Stops and asks the user to resolve rebase conflicts manually.

## Good for

- Sync my dev branch commits into main
- Rebase my feature branch onto main and push it
- Update main with the work from dev
- Push the development branch changes to the main branch

## Install

### Claude Code

This skill ships in the `common-tools` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add ruan-cat/monorepo
/plugin install common-tools@ruan-cat-tools
```

Or copy only this skill to `~/.claude/skills/rebase2main`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ruan-cat/monorepo.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/rebase2main &&
cp -R "$tmp/ai-plugins/common-tools/skills/rebase2main" ~/.claude/skills/rebase2main &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/rebase2main` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/rebase2main` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ruan-cat/monorepo.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/rebase2main &&
cp -R "$tmp/ai-plugins/common-tools/skills/rebase2main" ~/.agents/skills/rebase2main &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/rebase2main` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/rebase2main` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ruan-cat/monorepo.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/rebase2main &&
cp -R "$tmp/ai-plugins/common-tools/skills/rebase2main" ~/.cursor/skills/rebase2main &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/rebase2main` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/ruan-cat/monorepo.git --path ai-plugins/common-tools/skills/rebase2main
```

Or copy the folder to `~/.gemini/skills/rebase2main` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/rebase2main`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ruan-cat/monorepo.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/rebase2main &&
cp -R "$tmp/ai-plugins/common-tools/skills/rebase2main" ~/.copilot/skills/rebase2main &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/rebase2main` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/ruan-cat/monorepo.git
```

Then copy `monorepo/ai-plugins/common-tools/skills/rebase2main` into your agent's skills folder as `rebase2main`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When does Rebase2main trigger?

It triggers when you mention syncing to main, rebasing to main, updating main, pushing to the main branch, or merging dev into main, including cases where you do not say rebase but want the development branch content moved to main.

### Does Rebase2main force push?

No. The skill uses a normal git push to origin main and explicitly avoids --force to keep remote history safe.

### What happens if there are uncommitted changes?

The skill tells you to commit or stash them first and does not continue until the working tree is clean.

### What happens on a rebase conflict?

The skill stops immediately and tells you to resolve the conflict manually.

### How do I install Rebase2main in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/rebase2main to use it in all your projects, or to .claude/skills/rebase2main in one project. Or install the common-tools plugin, which includes it: /plugin marketplace add ruan-cat/monorepo, then /plugin install common-tools@ruan-cat-tools.

### Does Rebase2main run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Rebase2main?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Rebase2main?

The closest alternatives to Rebase2main are Rebase current branch, Commit push, Git merge, Check a stale branch is not undoing newer main work and Gha PR merge ref shows upstream changes.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Rebase current branch](https://ai-powered.com/skills/rebase-current-branch): Rebase current branch is an open-source agent skill for developer tools.
- [Commit push](https://ai-powered.com/skills/commit-push): Commit push is an open-source agent skill for developer tools.
- [Git merge](https://ai-powered.com/skills/git-merge): Git merge is an open-source agent skill for developer tools.
- [Check a stale branch is not undoing newer main work](https://ai-powered.com/skills/check-a-stale-branch-is-not-undoing-newer-main-work): Check a stale branch is not undoing newer main work is an open-source agent skill for developer tools.
- [Gha PR merge ref shows upstream changes](https://ai-powered.com/skills/gha-pr-merge-ref-shows-upstream-changes): Gha PR merge ref shows upstream changes is an open-source agent skill for developer tools.
- [GitHub workflow](https://ai-powered.com/skills/github-workflow): GitHub workflow is an open-source agent skill for developer tools.
- [Git branch cleanup](https://ai-powered.com/skills/git-branch-cleanup): Git branch cleanup is an open-source agent skill for developer tools.
- [Pull main](https://ai-powered.com/skills/pull-main): Pull main is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/rebase2main
