sk-worktree-safety
Skill4 starsChanged 6 months agoMITView on GitHub
Enforces a mandatory 4-step safety protocol (Ignore, Setup, Baseline, Commit) for creating, managing, and destroying git worktrees in pipeline isolation contexts. Use when a pipeline step declares `isolation: worktree`, when parallel pattern tasks require branch isolation, or when the iterative or spec-driven patterns require atomic rollback capability.
In this repository43 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms-full.txtllms.txt
- llms.txtllms.txt
- cutting-a-releaseSkill
- cutting-a-releaseSkill
- adding-a-pipeline-stepSkill
- brainstormingSkill
- change-modelsSkill
- creating-a-pipelineSkill
- deleting-a-pipeline-stepSkill
- finishing-a-development-branchSkill
- migrating-a-pipelineSkill
- optimizing-a-pipelineSkill
- pipeline-architect-protocolSkill
- pipeline-auditor-protocolSkill
- pipeline-failure-analyzer-protocolSkill
- pipeline-optimizer-protocolSkill
- pipeline-quality-reviewer-protocolSkill
- pipeline-spec-reviewer-protocolSkill
- pipeline-task-executor-protocolSkill
- running-a-pipelineSkill
- sk-4d-methodSkill
- sk-claude-code-conventionsSkill
- sk-dynamic-routingSkill
- sk-hashline-protocolSkill
- sk-hierarchical-contextSkill
- skill-architect-protocolSkill
- sk-model-migrationSkill
- sk-model-resolverSkill
- sk-pipeline-grillingSkill
- sk-pipeline-pathsSkill
- sk-pipeline-patternsSkill
- sk-pipeline-stateSkill
- sk-platform-dispatchSkill
- sk-rationalization-resistanceSkill
- sk-spec-driven-developmentSkill
- sk-write-review-isolationSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- updating-a-pipeline-stepSkill
- using-superpipelinesSkill
- verification-before-completionSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 36
All changes are added and committed before any worktree is removed, preserving the work-in-progress state.
- Distinctive: line 64
NEVER skip the baseline test.
- Distinctive: line 65
NEVER use git worktree remove --force without a preceding commit to preserve findings.
- Very specific: line 66
ALWAYS verify that .worktrees/ is ignored before creation.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Worktree Safety Protocol — Isolated Execution
Defines the mandatory 4-step protocol (Ignore, Setup, Baseline, Commit) for creating, managing, and destroying git worktrees.
<glossary>
<term name="Worktree">An isolated git workspace sharing the same repository object but operating on a different branch and path.</term>
<term name="Baseline Verification">Running the project's test suite before modification to identify pre-existing failures.</term>
<term name="Atomic Teardown">Committing all uncommitted work before removing the worktree directory.</term>
</glossary>The 4-Step Safety Protocol
<protocol>
### 1. VERIFY_IGNORED
The `.worktrees/` directory must be git-ignored before any worktree is created, to prevent accidental commits or workspace pollution.
```bash
git check-ignore -q .worktrees || { echo ".worktrees/" >> .gitignore && git add .gitignore && git commit -m "chore: ignore worktrees"; }
```2. SETUP_AFTER_CREATE
Manifests are auto-detected (package.json, Cargo.toml, etc.) and the corresponding installation commands (npm install, cargo build) are run to prepare the isolated environment.
3. VERIFY_BASELINE
The project's full test suite is run before any modifications.
- Failures Found: Results are reported to the user. DO NOT PROCEED with implementation without explicit human authorization.
- Goal: Distinguishes between pre-existing issues and pipeline-introduced regressions.
4. COMMIT_BEFORE_DESTROY
All changes are added and committed before any worktree is removed, preserving the work-in-progress state.
cd "$WORKTREE_PATH" && git add -A && git commit -m "wip: pipeline checkpoint"
git worktree remove "$WORKTREE_PATH"</protocol>Pattern Integration
<integration_table>
| Pattern | Worktree Requirement | Rationale |
| 1. Sequential | Optional | Linear flow may not require isolation. |
| 2. Parallel | Mandatory | Required for fanned-out task isolation. |
| 3. Iterative | Mandatory | Enables atomic rollback on escalation. |
| 4. Gated | Conditional | Required only during the modification phase. |
| 5. Spec-Driven | Mandatory | Enforced per-task during Phase 5 (Implement). |
| </integration_table> |
Detection Signals
<signals>
Environment state is verified before execution:
- **`GIT_DIR != GIT_COMMON`**: Already in a linked worktree; Step 1 is skipped.
- **Branch empty**: Detached HEAD detected; branching/pushing is not possible. Escalate to user.
</signals><invariants>
- NEVER skip the baseline test; it is the leading cause of false escalations in iterative loops.
- NEVER use `git worktree remove --force` without a preceding commit to preserve findings.
- ALWAYS verify that `.worktrees/` is ignored before creation.
</invariants>Red Flags — STOP
- "I'll skip the baseline test, it'll be fine." → STOP. Pre-existing failures will corrupt the pipeline metrics.
- "Just force-remove the worktree, the pipeline failed." → STOP. Commit partial findings first to aid debugging.
Reference Files
sk-pipeline-patterns/SKILL.md— Topology selection.sk-pipeline-state/SKILL.md—metadata.worktree_roottracking.finishing-a-development-branch/SKILL.md— Final merge protocol.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

