Skip to content

cursor-team-kit: add worktree + one-shot script cleanup rules - #195

Open
fluiddynamicsLLC wants to merge 2 commits into
cursor:mainfrom
fluiddynamicsLLC:add-worktree-cleanup-rule
Open

cursor-team-kit: add worktree + one-shot script cleanup rules#195
fluiddynamicsLLC wants to merge 2 commits into
cursor:mainfrom
fluiddynamicsLLC:add-worktree-cleanup-rule

Conversation

@fluiddynamicsLLC

@fluiddynamicsLLC fluiddynamicsLLC commented Aug 6, 2026

Copy link
Copy Markdown

What

Adds two closely related "session hygiene" rules to cursor-team-kit/rules/ and lists them in the team-kit README:

  • worktree-cleanup.mdc -- the session that adds a git worktree is responsible for removing it when the branch merges (or the work is abandoned), so sibling <repo>-wt-* directories do not accumulate.
  • one-shot-script-cleanup.mdc -- the session that writes a _tmp-* helper script or temp payload (JSON fed to a single API call, PR-body drafts written only for --body-file, extract/parse one-liners, etc.) is responsible for deleting it when the underlying task ships.

Why

In agent-heavy workflows both classes of artifact pile up fast:

  • Long-running Cursor/ADO/PR loops spin up one worktree per ticket or subagent. If nobody sweeps after merge, the parent directory ends up with dozens of <repo>-wt-* siblings and it becomes hard to tell what work is actually live.
  • The same loops leave behind _tmp-*.ps1, _tmp-<ticket>-wi.json, _tmp-*-pr-body.md, and similar one-shot scaffolding. Every subsequent git status gets buried under untracked scratch.

Both rules pair with (and cross-reference) the existing parallel-agent write-discipline guidance in this ecosystem instead of duplicating it. They only add the "clean up after yourself" half, which was implicit but not written down.

Guardrails

Both rules explicitly refuse to sweep silently:

  • Never touch another running agent's worktree; never delete the main checkout; never delete long-lived branches (main / master / staging / develop).
  • Never auto-delete anything that looks like a secret (.env*, *.key, *.pem, VAPID / JWT / token blobs) -- report to the user instead.
  • Never git clean -fd a shared workspace without explicit approval, and never touch tool-managed dirs (.git/, node_modules/, venv/, .next/).
  • Report any worktree or _tmp-* cruft you leave behind, with a reason, in your final summary.

Notes

  • Rule format matches the existing no-inline-imports.mdc / typescript-exhaustive-switch.mdc (frontmatter with description and alwaysApply: true, prose body).
  • ASCII only.
  • README rows added alongside the existing two rule entries.

No functional / code changes; docs-and-rules only.


Note

Low Risk
Documentation and agent guidance only; no application code, data access, or production behavior changes.

Overview
Adds two always-on agent rules to cursor-team-kit for session hygiene after parallel agent work, plus README table rows for each.

worktree-cleanup makes the session that created a sibling git worktree remove it after merge or abandonment (worktree remove, prune, merged feature branch delete), with guardrails against touching the main checkout, long-lived branches, dirty trees, or another agent’s worktree.

one-shot-script-cleanup requires deleting untracked _tmp-* helpers and single-use payloads when the task ships, with a session-end sweep, explicit exclusions for tracked source and secrets, and a requirement to report any scratch left behind.

Neither rule changes runtime code—only documented agent behavior, aligned with existing rule frontmatter (alwaysApply: true).

Reviewed by Cursor Bugbot for commit 8c96aca. Bugbot is set up for automated code reviews on this repo. Configure here.

fluiddynamicsLLC and others added 2 commits August 6, 2026 17:48
A standing rule that pairs with the existing parallel-agent-write-discipline
guidance: every agent that adds a git worktree is responsible for removing it
when its branch merges (or the work is abandoned), so sibling <repo>-wt-*
directories do not accumulate in agent-heavy workflows.

Co-authored-by: Cursor <cursoragent@cursor.com>
Companion to the worktree-cleanup rule in the same PR: agent sessions
routinely produce single-use helper scripts and temp payload files
(_tmp-*.ps1, _tmp-<ticket>-wi.json, PR-body drafts written only for a
CLI --body-file, etc.). Left behind they bury every future git status.
This rule makes the session that creates them responsible for deleting
them once the task ships, with explicit carve-outs for secrets and
tracked scripts.

Co-authored-by: Cursor <cursoragent@cursor.com>
@fluiddynamicsLLC fluiddynamicsLLC changed the title cursor-team-kit: add worktree-cleanup rule cursor-team-kit: add worktree + one-shot script cleanup rules Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant