worktree
Manage ICN git worktrees: create, status, cleanup, rebase. Usage: /worktree [status|create <name>|cleanup|rebase <name>]
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Manage ICN git worktrees: create, status, cleanup, rebase. Usage: /worktree [status|create <name>|cleanup|rebase <name>]
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
ICN development companion for the InterCooperative Network Rust monorepo. Use when working on ICN code, docs, deployment, or protocol design. Provides crate-aware routing to specialist agents (icn-architect, icn-economist, icn-ops), enforces project conventions, and understands the current sprint state, cluster topology, and demo flow status. Triggers on: any ICN crate names, "cooperative contract", "mutual credit", "governance", "gossip", "K3s", "icn-dev", "ops/mcp", "Sprint", "demo flow", "CCL", "federation", "DID", "ledger", "trust graph", "icnd", "icnctl".
Full sprint-batch or stacked-PR integration pipeline. Owns merge order, rebases, local gates, and main sync.
Full sprint-batch or stacked-PR integration pipeline. Owns merge order, rebases, local gates, and main sync.
Show full ICN development status dashboard — active sessions, sprint tasks, worktree freshness, CI state, and cluster health
ICN session preflight. This skill should be used when the user explicitly invokes "/icn-agent-pack:preflight", or asks to "run preflight", "orient me on ICN", or "check the ICN session environment". Loads canonical docs and the latest handoff, then verifies branch, gh auth, ports, toolchain, and a light cargo check. Read-only; reports, never fixes.
ICN repo navigator / knowledge graph. This skill should be used when the user explicitly invokes "/icn-agent-pack:navigator", or asks to "map the repo", "build/refresh the knowledge graph", "trace this concept to its source", or "show the conceptual map / impact map". Begins the living repository knowledge-graph and conceptual-map workflow, grounded in the icn-ops MCP tools and (future) generated graph artifacts.
| name | worktree |
| description | Manage ICN git worktrees: create, status, cleanup, rebase. Usage: /worktree [status|create <name>|cleanup|rebase <name>] |
| disable-model-invocation | true |
| truth_contract | {"canonical_sources":["ops/state/config/repo-map.json"],"live_load_required":["git worktree list"],"examples_only":[]} |
Manage ICN git worktrees. Worktrees live at <REPO_ROOT>/../icn-wt/ (from repo-map.json#worktrees.root).
Always resolve paths dynamically — never assume an absolute path:
REPO_ROOT="$(git rev-parse --show-toplevel)"
WORKTREE_ROOT="${REPO_ROOT}/../icn-wt"
Parse the argument to determine the subcommand. If no argument or unrecognized, default to status.
/worktree status (default)Try the MCP tool first:
call: worktree_status
If MCP is available, format output as:
Worktrees (N)
| Name | Branch | Behind Main | Claimed By |
|------------------------|-------------|-------------|-------------------|
| main | main | current | — |
| 1234-feature-name | feat/1234 | 2 | — |
| 1120-example | feat/1120 | 15 ⚠️ | — |
Flag ⚠️ if behind main > 10 commits.
If MCP unavailable, fall back to:
REPO_ROOT="$(git rev-parse --show-toplevel)"
WORKTREE_ROOT="${REPO_ROOT}/../icn-wt"
ls "${WORKTREE_ROOT}/" 2>/dev/null || echo "no worktrees"
Then for each directory:
git -C "${WORKTREE_ROOT}/<name>/icn" rev-parse --abbrev-ref HEAD 2>/dev/null
git -C "${WORKTREE_ROOT}/<name>/icn" log -1 --format="%cr: %s" 2>/dev/null
/worktree create <name>Creates a new worktree and branch for feature work.
REPO_ROOT="$(git rev-parse --show-toplevel)"
WORKTREE_ROOT="${REPO_ROOT}/../icn-wt"
git -C "${REPO_ROOT}" worktree add "${WORKTREE_ROOT}/<name>/icn" -b feat/<name>
On success, report:
Created worktree: <WORKTREE_ROOT>/<name>/icn
Branch: feat/<name>
To start working: cd <WORKTREE_ROOT>/<name>/icn
On failure (e.g. branch exists), show the git error and suggest:
git -C "${REPO_ROOT}" worktree list
/worktree cleanupRemove stale worktrees that are no longer needed.
Step 1: Check what's stale
REPO_ROOT="$(git rev-parse --show-toplevel)"
git -C "${REPO_ROOT}" worktree list
Step 2: Check merged branches (note: squash-merged branches won't appear here — check PR state via gh):
git -C "${REPO_ROOT}" branch --merged origin/main | grep feat/
Step 3: For each merged branch with a worktree, confirm before removing:
"Remove worktree <name> (branch feat/<name> is merged to main)? [y/N]"
If confirmed:
git -C "${REPO_ROOT}" worktree remove "${WORKTREE_ROOT}/<name>/icn"
Step 4: Prune stale references:
git -C "${REPO_ROOT}" worktree prune
Report: N worktrees removed, N pruned.
Safety: Never remove a worktree with uncommitted changes or claimed by an active session (check MCP list_sessions first if available).
/worktree rebase <name>Rebase a worktree's branch onto latest origin/main.
REPO_ROOT="$(git rev-parse --show-toplevel)"
WORKTREE_ROOT="${REPO_ROOT}/../icn-wt"
git -C "${WORKTREE_ROOT}/<name>/icn" fetch origin
git -C "${WORKTREE_ROOT}/<name>/icn" rebase origin/main
Report:
git rebase --continue"If the worktree has uncommitted changes, warn and stop:
git -C "${WORKTREE_ROOT}/<name>/icn" status --porcelain
"⚠️ Worktree has uncommitted changes — stash or commit before rebasing."