Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Rebase

ASecurity

Rebase current branch onto trunk (origin/master or origin/main), predict and resolve conflicts

3 stars
0 votes
0 copies
2 views
Added 9/19/2026
ai-agentsrustgobashgit

Works with

cli

Security Analysis

A100/100

Scanned 9/19/2026

$npx -y skills add tony/skills --skill rebase --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rebase?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Rebase
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tony-rebase/badge)](https://www.skillsdirectory.com/skills/tony-rebase)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: rebase
description: >-
  Rebase current branch onto trunk (origin/master or origin/main), predict
  and resolve conflicts
disable-model-invocation: true
allowed-tools: ["Bash", "Read", "Grep", "Glob", "Edit"]
metadata:
  source: "plugins/rebase/skills/rebase/SKILL.md"
---

## Context

- Current branch: !`git branch --show-current`
- Working tree: !`git status --short`
- Remote refs available: !`git remote -v`

These run before the first turn, so each is a single command that succeeds in
any repository. Anything needing the trunk is derived in Phase 1 instead: a
repository set up with `git init` and `git remote add` has no
`refs/remotes/origin/HEAD`, and a context command that exits non-zero takes the
whole invocation with it.

## Your Task

Rebase the current branch onto the remote trunk branch. Follow these steps carefully, handling each phase before moving to the next.

### Phase 1: Detect trunk branch

Determine the trunk branch name and store it as `TRUNK`, the **bare** name — every use below prefixes it with `origin/` itself, so storing `origin/main` here would ask git for `origin/origin/main`.

Ask the remote first, because it answers before anything has been fetched:

```
git ls-remote --symref origin HEAD
```

The `ref:` line names the remote's default branch, so `TRUNK` is the part after `refs/heads/`. A repository built with `git init` plus `git remote add` has no remote-tracking refs at all until Phase 2 fetches, so local lookups cannot answer this yet.

If the remote is unreachable, fall back to `git symbolic-ref --short refs/remotes/origin/HEAD` (which prints `origin/<branch>` — take the part after the slash), and failing that to whichever of `origin/main` or `origin/master` `git rev-parse --verify` resolves.

### Phase 2: Fetch latest and analyze

1. Run `git fetch origin` to get the latest remote state.
2. Run `git diff origin/${TRUNK}...HEAD --stat` to see what files the current branch modifies.
3. Run `git diff origin/${TRUNK}...HEAD` to see the full diff of changes on this branch.
4. Run `git log --oneline origin/${TRUNK}..HEAD` to see commits that will be rebased.
5. Run `git diff origin/${TRUNK} -- $(git diff --name-only origin/${TRUNK}...HEAD)` to check if trunk has also modified any of the same files — these are potential conflict zones.

Report a brief summary of:
- How many commits will be rebased
- Which files were changed on this branch
- Which of those files were ALSO changed on trunk (potential conflicts)
- An assessment of conflict likelihood (none expected / minor / significant)

### Phase 3: Execute the rebase

Run:
```
git pull --rebase origin ${TRUNK} --autostash
```

If the rebase completes cleanly (exit code 0), skip to Phase 5.

### Phase 4: Resolve conflicts (if any)

If conflicts are detected:

1. Run `git status` to see which files have conflicts.
2. For each conflicted file:
   a. Read the file to see the conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`)
   b. Understand both sides of the conflict by examining what the branch intended vs what trunk changed
   c. Resolve the conflict by editing the file — preserve the intent of BOTH changes when possible. When in doubt, prefer the branch's changes (our work) but integrate trunk's changes if they're structural (renames, new parameters, etc.)
   d. Run `git add <file>` to mark it resolved
3. Before continuing the rebase, run the project's quality checks. Look for CLAUDE.md or AGENTS.md in the repo root to discover the project's required checks. Common quality gates by ecosystem:

   | Gate | Example commands |
   |------|-----------------|
   | Formatter | `ruff format`, `prettier --write`, `rustfmt`, `gofmt` |
   | Linter | `ruff check --fix`, `eslint --fix`, `clippy`, `golangci-lint` |
   | Type checker | `mypy`, `tsc --noEmit`, `basedpyright` |
   | Tests | `pytest`, `jest`, `cargo test`, `go test ./...` |

   If any check fails, fix the issues and re-stage with `git add` before continuing.
4. Run `git rebase --continue` to proceed.
5. If more conflicts appear, repeat from step 1 of this phase.
6. If the rebase becomes unrecoverable, run `git rebase --abort` and report what went wrong.

### Phase 5: Verify final state

After the rebase completes successfully:

1. Run `git log --oneline -10` to confirm the rebased commit history looks correct.
2. Run `git status` to confirm a clean working tree.
3. Run the project's quality checks one final time as described in Phase 4 step 3.
4. Report the results: how many commits were rebased, whether any conflicts were resolved, and the final state of all quality checks.

Do NOT force-push. Only report the final state and let the user decide on the next step.

Attribution

tonytony
View sourceSee grades on GitHubMore from tony →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698621 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →