code-sync
Skill0 starsChanged 15 days agoApache-2.0View on GitHub
Classify open pull requests as up to date, behind, conflicting or base moved, and bring the ones that are behind main up to date with a signed rebase, the gates and a leased push, marking each PR draft meanwhile. Use when main advanced and open PRs may need a rebase, or before merging one. Not for restacking a stack of parts (see /code-restack), for applying a Writer's patches (see /code-integrate), or for creating or editing PRs.
In this repository19 other files it gives its agents.
- AGENTS.mdAGENTS.md
- code-checkSkill
- code-formatSkill
- code-genSkill
- code-integrateSkill
- code-restackSkill
- code-reviewSkill
- code-testSkill
- commitSkill
- feat-discoverySkill
- feat-statusSkill
- feat-validateSkill
- releaseSkill
- code-rules-checkSkill
- code-rulesSkill
- docs-rules-checkSkill
- docs-rules-creatorSkill
- docs-rulesSkill
- skills-checkSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is 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.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
Run on a clean working tree.
≈ “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.
Files
Code Sync
One command that tells which open pull requests are behind their base, and with --apply brings them up to date.
It prints ONE compact JSON result and writes the raw git, gh 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
mainadvanced and open pull requests may be behind it.- A pull request is about to be merged and must sit on the current
main.
The script never resolves a conflict, never pushes an unsigned commit, never uses plain --force, never merges or
closes a pull request and never runs gh pr update-branch. Creating and editing pull requests stays with the Lead;
the only change it makes to one is the draft/ready toggle.
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-sync/scripts/sync.py --repo <repo> [--apply] <pr> [<pr> ...]| Argument | Meaning |
--repo | The repository to work in; default the current directory |
<pr>... | The pull request numbers |
--apply | Run the fast lane on each pull request that is behind; without it the script only classifies |
It fetches, then classifies each pull request from its origin/<head> and origin/<base>:
| Status | Meaning |
up_to_date | The base is already in the branch |
behind | The base is main, moved, and the branch rebases onto it cleanly |
conflicting | The base is main, moved, and the rebase would conflict |
base_moved | The base is another branch of a stack; use /code-restack |
The fast lane for a behind pull request: mark it draft, git rebase -S origin/main on a detached HEAD, run the
gates fmt-check, check, typecheck, test and check-docs (stopping at the first failure), check that every
commit is signed (%G? is G), push the rebased commit with a lease pinned to the branch's remote SHA from before
the rebase, move the local branch, and mark the pull request ready. A pull request that was already a draft is not
touched and stays one; only one this run drafted is marked ready again. A failure leaves the remote branch
untouched, and the pull request a draft. A rejected push is such a failure: the entry is refused with the
reason, and carries "drafted":true when this run drafted the pull request and did not mark it ready again. A
local branch that another worktree has checked out is not moved, since git refuses to, and its entry carries
"local_not_moved":true; the sync is still synced. When gh pr ready fails after the push, the entry stays
synced and carries "ready":false; when --undo fails the run refuses before the rebase. The caller's branch is
restored at the end.
It refuses when --repo is not a git repository, when the tree is not clean, when a pull request is not open or its
branches do not exist, when a commit is unsigned and when a push is rejected.
Result
{"status":"ok","prs":[{"pr":7,"branch":"lnsd/x","draft":false,"old_sha":"…","new_sha":"…","gates":{"fmt-check":"pass"},"push":"lease","status":"synced"}],"log":"…"}- The top-level
statusisok,needs_rebase(a pull request isconflictingorbase_moved),gates_failedorrefused;refusedcarries areason. - Each entry's
statusis one of the classifications above, orsyncedafter--apply.
Exit codes
| Code | Meaning | What the caller does |
| 0 | Every pull request is up to date or synced | Continue |
| 1 | A gate failed after the rebase | Read the log, send the failure back as a FIX |
| 2 | A pull request is conflicting or base_moved | Ask the Writer for a REBASE, or run /code-restack |
| 3 | Refused or a command failed | Read reason; fix the setup, do not work around it |
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.

