codex-rebase
Skill118 starsChanged 37 days agoMITView on GitHub
Replay the current branch onto its base and establish that the result is sound. Preflight settles the base by comparing the local default branch against origin's copy. The rebase runs under pinned settings. A range-diff afterwards says what the replay did to each commit. The gates then run against a tree no commit ever saw. Conflicts route to codex-resolve-rebase-conflicts. Use this whenever the user asks to rebase or to bring a branch current, and whenever a workflow needs the branch moved first.
- Deletes or force-pushes
- Commits and pushes
In this repository32 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- analyze-sessionSkill
- codex-analyze-sessionSkill
- codex-commitSkill
- codex-fix-proseSkill
- codex-fix-prSkill
- codex-merge-prSkill
- codex-prSkill
- codex-resolve-rebase-conflictsSkill
- codex-review-commit-messageSkill
- codex-review-pr-descriptionSkill
- codex-review-prose-fixSkill
- codex-review-squash-messageSkill
- codex-watch-prSkill
- codex-write-pr-descriptionSkill
- codex-write-prose-fixSkill
- commitSkill
- fix-proseSkill
- fix-prSkill
- merge-prSkill
- prSkill
- rebaseSkill
- releaseSkill
- resolve-rebase-conflictsSkill
- review-commit-messageSkill
- review-pr-descriptionSkill
- review-prose-fixSkill
- review-squash-messageSkill
- watch-prSkill
- write-pr-descriptionSkill
- write-prose-fixSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
Create these with update_plan, keeping exactly one item in_progress at a time.
- Very specific: line 47
Never a bare git stash pop or git stash apply.
- Distinctive: line 59
Read the output for a line about rerere replaying a recorded resolution.
- Distinctive: line 85
Use it when the conflicts say somebody cut this branch from the wrong place.
- Distinctive: line 99
Run the gate the script names:
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 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.
Files
Rebase workflow
Move the branch onto its base, then establish that what came out is right.
Codex doesn't provide a skill-scoped command hook. Use only the scripts named here to pin the rebase settings and check conflict markers before continuing. The continuation script also proves an empty skip. Never use a bare stash pop, start the rebase by hand, or force-push without a lease.
Preflight
Run bash .agents/skills/codex-rebase/scripts/preflight.sh.
Step 0: open the task list
Create these with update_plan, keeping exactly one item in_progress at a time.
- Choose the base
- Settle the working tree
- Start the rebase
- Resolve whatever it stops on
- Verify the result
- Report
Preflight reporting a merge or cherry-pick in progress stops everything. Say what's in the way and hand back. A rebase already in progress is the other case, and that one resumes at step 4.
Step 1: choose the base
Preflight computed this under == rebase base ==. Take its recommendation.
- Local default branch carries everything the remote has, so rebase onto the local branch.
- Local default branch sits behind the remote, so rebase onto
origin/<default>and skip the stale local copy.
The commit skill's preflight makes the same decision, and both reach the same answer. Where the operator specifies a different base, use theirs and say why it differs.
Nothing to replay means nothing to do. Say so and stop.
Step 2: settle the working tree
--autostash handles a dirty tree, and start-rebase.sh passes it. It scopes the save to this rebase and never touches the shared stash stack, which is what makes it the sanctioned form here.
The stashed work is outside the worktree while you resolve a conflict, so nothing you see there reflects it. It can also conflict on the way back once the replay finishes. If that durability isn't enough, stop and let the operator settle the worktree before starting. Don't invent a temporary commit or reset sequence inside this workflow.
Never a bare git stash pop or git stash apply. Worktrees share one global stash stack whose indices shift whenever any worktree pushes. A bare pop takes whatever entry is at stash@{0} right then. The guard hook refuses it.
Step 3: start the rebase
bash .agents/skills/codex-rebase/scripts/start-rebase.sh <base>Don't type the git rebase yourself. The script pins off rebase.updateRefs, an operator preference that quietly moves other local branches pointing into the replayed range. It pins off rebase.autoSquash as well, which would otherwise collapse a fixup! commit that requires its own review. Recording the pre-rebase tip is the third thing it does. Without that record, step 5 has nothing to compare against.
Exit 0 means the replay finished, so go to step 5. A 1 means it stopped, so go to step 4.
Read the output for a line about rerere replaying a recorded resolution. That's git staging a resolution from an earlier rebase without stopping, and nothing has read it since. Treat every such path as unverified.
Step 4: resolve what it stops on
bash .agents/skills/codex-rebase/scripts/rebase-status.shThat says which commit stopped, how far through the replay it sits, which paths remain unmerged, and what git staged without asking. When another workflow started the rebase, preflight reconstructs the durable before/base record from git's active rebase state so verification still has both ranges after the replay finishes. Then follow codex-resolve-rebase-conflicts. Keep the resolution in this thread because delegated agents share the filesystem and concurrent conflict edits are unsafe. The skill classifies each path before anything edits it and settles the mechanical ones itself.
Once you have staged every path:
bash .agents/skills/codex-rebase/scripts/continue-rebase.shThat reads the staged blobs for conflict markers before it advances. git checks only that no path remains unmerged, so a file you staged with <<<<<<< still in it continues straight into a commit.
Repeat from rebase-status.sh at each further stop. Where git calls a commit empty because the change is already in the base, continue-rebase.sh --skip-empty drops it after proving the index matches HEAD.
You can still give up, and doing so doesn't cost anything:
git rebase --abortUse it when the conflicts say somebody cut this branch from the wrong place. Resolving thirty of them to reach that conclusion helps nobody.
Step 5: verify the result
bash .agents/skills/codex-rebase/scripts/verify-rebase.shA rebase that ends without complaint has proved one thing: every commit applied. It has proved nothing else, and what it leaves unproved is where the trouble sits.
A resolution can lose a hunk. The commit still applies. Its message still describes the change it no longer makes, and no gate anywhere notices, because a commit that does less than it claims isn't a syntax error. The range-diff this script prints is what surfaces it. That view pairs each old commit against its replayed self, marking = where the commit came through unchanged and ! where its content moved. Expect a ! wherever you resolved a conflict. Treat one anywhere else as a question to answer before moving on.
A tree can break with no commit at fault. The base adds a gate, the branch adds a file that gate rejects, and neither side fails on its own. That combination first exists after the rebase.
Run the gate the script names:
mise run checkOr mise run lint where the repository has no check. Either way, run it against the tree as it now stands rather than against any commit in isolation, because the tree is the thing nothing has tested yet.
A failure here is an ordinary fix rather than a rebase problem. Correct it, and commit through the commit skill. Where the fix belongs inside a commit the rebase just replayed, say so and let the operator choose between a follow-up commit and an amend.
Where the branch runs long enough for a mid-history break to matter, the thorough form runs the gate at every commit:
git -c rebase.updateRefs=false rebase --exec 'mise run lint' <base>The script also lists any path the repository declares generated through rebase-resolve=regenerate. The resolution took one side of those whole, on the understanding that the generator would overwrite it. Run the generator now, and commit what it changes.
Step 6: report
Say what the base was, how many commits replayed, which paths conflicted, and how you settled each one. Give what the gates reported, and name anything the range-diff flagged.
Then hand back. Pushing is the caller's call. Because a rebase rewrites the branch, the push needs git push --force-with-lease origin HEAD. The guard refuses a bare --force, because the lease is what keeps the push from discarding whatever arrived while this session worked. Where a pull request is open, pr and watch-pr take it from there.
Where this sits
The commit skill rebases onto the base itself as its last step, and for a clean replay that rebase is all the branch needs. Come here when that rebase stops on a conflict, when the branch needs moving without a commit in hand, or when the result needs the verification step this skill runs.
Preconditions
- a git repository with a resolvable default branch
- the
codex-resolve-rebase-conflictsskill deployed alongside this one - a
mise run checkormise run linttask for the verification to run
Preflight checks each and says which are missing.
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
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.

