worktree-destruction-safety

worktree-destruction-safety is a cursor rule for Cursor from fmflurry/settings-opencode. It costs 1,975 tokens per session, scanned C, original, MIT.

A safety rule for removing Git worktrees, which are separate working directories linked to one repository. It treats deletion as potentially permanent data loss when the directory contains uncommitted files.

In plain words
What is it for?
Use it when creating safeguards around `git worktree remove`, `git worktree prune`, moving worktrees, or deleting their directories.
Why use it?
It helps prevent accidental deletion of work that has not been committed or backed up. It also distinguishes deleting a worktree from merely deleting a branch.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when creating safeguards around git worktree remove, git worktree prune, moving worktrees, or deleting their directories.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/fmflurry/settings-opencode/worktree-destruction-safety
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.

Clone the repo
git clone --depth 1 https://github.com/fmflurry/settings-opencode

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for worktree-destruction-safety

README.md
[![agentmods](https://agentmods.dev/badge/rules/fmflurry/settings-opencode/worktree-destruction-safety/github.svg)](https://agentmods.dev/rules/fmflurry/settings-opencode/worktree-destruction-safety)
Your own site
<a href="https://agentmods.dev/rules/fmflurry/settings-opencode/worktree-destruction-safety"><img src="https://agentmods.dev/badge/rules/fmflurry/settings-opencode/worktree-destruction-safety/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for worktree-destruction-safety

Your own site · 80×15
<a href="https://agentmods.dev/rules/fmflurry/settings-opencode/worktree-destruction-safety"><img src="https://agentmods.dev/badge/rules/fmflurry/settings-opencode/worktree-destruction-safety.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,975 This file is loaded in full into every session.
When invoked 1,975 The same file — it is already loaded in full.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.01975 $0.01975
Opus 5.5 $0.00790 $0.00790
Sonnet 5.5 $0.00395 $0.00395
Haiku 4.5 $0.00198 $0.00198

Measured yesterday against content hash f7436e088f77, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

worktree-destruction-safety scanned grade C with 1 finding 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 yesterday.

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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

A worktree directory is the **only copy** of any uncommitted work inside it. Removing one is a destructive data operation, not bookkeeping — treat it with the same caution as `rm -rf`, never like `git branch -d`.
plugins/fmflurry-harness/rules/worktree-destruction-safety.mdc · 113 lines

How it starts

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

Worktree Destruction Safety (mandatory)

A worktree directory is the only copy of any uncommitted work inside it. Removing one is a destructive data operation, not bookkeeping — treat it with the same caution as rm -rf, never like git branch -d.

Boundary with worktree-switching: that rule (where configured) governs entering, creating, and switching between worktrees. This rule governs their destruction — git worktree remove, git worktree prune, git worktree move, orca worktree rm, or any raw filesystem delete of a worktree directory. Read both; they do not overlap.

Why this exists

Two incidents shaped this rule. A raw git worktree remove --force + git worktree prune run outside Orca's pipeline destroyed a worktree with no trash step, so the content was not recoverable. Later, orca worktree rm returned before the removal finished ("removing": true). Orca always runs git worktree remove --force internally, whatever CLI flags are passed. During that background removal, the repo's main checkout received reset --hard and pull, which destroyed an uncommitted tracked edit and an untracked file. The actor is unknown. The old checks inspected only the worktree being removed, not the other checkouts of the repo.

Orca-managed detection (read-only, portable)

A repo is Orca-managed when either is true:

  • it appears in orca repo list
  • the target path is enumerated by orca worktree list --json

If the orca CLI is not installed or not on PATH, the Orca routing below does not apply — say so explicitly. The mandatory pre-removal checks further down apply regardless of Orca's presence; they are plain git and are always in scope.

Mandatory: route worktree lifecycle through Orca when Orca-managed

Inside an Orca-managed repo, creation goes through orca worktree create .... Removal goes through agent-harness worktree-rm (below), which routes to Orca itself.

Forbidden by default in an Orca-managed repo: raw git worktree remove, git worktree prune, git worktree move, a direct orca worktree rm call, and rm -rf <worktree-dir>. These bypass the checks and the trash step (~/orca/workspaces/<repo>/.orca-worktree-trash/).

Read the full file on GitHub · 113 lines

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. yesterday Changed · +55 lines · +923 tokens per session f7436e088f77
  2. 8d ago First seen · 58 lines · 1,052 tokens per session scan C bb582dc9a919

Subscribe to this mod's changes

worktree-destruction-safety is a cursor rule published in the GitHub repository fmflurry/settings-opencode (171 stars, last pushed yesterday), licensed MIT. It adds 1,975 tokens to every session, about $0.0079 per session on Opus 5.5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-08.