Skip to content
Agentmart
Submit a tool

rebase-main

Fetch and rebase the current branch onto origin/main (or origin/master) for a clean linear history.

Skill by TJaenichen

IndexedMIT
Write a review

Chalk Labs

Need help deploying rebase-main?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/tjaenichen-rebase-main

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Fetch and rebase the current branch onto origin/main (or origin/master) for a clean linear history. Handles conflicts and reports what was done.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/rebase-main

Tools it pre-approves 5

From allowed-tools in SKILL.md: the agent may use these without asking you each time.

  • Bash(git:*),
  • Read,
  • Grep,
  • Glob,
  • Edit

What's inside

Skill name
rebase-main
Description
Fetch and rebase the current branch onto origin/main (or origin/master) for a clean linear history. Handles conflicts and reports what was done.
License
MIT
Allowed tools
Bash(git:*),, Read,, Grep,, Glob,, Edit
Instructions
72 lines in SKILL.md · view on GitHub

Before installing

  • Pre-approves some shell commands

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Rebase Current Branch onto Main

Rebase the current working branch onto the latest `origin/main` (or `origin/master`) for a clean, linear commit history. Handle conflicts and produce a summary report.

## Your Task

Execute the following steps in order:

### 1. Pre-flight checks
1. Run `git rev-parse --abbrev-ref HEAD` to get the current branch name.
2. **Safety check**: if on `main` or `master`, **stop** and warn the user. Do NOT rebase the main branch.
3. Run `git status --porcelain` to check for uncommitted changes.
   - If there are uncommitted changes, **stop** and warn the user. Ask if they want to stash or commit first. Do NOT proceed with a dirty working tree.
4. Determine the main branch: check if `origin/main` exists (`git rev-parse --verify origin/main`). If not, fall back to `origin/master`.

### 2. Fetch and rebase
1. Run `git fetch origin` to get the latest remote state.
2. Run `git rev-list --count HEAD..{main-branch}` to see how many new commits are on main.
   - If **0 commits** incoming, report "Already up to date with {main-branch}" and stop.
3. Capture the incoming commit list BEFORE rebasing: `git log --oneline HEAD..{main-branch}`.
4. Run `git rebase {main-branch}`.
5. Capture the rebase output.

### 3. Handle conflicts
If the rebase stops due to conflicts:
1. Run `git diff --name-only --diff-filter=U` to list conflicted files.
2. For **each conflicted file**:
   a. Read the file to see the conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`).
   b. Analyze the conflict:
      - **Theirs-only changes** (our side is unchanged around the conflict): accept theirs.
      - **Ours-only changes** (their side is unchanged around the conflict): accept ours.
      - **Both sides changed**: Use your best judgment based on the code context. Prefer combining both changes when they don't overlap logically. If the conflict is complex or ambiguous, **abort the rebase** (`git rebase --abort`), report the issue, and let the user handle it manually.
   c. Edit the file to remove conflict markers and apply the resolution.
   d. Run `git add {file}` to mark it resolved.
3. After all conflicts in the current step are resolved, run `git rebase --continue`.
4. Repeat steps 1-3 if the rebase stops again on subsequent commits.
5. If more than **3 conflict rounds** occur, **abort the rebase** (`git rebase --abort`) and report to the user that manual resolution is needed.

### 4. Post-rebase report
Generate a clear report with:

```
## Rebase Report: {current-branch} onto {main-branch}

### Summary
- **New commits from main:** {count}
- **Conflicts:** {count} ({list of files, or "None"})
- **Status:** {Rebased cleanly | Rebased with conflict resolution | Aborted}

### Commits from main
{list of commits from git log --oneline captured BEFORE the rebase}

### Conflict Resolutions (if any)
For each resolved conflict:
- **{filename}**: {brief description of what conflicted and how it was resolved}

### Notes
- Your local commits have been replayed on top of the latest main.
- If your branch was previously pushed, you will need to force-push: `git push --force-with-lease`
```

## Important

- **Never rebase `main` or `master`** — check the branch name first
- If there are uncommitted changes, **do not proceed** — ask the user first
- If a conflict resolution is ambiguous, **abort the rebase** rather than guessing wrong
- Always use `git rebase --continue` (never `--skip`) after resolving conflicts
- Use `--force-with-lease` (not `--force`) in the push reminder — it's safer
- After completion, do NOT push — leave that to the user, but remind them about force-push if needed
- If anything goes wrong mid-rebase, run `git rebase --abort` to return to the original state

From TJaenichen/claude-code-harness, MIT.

More from TJaenichen/claude-code-harness

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Aug 16, 2026 (2 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from TJaenichen

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get rebase-main running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying rebase-main?

CallGet help
Cite this page

rebase-main skill. Agent Mart. https://agentmart.dev/skills/tjaenichen-rebase-main (last updated 2026-10-24)