repos-sync
Use to update clones of your repositories under repos/ and see their branch, lag and uncommitted changes.
- License 许可
- MIT
- 最近更新
- 2026-10-30
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- repos-sync
- description
- Use to update clones of your repositories under repos/ and see their branch, lag and uncommitted changes.
03 SKILL.md 正文
Repository sync
Steps
- Go to the workspace root: the nearest directory, walking up from where you are, where
test -f .agents/kit.jsonsucceeds. Run every later command in that directory. - If
.local/repos.jsondoes not exist, stop and run theinitskill first: follow.agents/skills/init/SKILL.md. Wheninitfinishes, continue with step 3. - Build the repository list. Open
repos.json. When the person asked for the optionall, take every entry ofrepositories. Otherwise open.local/repos.jsonand read itsrole; take every entry ofrepositorieswhoseroleslist contains that role. Then, still in.local/repos.json, for every name inadd, take the entry ofrepos.jsonwith thatname; when there is none, put the name in the list anyway and mark it "not in repos.json". Remove every entry whosenameis inskip. When anameappears more than once, for example a name inaddthat the role already includes, keep it once. Use each entry'sname,remote,default_branchandstatus. An entry whosestatusisplanneddoes not exist yet and may have noremote, so it is never cloned or fetched. - An error line below is the first output line that starts with
fatal:orerror:. Lines such asCloning intoare not the error. When no line starts withfatal:orerror:, the error line is the last non-empty output line. - For each repository in the list, one at a time, do these sub-steps in order. Collect each row for the final table in step 6; do not print rows yet. When a sub-step says "next repository", record the row for the table and start sub-step a for the next repository.
- a. When the name is marked "not in repos.json", the action is
not in repos.json, write-for branch, behind default and dirty, run no git command, and go to the next repository. When the entry'sstatusisplanned, the action isplanned, write-for branch, behind default and dirty, run no git command, and go to the next repository. Otherwise runls -d repos/<name>. When it exists, go to sub-step c. - b. Run
GIT_TERMINAL_PROMPT=0 git clone <remote> repos/<name>.GIT_TERMINAL_PROMPT=0makes a clone that needs a password fail instead of waiting for input. When it succeeds, the action iscloned; go to sub-step d. When it fails, the action isclone failed: <error line>, write-for branch, behind default and dirty, and go to the next repository. - c. Run
GIT_TERMINAL_PROMPT=0 git -C repos/<name> fetch --prune. When it fails, rememberfetch failed: <error line>and continue with sub-step d. - d. Run
git -C repos/<name> rev-parse --abbrev-ref HEAD; its output is the branch. Rungit -C repos/<name> status --porcelain; any output means dirtyyes, no output means dirtyno. - e. When sub-step c failed, the action is
fetch failed: <error line>, write-for behind default, and go to the next repository. The branch and dirty values from sub-step d stay in the row. - f. Run
git -C repos/<name> rev-parse --verify --quiet origin/<default_branch>. When it prints nothing, the action isno origin/<default_branch>, write-for behind default, and go to the next repository. Do not merge. - g. Run
git -C repos/<name> rev-list --count HEAD..origin/<default_branch>. The number is behind default. Remember it before any merge. - h. When the action is
cloned, keep it and go to the next repository. - i. When the branch is not
default_branch, the action isskipped: on branch <branch>; go to the next repository. When dirty isyes, the action isskipped: uncommitted changes; go to the next repository. - j. When behind default is
0, the action isup to date; go to the next repository. - k. Run
git -C repos/<name> merge --ff-only origin/<default_branch>. When it succeeds, the action isfast-forwardedand behind default becomes0. When it fails, the action isdiverged, not changedand behind default keeps the number from sub-step g.
- a. When the name is marked "not in repos.json", the action is
- Report a table with one row per repository, in list order:
| Repository | Branch | Behind default | Dirty | Action | |---|---|---|---|---| | <name> | <branch> | <count> | <yes or no> | <action> |
Never
git checkoutgit switchgit stashgit resetgit cleangit pull, with merge or with rebase- deleting files in
repos/
Without Python
This skill needs no Python. It changes only clones under repos/, which git ignores, so there is nothing to check.
04 同仓库更多 Skills
verify
Use when a change in __SERVICE__ must be checked before review
work-record
Use when you finished work on a tracker task and it must be recorded in the workspace through a merge request.
task-new
Use to create one story in a stream from the stream profile's story template, link it from its scope screens and open a merge request.
task-decompose
Use to split a stream at the decomposition stage into stories - list scope screens without a story, create the accepted stories and close the stage through a merge request.
task-context
Use to gather the context of a story key or a tracker id - its story, stream stage, scope screens, repositories, decisions, mockups and work records.
repos-sync
Use to update clones of your repositories under repos/ and see their branch, lag and uncommitted changes.