agentleFS
gustavo-meilusgustavo-meilus/superpipelines/skills/sk-worktree-safety/SKILL.md

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.

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
  1. Distinctive:

    All changes are added and committed before any worktree is removed, preserving the work-in-progress state.

    line 36
  2. Distinctive:

    NEVER skip the baseline test.

    line 64
  3. Distinctive:

    NEVER use git worktree remove --force without a preceding commit to preserve findings.

    line 65
  4. Very specific:

    ALWAYS verify that .worktrees/ is ignored before creation.

    line 66

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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>

PatternWorktree RequirementRationale
1. SequentialOptionalLinear flow may not require isolation.
2. ParallelMandatoryRequired for fanned-out task isolation.
3. IterativeMandatoryEnables atomic rollback on escalation.
4. GatedConditionalRequired only during the modification phase.
5. Spec-DrivenMandatoryEnforced 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_root tracking.
  • finishing-a-development-branch/SKILL.md — Final merge protocol.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.