Get the FREE Ultimate OpenClaw Setup Guide →

rebase-assistant

npx machina-cli add skill jmerta/codex-skills/rebase-assistant --openclaw
Files (1)
SKILL.md
2.2 KB

Rebase assistant

Goal

Rebase the current branch onto a target branch safely, with built-in conflict resolution guidance.

Inputs to confirm (ask if missing)

  • Target branch (explicit branch name or "default branch").
  • Preferred conflict bias when ambiguous: keep ours, keep theirs, or manual merge.
  • Protected paths or file types to avoid touching.

Workflow

  1. Identify the target branch
    • If user says "default branch": discover via git remote show origin (read "HEAD branch").
    • If ambiguous or no remote: ask the user which branch to use.
  2. Preflight checks
    • git status -sb (must be clean before rebase).
    • git fetch --prune to sync remotes.
    • Optional safety branch (ask before creating): git branch backup/<current-branch>.
  3. Start the rebase
    • git rebase <target-branch>
  4. If conflicts occur, resolve (repeat per file)
    • Inspect conflict list:
      • git status -sb
      • git diff --name-only --diff-filter=U
    • Classify and inspect:
      • Content conflicts: open file, resolve markers.
      • Delete/modify or rename conflicts: decide keep vs delete explicitly.
      • Binary conflicts: choose ours/theirs only.
    • Show base/ours/theirs when useful:
      • git show :1:<path>
      • git show :2:<path>
      • git show :3:<path>
    • File-level choice when safe:
      • git checkout --ours <path>
      • git checkout --theirs <path>
    • Stage resolved files: git add <path>
    • Continue: git rebase --continue
  5. Finish and verify
    • Ensure no conflicts: git status -sb
    • Suggest a fast test/build if available.

Safety rules

  • Never run git reset --hard, git clean -fd, or git rebase --abort unless the user explicitly requests it.
  • Always show candidate commands before applying destructive changes.

Deliverables

  • The exact rebase command used and target branch.
  • Conflict list grouped by type with per-file resolution guidance.
  • Completion command and a short verification suggestion.

Source

git clone https://github.com/jmerta/codex-skills/blob/main/rebase-assistant/SKILL.mdView on GitHub

Overview

Guides a safe rebase of the current branch onto a target branch and includes built-in conflict resolution guidance. It covers identifying the target (including default branch via origin), preflight checks, conflict triage, and completion verification to reduce risk.

How This Skill Works

The assistant identifies the target branch (default or explicit), performs preflight checks like git status -sb and git fetch --prune, and optionally creates a safety backup branch. It runs git rebase <target-branch>, then, on conflicts, lists conflicting files (git status -sb, git diff --name-only --diff-filter=U), classifies conflict types, shows base/ours/theirs where helpful (git show :1:<path>, etc.), applies per-file choices (git checkout --ours/theirs), stages with git add, and continues with git rebase --continue until complete. It then verifies with git status -sb and a recommended test/build if available, and reminds about safety rules.

When to Use It

  • You want to rebase the current feature branch onto the default or a specific target branch.
  • You need to update a branch by rebasing while preserving local commits.
  • Conflicts occur during a rebase and you need structured triage and resolution guidance.
  • You want to determine the target branch automatically (default) or confirm a specific one before rebasing.
  • You want a careful, guided rebase workflow with safety checks and a verification step after completion.

Quick Start

  1. Step 1: Confirm target branch (default or explicit) and desired conflict bias.
  2. Step 2: Ensure a clean working tree and run git fetch --prune; optionally create git branch backup/<current-branch>.
  3. Step 3: Run git rebase <target-branch>, resolve conflicts per file (git checkout --ours/theirs <path>), then git add <path> and git rebase --continue; finish with git status -sb and a quick verification.

Best Practices

  • Keep a clean working tree (git status -sb must be clean) before starting a rebase.
  • Fetch and prune remotes (git fetch --prune) to ensure you rebasing onto the latest target.
  • Consider creating a safety backup branch (backup/<current-branch>) before starting.
  • Resolve conflicts file-by-file with explicit choices (ours/theirs) and verify each resolution.
  • Always show candidate commands before applying potentially destructive changes and verify with a final status.

Example Use Cases

  • Rebase feature/login onto main before submitting a PR.
  • Rebase bugfix/ci onto develop after upstream updates.
  • Handle a multi-file conflict when rebasing ui-components over master.
  • Use a safety backup branch prior to rebase in a high-stakes branch.
  • Infer the default target from origin HEAD and rebase accordingly.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers