worktree
Manage worktrees only for concurrent work by the owner or agents launched by the owner on the same repository, or for explicitly requested inventory and cleanup; never create one for isolation alone.
- License 许可
- MIT
- 所属仓库
- 0xgleb/dotconfig
- 最近更新
- 2026-11-14
- Stars
- ★ 3
- Forks
- 0
01 前言 Front Matter
- name
- worktree
- description
- Manage worktrees only for concurrent work by the owner or agents launched by the owner on the same repository, or for explicitly requested inventory and cleanup; never create one for isolation alone.
- allowed-tools
- [ "Bash(git *)", "Bash(mkdir *)", "Bash(fix-worktree-submodules *)", "Bash(ls *)", "Bash(cd *)" ]
- user-invocable
- true
03 SKILL.md 正文
Worktrees
When to Use
Worktrees are permitted ONLY when the owner or another agent launched by the owner is concurrently working on the same repository as an agent. Isolation alone, dirty local state, ordinary setup, review, builds, and agent-initiated fan-out never justify a worktree. Explicit owner requests to inventory or remove existing worktrees authorize that cleanup, not new worktrees.
The assigned checkout remains the default workspace. Without owner-authorized concurrent work or an explicit inventory/cleanup request, inspect only that checkout and do not enter other worktrees.
Apply GLOBAL_AGENTS.md's directory-ignore preflight before using temporary
directories or creating a slot. Recheck in a newly created checkout before using
its temporary directories. Account for any owned repair during preflight, not at
cleanup; a saved repair does not authorize discarding it or force-removing a
dirty worktree.
Procedure
- Verify Git topology with
git rev-parse --show-toplevel,git rev-parse --git-common-dir, and, when inventory is authorized,git worktree list --porcelain. GitButler is valid only in an existing managed main worktree; use plain Git in every linked worktree. - Before creation, identify the owner or owner-launched agent working on the same repository concurrently. If none exists, do not create a worktree.
- Use a stable repository-local role slot:
.worktrees/secondary,.worktrees/tertiary, or an explicitly disposable.tmp/worktrees/secondaryor.tmp/worktrees/tertiary. Never use PR-, ticket-, branch-, timestamp-, experiment-, or task-named directories. Verify existing ownership before reusing a slot. - Create only the selected slot from the task's verified base. Do not change
VCS backends, fetch unrelated branches, or initialize unapproved
environments. When the main worktree uses direnv and its repository
environment is already owner-approved, run
direnv allow <worktree-root>in the linked or review checkout before tests or commits. Main-checkout approval does not activate a new checkout. Use the repository's declared complete setup, not partial hook configs or skipped hooks. This grants no new secret, host-configuration or deployment authority. Diagnose activation errors rather than silently working outside the environment. Record artifact provenance for a newly created disposable slot when the harness exposes that tool. - Repair submodules only if concurrent work actually requires them. Use
fix-worktree-submodulesonly when that command exists; otherwise inspect the repository's documented equivalent before acting. - The creating agent owns removal of its worktree registration, directory, and generated outputs immediately after concurrent work succeeds, fails, or is cancelled. A pre-existing owner-managed slot may remain; an agent-created slot may remain only with explicit owner direction.
Temporary artifacts
Resolve the task checkout root from the active worktree, not a coordinating
session's cwd or the common Git directory. Pass this checkout root explicitly to
workflows and set every child's cwd to it. Keep task-local patches, prompts,
reports, payloads, and logs under that checkout root's .tmp/. For a linked
worktree, never write its artifacts into the main checkout's .tmp/. The
artifact directory is not a child working directory. Record provenance where
required and remove these artifacts with the worktree.
Cleanup
Use git worktree remove with each exact verified linked-worktree path.
Preserve uncommitted work unless the owner explicitly authorizes discarding it.
When the owner orders removal regardless of contents, honor that exact
authorization; Git's documented --force option may be needed for dirty
worktrees. Never remove the main checkout or unrelated files. Remove stale
registrations only within the requested repository scope.
If safe cleanup is blocked, record the exact path and reason, keep completion blocked, and make cleanup the first resumed action. Do not leave disk debt for the owner or another agent.
Verification
git worktree list --porcelainshows only the intended registrations.- Every removed exact path is absent, including its generated outputs.
- No worktree was created without verified owner-authorized concurrency.
- Explicit requests for zero linked worktrees leave only the main checkout.
04 同仓库更多 Skills
unslop
Rewrite draft prose before owner-facing replies, docs, issues, PR text, handoffs, or Telegram reports to remove AI tells while preserving facts, links, tone, and authority; auto-trigger on externally visible prose, but never on code, commands, logs, tool output, quoted sources, or user text.
threat-model-first
Use at the START of a change that moves money, changes balances or custody, touches access control or signing, deserializes untrusted input, adds an external or on-chain integration, or wires an LLM tool. Design-time threat modeling that turns abuse cases into the first failing tests; it precedes the post-hoc security-review pass.
test-inspector
Auto-run for new or changed retained behavior, even without test changes, and for test, fixture, snapshot or mock changes; verify real happy-path and error-path coverage, expose false-confidence assertions and over-mocking, but do not perform general production-code correctness review.
strong-typing-inspector
Lightweight review — flags primitives used where a domain type already exists (e.g. String for a USD field when Usd exists) and missed newtype opportunities.
spec-review
Critique existing specifications and design proposals, including whether their approach or addition is justified, and refine them through adversarial Pi review and authorized author revisions. Not for code review, implementation-plan sequencing, creating a design from scratch or minor copy edits.
shape-work
Use when a vague idea, issue, or potentially irreversible or multi-file change needs intent shaping before planning or an ADR; trigger on "shape this idea", "explore the design space", "stress-test this direction", "lock intent", or "interview me" regardless of implementation language, and never use it to plan or write code.