agentleFS
TJaenichenTJaenichen/claude-code-harness/skills/project/rebase-main/SKILL.md

rebase-main

Skill0 starsChanged 3 months agoMITView on GitHub

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

  • Deletes or force-pushes
  • Commits and pushes

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

18 rules. About 0 are common, 14 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Run git rev-parse --abbrev-ref HEAD to get the current branch name.

    line 17
  2. Distinctive:

    Safety check: if on main or master, stop and warn the user.

    line 18
  3. Distinctive:

    Run git status --porcelain to check for uncommitted changes.

    line 19
  4. Distinctive:

    If there are uncommitted changes, stop and warn the user.

    line 20
  5. Distinctive:

    Run git fetch origin to get the latest remote state.

    line 24
  6. Very specific:

    Run git rev-list --count HEAD..{main-branch} to see how many new commits are on main.

    line 25
  7. Distinctive:

    If 0 commits incoming, report "Already up to date with {main-branch}" and stop.

    line 26
  8. Distinctive:

    If the rebase stops due to conflicts:

    line 32
  9. Very specific:

    Run git diff --name-only --diff-filter=U to list conflicted files.

    line 33
  10. Distinctive:

    Both sides changed: Use your best judgment based on the code context.

    line 39
  11. Distinctive:

    After all conflicts in the current step are resolved, run git rebase --continue.

    line 42
  12. Distinctive:

    If more than 3 conflict rounds occur, abort the rebase (git rebase --abort) and report to the user that manual resolution is needed.

    line 44
  13. Distinctive:

    If there are uncommitted changes, do not proceed — ask the user first

    line 72
  14. Distinctive:

    If a conflict resolution is ambiguous, abort the rebase rather than guessing wrong

    line 73
  15. Very specific:

    Always use git rebase --continue (never --skip) after resolving conflicts

    line 74
  16. Very specific:

    Use --force-with-lease (not --force) in the push reminder — it's safer

    line 75
  17. Distinctive:

    After completion, do NOT push — leave that to the user, but remind them about force-push if needed

    line 76
  18. Distinctive:

    If anything goes wrong mid-rebase, run git rebase --abort to return to the original state

    line 77

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.