/workspace:submodule-relayfrom workspace
git submodule 容器的提交與同步接力——子模組 commit → push → 上層 pointer bump,以及 pull/rebase 後驗 pointer 沒倒退。含 `M` 的方向判讀(何時 bump、何時該 pull、何時別動)。Use when 在 submodule 容器 repo 提交或同步、「bump pointer」「commit submodule」「push 子模組」「pull submodule」「submodule 顯示 M」「上層 repo 要不要更新 ref」。
Ships in workspace. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
容器 repo(上層)只記每個子模組的 commit pointer;真正的變更在子模組裡。接力順序固定: 子模組 commit → 子模組 push 成功 → 上層 bump pointer。順序反了或中間斷了,上層就會記一個遠端不存在的 commit,別人 clone 直接壞。
提交訊息格式、逐檔暫存、多 agent 並行安全一律照 commit;本 skill 只管子模組特有的部分。
.gitmodules 讀,不寫死git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | awk '{print $2}'
git config -f .gitmodules --get-regexp '^submodule\..*\.branch$' # 有設才有,沒設就看該子模組 origin/HEAD
任何掃描(哪些子模組有變更、哪些落後遠端)都以這份清單為準,不在文件或 skill 裡維護靜態對照表——子模組增刪時靜態表一定會漂移。
git status 上的子模組狀態.gitmodules 的 ignore 級別決定上層 git status/git diff 看得到什麼:
ignore | 會報 |
|---|---|
none | ? + m + M |
untracked | m + M |
dirty | M |
all | 全部沉默——連 M 都藏 |
? 子模組有未追蹤檔|m 子模組有已追蹤改動|M 子模組 HEAD 與上層記錄的 pointer 不一致。
M 是 bump 的訊號;?、m 多半是別人進行中的工作,不是你該收的。all 時 pointer 倒退也是隱形的。要看全貌用 git status --ignore-submodules=none。git config -f .gitmodules --get-regexp ignore。M:先分方向,兩種處置相反取值:
idx=$(git ls-tree HEAD <path> | awk '{print $3}') # 上層記錄的 pointer(index)
co=$(git -C <path> rev-parse HEAD) # 子模組目前 checkout
git -C <path> fetch --quiet origin
| 方向 | 判準 | 動作 |
|---|---|---|
| index 落後 checkout | git -C <path> log --oneline $idx..$co 有東西 | 且 checkout 已在遠端 → bump |
| index 超前 checkout | git -C <path> log --oneline $co..$idx 有東西 | git -C <path> pull 讓工作目錄追上,不要 bump——bump 等於把別人推上去的 commit 靜默 revert |
| 兩邊分叉 | 兩向都有 | 先查是誰的工作,不要自行收斂 |
| checkout 領先但未推遠端 | git -C <path> branch -r --contains $co 為空 | 不要 bump,先 push 子模組(或交給它的主人) |
「pointer 不一致就 bump」是錯的直覺:index 超前時照做會把上層 pointer 寫回舊 commit,而在 ignore = all 下這個倒退連 git status 都看不到。
commit 流程,用 git -C <path> ... 操作,不 cd 進去(shell 停在子模組裡,後續指令容易打錯 repo)。git -C <path> push,單獨一次呼叫,讀它的 exit code。
git -C <path> push 2>&1 | tail -2 && git add <path> && git commit ...:管線的 exit code 是 tail 的 0,push 被拒也照樣往下 bump。要串就 set -o pipefail 或乾脆分兩步。git -C <path> branch -r --contains $(git -C <path> rev-parse HEAD) 必須非空。git add <path>
git diff --cached --name-only # 只該有這個子模組;多的 git restore --staged 移出
git commit -m "chore: bump <name> pointer (<子模組 commit 主旨>)"
git -C <path> fetch 後 git -C <path> status -sb,找 behind。git fetch --no-recurse-submodules:預設會連帶抓子模組,遇到 "not our ref" 時整個 exit 1,但上層 fetch 本來就不需要子模組。git -C <path> pull,逐一回報結果;衝突顯示原始錯誤,不自動解。git submodule update --recursive子模組本身可能是自帶大量巢狀 submodule 的 monorepo,--recursive 會全部 clone(量級可達數百 MB),
錯誤又常被管線吞掉,事後才發現工作目錄變髒。只更新指名子模組:
git submodule update --init <path> # 不加 --recursive
誤拉後,在該子模組內 deinit 不該 init 的巢狀子模組(zsh 不會把換行拆成多參數,走 xargs):
git config --file .gitmodules --get-regexp path | awk '{print $2}' | xargs git submodule deinit -f --
deinit 不清 .git/modules/.../modules/ 下的 gitdir,要騰空間另外刪。
只改 pointer 的 commit 曾在 rebase 時被靜默丟掉(沒報錯、todo 裡也沒有 pick),git diff 看不出來。只要 @{u}..HEAD 非空:
git log --format=%s @{u}..HEAD(領先 commit 標題)、每個子模組的 git ls-tree HEAD <path>。@{u}..HEAD 裡(rebase 改 SHA,比標題不比 SHA)。git -C <path> merge-base --is-ancestor <舊> <新>。git reflog 找回或補 bump,修法由使用者決定。先 git -C <path> merge-base --is-ancestor <a> <b> 判新舊,再用較新的那個:
git update-index --cacheinfo 160000,<sha>,<path>。
| 念頭 | 實際上 |
|---|---|
| 「status 顯示 M,bump 一下就好」 | 先分方向;index 超前時 bump 是 revert |
| 「push 應該成功了,接著 bump」 | 沒讀到 push 的 exit code 就不算成功 |
「pull 完順手 submodule update --init --recursive」 | 只 init 指名子模組,不遞迴 |
| 「rebase 沒報錯,直接 push」 | 先比領先 commit 數與 pointer |
commit — 訊息格式、逐檔暫存、並行安全worktree — 別的 session 有未推 commit 時另開lifecycle:release(可選,lifecycle plugin)— 發版時子模組的處理見該 skill 的 submodules reference;沒裝 lifecycle 就照本 skill 的接力順序做What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub kerryhuang/plugharbor --plugin workspace13 skills in this plugin
/agent-orchestration適用於多階段 agent chain(≥2 個 agent 接力)、需要用 output file 交棒、把多步工作流展示給使用者確認、偵測到「工作完成」需清理階段性產物、跨 agent 任務串接決策。涵蓋 chain 規範、output 路徑、清理流程、工作流呈現格式、subagent 作為 context 隔離工具的使用時機。觸發語:「召喚某 agent」「多階段流程」「工作流規劃」「agent 交棒」。/commit建立符合 Conventional Commits 規範的提交訊息,支援 Git Flow+Semantic Release。Use when 你自己要下 git commit(含自動流程中)、使用者說「commit」「幫我提交」。/context-hygieneUse when 對話很長 / context 快滿 / 連續修同一錯誤失敗 / 即將切換到無關任務 / 要讀大量檔案探索 / agent 交接(handoff)/ 對話要搬到別的專案目錄 / 使用者說「對話太長」「感覺變笨」「context 滿了」「要不要清一下」「clean context」時。Other plugins' skills for the same job