submodule-worktree

A Git workflow for managing multiple working directories and Git submodules. A worktree lets you check out another branch in a separate directory while sharing the same repository history.

In plain words
What is it for?
Use it to create and manage worktrees for a main repository and its submodules, such as developing a feature beside the main branch.
Why use it?
It lets you work on several branches or dependencies at once without repeatedly switching the files in one directory.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/cdbattags/ai/submodule-worktree
Any agent
npx skills add cdbattags/ai --skill submodule-worktree
Clone the repo
git clone --depth 1 https://github.com/cdbattags/ai

Made for: Claude Code, Codex.

Per session 62 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,131 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00062 $0.01131
Opus 5 $0.00031 $0.00566
Sonnet 5 $0.00012 $0.00226
Haiku 4.5 $0.00006 $0.00113

Measured 2d ago against content hash 3d2db4eaaa1b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

submodule-worktree scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/worktree.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

src/skills/submodule-worktree/SKILL.md · 141 lines

How it starts

The opening of the file, as written. The whole thing — 141 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Submodule & Repo Worktree Management

Worktrees let you check out multiple branches simultaneously — each worktree is a separate directory backed by the same .git store. This skill handles worktrees for both the top-level repo and any submodules within it.

Layout

workspace/
├── worktrees/                         # All worktrees (gitignored)
│   ├── _root/                         # Top-level repo worktrees
│   │   └── feature-something/         # branch: feature/something
│   ├── my-submodule/                  # Submodule worktrees (by basename)
│   │   └── feature-branch/            # branch: feature/branch
│   └── another-submodule/
│       └── fix-bug/

Script

All operations use the portable script shipped with this skill:

WORKTREE_SH="$HOME/.cursor/skills/submodule-worktree/scripts/worktree.sh"

Run it from anywhere inside the workspace.

First-time setup

The script auto-detects the git root and submodules. You only need to ensure:

  1. worktrees/ is in the workspace .gitignore
  2. Submodules are initialized (git submodule update --init)
echo 'worktrees/' >> .gitignore
git submodule update --init --recursive

Create a worktree

# Top-level repo worktree
$WORKTREE_SH add _root feature/my-branch

# Submodule worktree (use submodule basename, not full path)
$WORKTREE_SH add mdxjs-rs feature/vite-plugin

# Explicitly create a new branch
$WORKTREE_SH add mdxjs-rs feature/new-thing --new

# Base a new branch off a specific ref
$WORKTREE_SH add mdxjs-rs feature/speed-up --base main

# Combine flags
$WORKTREE_SH add mdxjs-rs hotfix/urgent --new --base v2.1.0

List active worktrees

# All targets with worktrees
$WORKTREE_SH list

# Specific target
$WORKTREE_SH list mdxjs-rs
$WORKTREE_SH list _root

Remove a worktree

$WORKTREE_SH remove mdxjs-rs feature/vite-plugin
$WORKTREE_SH remove _root feature/my-branch

Status overview

$WORKTREE_SH status

Read the full file on GitHub · 141 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 141 lines · 62 tokens per session scan A 3d2db4eaaa1b

Subscribe to this mod's changes

submodule-worktree is a skill published in the GitHub repository cdbattags/ai (4 stars, last pushed 6mo ago), licensed MIT. It adds 62 tokens to every session and 1,131 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

android-feature

Workflow for implementing a new Android feature, screen, fragment, activity, dialog, adapter, or enhancement in this XML/MVVM template. Use whenever the user asks to add, build, implement, or extend functionality — before writing any code. Covers planning, the MVVM/MVI skeleton, the Android configuration checklist…

orbitalsonic/AndroidPilot · 72 tokens

template-helpers

Catalog of the reusable building blocks shipped with this Android template — BaseActivity/BaseFragment, the helpers/ extension files (navigation, lifecycle, toast, snackbar, dialogs, images, permissions, theme, locale, settings intents, date, delay), common/ (Firebase, network, observers), and…

orbitalsonic/AndroidPilot · 92 tokens

android-new-project

Workflow for turning a fresh copy of this Android template into a new app — renaming the package/namespace/applicationId, branding (icons, splash, palette, fonts), Firebase setup, signing config, stripping unused sample screens, and verifying the foundation. Use when the user says they are starting a new app…

orbitalsonic/AndroidPilot · 83 tokens

android-preflight

Final verification checklist to run before declaring Android work finished — build, both themes, string resources, lifecycle and leak risks, registered permissions and components, resource parity between values and values-night, and honest reporting of what was and was not verified. Use at the end of any feature, fix…

orbitalsonic/AndroidPilot · 79 tokens

android-ui-theming

Rules for Android XML layouts, Material 3 components, semantic color tokens, light/dark theming, dimensions (sdp/ssp), string resources and localization, accessibility, and edge-to-edge insets. Use when creating or editing any layout, drawable, style, color, vector, or string resource, or when a screen must work in…

orbitalsonic/AndroidPilot · 81 tokens

android-upgrade

Workflow for changing an existing working Android project — upgrading dependencies, AGP/Gradle or SDK levels, migrating deprecated APIs, refactoring, and fixing bugs, without breaking what already works. Covers baseline verification, scoping the diff, targetSdk behaviour changes, SharedPreferences/Room data…

orbitalsonic/AndroidPilot · 86 tokens