Skip to content
Agentmart
Submit a tool

smart-rebase

Smart partial rebase for squash-merge repositories.

Skill by sd0xdev

IndexedMIT★ 194
Write a review

Chalk Labs

Need help deploying smart-rebase?

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/sd0xdev-smart-rebase

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

Smart partial rebase for squash-merge repositories. Auto-detect which commits to keep/drop when base branch was squash-merged into target. Use when: user says 'rebase', 'partial rebase', 'base already merged', 'smart rebase', or /smart-rebase. Not for: simple git rebase (the developer runs it — no skill executes rebase for them), merge conflict resolution (use /merge-prep), branch switching (the developer runs git checkout). Output: rebase plan table + a shell-quoted git rebase --onto command for the developer to run after the ambiguity check in Step 5.

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
Runs as
Shell scripts

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/smart-rebase

Tools it pre-approves 5

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

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

What's inside

Skill name
smart-rebase
Description
Smart partial rebase for squash-merge repositories. Auto-detect which commits to keep/drop when base branch was squash-merged into target. Use when: user says 'rebase', 'partial rebase', 'base already merged', 'smart rebase', or /smart-rebase. Not for: simple git rebase (the developer runs it — no skill executes rebase for them), merge conflict resolution (use /merge-prep), branch switching (the developer runs git checkout). Output: rebase plan table + a shell-quoted git rebase --onto command for the developer to run after the ambiguity check in Step 5.
License
MIT
Allowed tools
Bash(git:*),, Bash(bash:*),, Read,, Grep,, Glob
Instructions
575 lines in SKILL.md · view on GitHub

Before installing

  • Ships executable scripts
  • Pre-approves some shell commands

Agent Skills spec issues

  • body: 575 lines (spec recommends under 500)

Files (2)

  • SKILL.md
  • smart-rebase-analyze.sh · scripts/

SKILL.md (first lines)

# Smart Rebase — Partial Rebase for Squash-Merge Repos

Analyze branch history → identify squash-merged commits → generate precise `git rebase --onto` command.

## When NOT to Use

- Simple `git rebase` without squash-merge complexity — **the developer runs it**; no skill runs
  `rebase` for them, this one included, and the one credential that reaches it is the user's own
  message naming that execution (§ Permissions). "Use git directly" is an instruction to the human,
  and this list is read by the dispatcher before § Permissions loads, so it says so here
- Merge conflict resolution (use `/merge-prep`)
- Branch management or switching — the developer runs the git command
- Cherry-picking specific commits (use `git cherry-pick`)

## Core Problem

In squash-merge repositories, when a feature branch is based on another branch that was already squash-merged:

```
main:    A ─── S (squash merge of B1+B2+B3) ─── ...
              ↑
feature: A ─ B1 ─ B2 ─ B3 ─ F1 ─ F2 ─ F3
              ↑ drop (in S)   ↑ keep (unique)
```

Need: `git rebase --onto main B3 feature` to keep only F1-F3.

## Permissions

Claude **must not** execute `git rebase` — **no workflow authorization lifts this**, this skill's
included. The one credential that does reach it is Register #4's `user-authorized execution`: the
user's own message naming that execution, which this skill can neither grant, request nor infer.
`rebase` is a destructive operation under Anchor Register #4 (`@rules/discretion.md`), whose
enumerated approval workflows are a closed set: `/push-ci` (push), `/smart-commit --execute` (add + commit),
`/epic-merge` (rebase --onto, force-with-lease, squash-merge) and `/gh-stack`
(`gh stack link` / `push` / `submit --auto`). This skill is not on that list, so
user approval here cannot create the exception — adding a workflow to the list is itself an
Anchor-level change. This skill **outputs** the rebase command; the developer runs it.

