agentleFS
LNSDLNSD/lorecraft/.agents/skills/code-restack/SKILL.md

code-restack

Skill0 starsChanged 16 days agoApache-2.0View on GitHub

Rebase a stack of pushed part branches onto a new base, run the gates on each, check that every commit is signed, and push them with a lease. Use when the base of a stack moved (a part below merged, or main advanced) and the branches above must follow. Not for applying a Writer's patch files or squashing a part (see /code-integrate), or for syncing open pull requests.

  • Commits and pushes

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    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
  1. Very specific:

    Run on a clean working tree.

    line 23
  2. Very specific:

    Only when every branch passed does it push them all in one atomic git push, each with a lease pinned to its origin/<branch> from before the …

    line 40

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Code Restack

One command that moves a stack of part branches onto a new base. It prints ONE compact JSON result and writes the raw git and gate output to a log file, named in the result as log; read the log only when the result says something failed.

When to Use

  • A part below the stack merged, or the stack's base advanced, and every branch above must be rebased.

The script never resolves a conflict, never pushes an unsigned commit, never uses plain --force, and never merges or closes a pull request.

Command

Run on a clean working tree. --repo names the repository and defaults to the current directory, so the call needs no cd.

python3 <repo>/.agents/skills/code-restack/scripts/restack.py --repo <repo> --onto origin/main --from <old-base> lnsd/<slug>-1 lnsd/<slug>-2 ...
ArgumentMeaning
--repoThe repository to work in; default the current directory
--ontoThe ref the bottom branch moves onto, such as origin/main
--fromThe ref the bottom branch sits on now: its old base, or the tip of the part that merged
<branch>...The part branches, bottom to top, as named on the remote

It fetches, then rebases each branch from its origin/<branch> with git rebase --onto, bottom to top, each one onto the rebased tip of the branch below. After each rebase it runs the gates fmt-check, check, typecheck, test and check-docs, stopping at the first failure, and checks that every commit is signed (%G? is G). Only when every branch passed does it push them all in one atomic git push, each with a lease pinned to its origin/<branch> from before the rebase, and then move the local branches. Until then no local branch moves and nothing is pushed. A local branch that another worktree has checked out is not moved, since git refuses to; the run is still ok, because the remote moved, and the branch is listed in local_not_moved.

It refuses when --repo is not a git repository, when the tree is not clean, when a ref does not exist, when a branch does not sit on the one below it, when a local branch holds commits its remote branch lacks, and when the push is rejected, in which case no remote branch moved.

Result

{"status":"ok","stack":[{"branch":"lnsd/x-1","old_sha":"…","new_sha":"…","gates":{"fmt-check":"pass"},"push":"lease"}],"local_not_moved":[],"log":"…"}
  • status is ok, needs_rebase (with the branch that conflicted; the rebase was aborted), gates_failed (with the branch; its failed gate is fail and later gates did not run), refused or error.
  • local_not_moved lists the branches whose local copy stayed at its old tip because another worktree holds it.
  • refused and error carry a reason.

Exit codes

CodeMeaningWhat the caller does
0okContinue
1A gate failedRead the log, send the failure back as a FIX
2A rebase conflicted and was abortedAsk the Writer for a REBASE of the named branch
3Refused or a git command failedRead reason; fix the setup, do not work around it

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.