rebase-clean
Performs a strict clean rebase of a feature branch onto main with minimal conflict resolution and full validation. Use when the user asks to rebase carefully,…
npx skills add https://github.com/openshift/lightspeed-service --skill rebase-cleanClean Rebase Workflow
Use this workflow exactly for rebases in this repository.
Rules
- Do not create extra temporary branches unless the user explicitly asks.
- Do not make unrelated edits.
- Do not stop after analysis; finish rebase and validation.
- Keep output brief and operational.
- Never assume target branch names; detect current branch first.
Step 0: Detect Branch Context
- Run
git branch --show-current. - Treat detected current branch as the candidate target branch.
- Ask user to confirm explicitly before proceeding:
I detected '<current-branch>' as the current branch. Should I rebase this branch?
- If user specified a target branch, verify it matches current branch; if not, stop and ask.
- Do not run reset/rebase commands until this confirmation is received.
- Before any reset/rebase command, restate:
- current branch
- target branch
- approved baseline ref and confirm when there is any mismatch or ambiguity.
Step 1: Restore Branch Baseline (Rerun Only)
Use this step only when a prior rebase attempt failed or introduced unwanted edits. For a first rebase attempt, skip this step and go directly to Step 2.
- Checkout target branch.
- Hard reset to the known backup/base commit the user approved.
- Fetch
origin.
Command pattern:
git checkout <branch>
git reset --hard <backup-or-approved-base>
git fetch origin
Step 2: Rebase Onto Main
Run:
git rebase origin/main
If conflicts occur, resolve only the conflicted files. Do not add extra refactors.
Step 3: Conflict Resolution Policy
For each conflicted file:
- Start from one side (
oursortheirs) as a temporary base. - Apply only minimal compatibility changes required to compile and run tests on the new base branch.
- Keep behavior from the feature commit unless it is incompatible with upstream removals/renames.
- Resolve matching tests together with production code changes.
- Avoid opportunistic refactors during conflict resolution.
Then:
git add <resolved files>
GIT_EDITOR=true git rebase --continue
Repeat until rebase completes.
Step 4: Verify No Code Loss
Run these checks against the approved pre-rebase baseline (backup/base commit):
git range-diff origin/main...<approved-base> origin/main...HEAD
git diff --name-status <approved-base>..HEAD
git merge-base --is-ancestor origin/main HEAD
git log --left-right --cherry-pick --oneline origin/main...HEAD
Acceptance criteria:
- Branch intent is preserved:
- Commit intent maps cleanly in
range-diff(rewritten SHAs are fine).
- Commit intent maps cleanly in
- Main is fully incorporated:
git merge-base --is-ancestor origin/main HEADsucceeds (exit code 0).
- No unexpected file removals/renames beyond what upstream already changed.
- Any conflict-touched files have expected compatibility-only deltas.
- No unexplained drift from the approved baseline.
If any check fails, treat as code-loss risk and restart from Step 1.
Step 5: Full Validation Pipeline
Run exactly:
make test-unit && make test-integration && make verify
If validation or code-loss checks fail at any point:
- Treat it as an incorrect rebase result.
- Abort/restore to the approved baseline.
- Re-run the rebase/conflict-resolution flow from Step 1.
- Re-run Step 4 and this step.
- Repeat full loop until all checks pass.
Step 6: Final Report
Report only:
- Rebase completed (yes/no)
- Current branch and ahead/behind state
make test-unitresultmake test-integrationresultmake verifyresult
Do not include unrelated diagnostics.