> **Note on `allowed-tools`**: `Bash(git:*)` is granted because Steps 1–3 read history (`git log`,
> `git rev-parse`, `git branch --show-current`), and `Bash(bash:*)` to run the analysis script —
> the latter cannot be narrowed to specific script paths until
> [#9354](https://github.com/anthropics/claude-code/issues/9354) is resolved. **A tool grant is not
> an authorization**: what may be executed is decided by the rule above, not by what the permission
> string happens to permit.

## Prerequisites

Before starting, validate:

| Check | Command | Fail action |
|-------|---------|-------------|
| Not on a protected branch | `git branch --show-current` must not match the **complete** protected set defined in `@rules/git-workflow.md` § Prohibited (which lists the complete protected set): `main`, `master`, `develop`, `release/*`. Do not re-spell a shorter list here — a partial copy is how `master` and `release/*` reached the force-push suggestion below | Abort with warning |
| Clean working tree | `git status --porcelain` must be empty | Abort: "stash or commit changes first" |
| Not detached HEAD | `git symbolic-ref HEAD` succeeds | Abort: "checkout a branch first" |

## Names in commands

Every command this skill outputs carries ref names, and **a ref name is not display text**:
`git check-ref-format` accepts `;`, backticks, `$( )` and `'` inside one — all measured. A name
substituted into a command as a bare word runs whatever it contains, and a fixed pair of single
quotes is broken by a name containing `'`.

So every `<…>` slot in a command block below is written `<quoted …>`: substitute a **shell-quoted**
value, single-quoted with each `'` rendered as `'\''`.

**Shell-quoting is only half of it, and the other half is git's own option parser.** Quotes are
consumed by the shell; git never sees them, so a branch named `--all` is still an option when it
arrives. Measured: `git check-ref-format refs/heads/--all` exits 0, and
`git push --force-with-lease origin '--all'` pushed **every** branch in the repository, not the one
named. The mechanism the templates below rely on is the **`--` / `--end-of-options` separator**,
placed before the ref operand — not fully-qualifying it. That distinction is load-bearing for one
operand in particular: a `git rebase` **branch** operand written `refs/heads/<branch>` is measured
to land on a **detached HEAD** and never move the branch, which is the whole point of the command,
whereas the same short name after `--` stops the option parser and — **when the short name resolves
unambiguously** — updates the ref. That qualification is not hypothetical and the separator does not
supply it: with a branch `refs/heads/tags/v0.0.1` and a tag `v0.0.1` both present,
`git rebase --onto main main -- 'tags/v0.0.1'` **exits 0 and leaves the branch unmoved** (measured —
`docs/features/ref-name-hardening/requests/2026-08-20-ref-name-hardening-r1.md` finding 1). Until the
ambiguity probe that closes this lands (that ticket's AC 1), **the emitted `rebase_command` is not
safe to run verbatim on a repository where the current branch name could also name a tag** — check
`git rev-parse --verify` for an `is ambiguous` warning on the operand before running it. So the
separator, carried in the template, is the rule — `--` for `git push` and `git rebase`,
`--end-of-options` for `git merge-base` and for `git log --not` (Step 6); a `<quoted branch>` after
it stays a short name on purpose. **Which spelling matters, and where, is measured — not a blanket
rule.** Measured on git 2.55.0 in this repository:

| Command | `--` | `--end-of-options` | Consequence |
|---------|------|--------------------|-------------|
| `git push`, `git fetch`, `git merge-base` | accepted | accepted | **Interchangeable.** Picking one is a convention, not a correctness requirement |
| `git log … --not <name>` | forces `<name>` to a **pathspec** — a name that is neither ref nor file yields nothing at exit 0 | keeps rev/path disambiguation — the same name exits **128** with `ambiguous argument` | **Not interchangeable.** `--end-of-options` fails closed; `--` fails silently. Step 6 uses `--end-of-options` for this reason |
| `git rev-parse` | — | **echoes the separator literally**, then resolves | Neither separator helps. Use `git rev-parse --verify --quiet refs/heads/<name>` |
| `git check-ref-format --branch` | rejected (exit 129) | rejected (exit 129) | Honours neither, so the script validates a source by its full `refs/heads/…` form instead |

The separator terminates **option** parsing, never **refspec** parsing: `git push origin -- '+main'`
still reads the leading `+` as the force modifier, and `git check-ref-format --branch '+main'` exits
0, so a lexical protected-branch check passes a branch literally named `+main`. Emit fully-qualified
refspecs (`'refs/heads/<n>:refs/heads/<n>'`) rather than short names wherever a `+` could appear.
This is the same fact § Step 5 states about the analysis script: the resolved operand is what git
acts on, never the spelling that was typed.

The slot also **brings its own quotes** —
never wrap one in a further fixed pair. `'--base=<quoted branch-or-commit>'` reads as safe and is
not: substituting `feat/x;printf${IFS}PWN` yields `'--base='feat/x;printf${IFS}PWN''`, which the
shell splits into an analysis call and a second command (measured), and a name containing `'` turns
it into a syntax error. Write the fixed prefix unquoted, adjacent to the slot:
`--base=<quoted branch-or-commit>`. Where the analysis script has already
produced the string — its `rebase_command` field, and the `git fetch …` line in its failure
message — copy that string rather than rebuilding it; `sh_quote` in the script is the same rule,
already applied. Reasons in full: `docs/features/ref-name-hardening/4-implementation.md` § 1.

## Workflow

```
Step 1: Analyze → run script to detect commits
Step 2: Identify → determine keep/drop boundary (cut point)
Step 3: Display → output rebase plan
Step 4: Confirm → user reviews
Step 5: Output → print the rebase command for the developer to run

From sd0xdev/sd0x-harness, MIT.

Signals

Stars
194
Forks
26
Open issues
5
Last commit (this folder)
Sep 23, 2026 (1 month ago)
Last release
Oct 6, 2026 (25 days ago)

From GitHub (fetched Oct 24, 2026).

Details

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

More from sd0xdev

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 smart-rebase 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 smart-rebase?

CallGet help
Cite this page

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