Worktree Manager Skill
Unified Git worktree and submodule management for any monorepo with git submodules — no per-repo edits needed.
Submodule Discovery
Submodule paths and default branches are auto-detected from .gitmodules at runtime — nothing is hardcoded in the scripts:
- Submodule list: read directly from
.gitmodules(git config --file .gitmodules --get-regexp path) - Default branch per submodule, in order:
- the
branch = ...entry in.gitmodules, if the repo owner set one viagit submodule set-branch --branch <branch> <path> - otherwise, the submodule's own remote HEAD (
origin/HEAD)
- the
To pin a submodule to a non-default branch (e.g. an AI-only backend that tracks develop-ai instead of develop), run git submodule set-branch once in the target repo and commit the resulting .gitmodules change — the scripts pick it up automatically, no config file to maintain.
Token-saving output modes
Every script accepts --quiet / -q alongside --yes / -y. It collapses output to one line per repo (no banner, no per-file diff dump) — prefer --quiet for routine status/commit/push checks so the tool output read back into context stays small. Only omit it when the user explicitly wants to see full file-level detail.
Script Paths
All scripts use plugin-root-relative paths:
skills/git-submodule-manager/scripts/
├── _config.sh # Shared config (auto-sourced)
├── create.sh # Create worktree
├── status.sh # Show status
├── commit.sh # Unified commit
├── push.sh # Unified push
├── pull.sh # Unified pull
└── switch.sh # Branch switching
Operation Guides
CREATE — Create Worktree
Creates a new worktree plus matching submodule branches for feature development.
Triggers: "create a worktree", "new feature branch", "feature worktree", "worktree 만들어줘", "새 기능 브랜치"
Procedure:
- Confirm feature name and base branch (default:
main) - Summarize what will be created:
- Worktree path:
../{repo-name}-{feature-name}(repo name is read from the current checkout, not hardcoded) - Main branch:
feature/{feature-name}(from main) - Submodule branches: same feature branch name on each submodule
- Worktree path:
- Run after user confirmation:
bash skills/git-submodule-manager/scripts/create.sh {feature-name} {base-branch} --yes
STATUS — Show Status
Displays the current worktree and the state of every submodule.
Triggers: "worktree status", "check branches", "submodule status", "상태 확인", "브랜치 확인"
Procedure:
- Run directly (no confirmation needed), defaulting to
--quietunless the user wants full detail:bash skills/git-submodule-manager/scripts/status.sh --quiet - Parse output and report issues:
- DETACHED HEAD → recommend checking out a branch
- Branch mismatch → suggest the
switchcommand - Unpushed commits (↑N) → suggest the
pushcommand
COMMIT — Unified Commit
Commits all changed submodules and the main repo with the same message.
Triggers: "commit", "commit changes", "commit all", "커밋해줘", "변경사항 커밋"
Procedure:
- Determine commit message:
- If provided as argument: use it verbatim
- Otherwise: analyze changes and generate a Conventional Commits–style message
(
feat:,fix:,docs:,chore:, etc.)
- Summarize changes per submodule (
--quietshows changed-file counts only, not every path) - Run after user confirmation:
bash skills/git-submodule-manager/scripts/commit.sh "{commit-message}" --yes --quiet - Commit order: each changed submodule (in
.gitmodulesorder) → main (main includes submodule pointer updates)
PUSH — Unified Push
Pushes submodules and the main repo that have unpushed commits to their remotes.
Triggers: "push", "push to remote", "push all", "푸시해줘", "원격에 올려줘"
Procedure:
- List push targets with unpushed commit counts
- ⚠️ On
--force: warn about the risk and require explicit confirmation - Run after user confirmation:
bash skills/git-submodule-manager/scripts/push.sh [--force] --yes --quiet - Push order: each submodule with unpushed commits (in
.gitmodulesorder) → main
PULL — Unified Pull
Fast-forward pulls the main repo and every submodule from their remote.
Triggers: "pull", "pull latest", "sync from remote", "풀받아줘", "최신 받아줘", "git pull"
Procedure:
- Parse optional branch name:
- If provided: pull that branch on main repo + all submodules (checkout first if needed)
- If omitted: pull each repo's current branch
- Abort if any repo has uncommitted changes (prevents merge conflicts)
- Show the pull plan (per-repo target branch)
- Run after user confirmation:
bash skills/git-submodule-manager/scripts/pull.sh [branch-name] --yes - Uses
--ff-only— stops on non-fast-forward (prevents accidental merge commits) - Pull order: main → each submodule in
.gitmodulesorder (main first so submodule pointers stay current)
SWITCH — Branch Switch
Switches branches on the main repo and every submodule at the same time.
Triggers: "switch branch", "checkout", "switch to", "브랜치 전환", "브랜치 바꿔줘", "체크아웃"
Procedure:
- Confirm target branch name and optional
--createflag - Check for uncommitted changes (abort if any exist)
- Run after user confirmation:
bash skills/git-submodule-manager/scripts/switch.sh {branch-name} [--create] --yes
Cautions
- Submodules first, always: for commit/push, submodules must be processed before the main repo
- Watch for detached HEAD: verify the branch on every submodule before making changes
--forcepush: do not use during team collaboration — requires explicit user consent- Main repo pointer updates: submodule pointer changes are staged on the main repo automatically after submodules commit