Skip to content

feat(setup-isolated-env): add WorktreeCreate and WorktreeRemove hooks#1

Open
joel611 wants to merge 6 commits into
mainfrom
feat/setup-isolated-env-hooks
Open

feat(setup-isolated-env): add WorktreeCreate and WorktreeRemove hooks#1
joel611 wants to merge 6 commits into
mainfrom
feat/setup-isolated-env-hooks

Conversation

@joel611

@joel611 joel611 commented Mar 5, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds automation hooks and an uninstall skill to the setup-isolated-env plugin.

  • WorktreeCreate/WorktreeRemove hooks — automatically prompt the activate-worktree-env skill when a git worktree is created, and suggest cleanup when one is removed
  • Uninstall skill — fully reverses generate-env-scripts setup: cleans up all active worktrees (dropping databases), removes generated scripts, WORKTREE.md, and the CLAUDE.md isolation section
  • Refactor — replaced CLAUDE_PLUGIN_ROOT with CLAUDE_SKILL_DIR throughout skill scripts for correct path resolution; fixed script calling conventions
  • Version bump — 0.2.x → 0.3.0 for the hooks addition

Changes

File Change
hooks/hooks.json New WorktreeCreate and WorktreeRemove hook definitions
hooks/scripts/worktree-create.sh Hook script that surfaces activate-worktree-env skill
hooks/scripts/worktree-remove.sh Hook script that suggests cleanup on worktree removal
skills/uninstall/SKILL.md New skill reversing full setup flow
skills/activate-worktree-env/SKILL.md Updated path references (CLAUDE_SKILL_DIR)
skills/generate-env-scripts/SKILL.md Updated path references + calling conventions
CLAUDE.md Added uninstall to flow diagram and trigger points
plugin.json Version 0.3.0

Test plan

  • WorktreeCreate hook fires when git worktree add is called and surfaces activate-worktree-env prompt
  • WorktreeRemove hook fires when git worktree remove is called
  • setup-isolated-env:uninstall triggers on "uninstall setup-isolated-env", "remove worktree scripts", "tear down worktree isolation"
  • Uninstall correctly orders teardown: worktrees cleaned up before scripts removed
  • Uninstall fallback manual DB cleanup path works when cleanup-env.sh is unavailable
  • Scripts directory only removed when empty (no side effects on pre-existing scripts/)
  • Skill scripts resolve paths correctly using CLAUDE_SKILL_DIR

@joel611
joel611 force-pushed the feat/setup-isolated-env-hooks branch from fd59e52 to 9db201c Compare March 5, 2026 15:26
joel-hypthon and others added 3 commits March 5, 2026 23:42
…SKILL_DIR

Update script path references to use the new ${CLAUDE_SKILL_DIR} variable
(supported since Claude 2.1.69) which points to the skill's own directory,
replacing the longer ${CLAUDE_PLUGIN_ROOT}/skills/generate-env-scripts/scripts/ pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All three scripts (setup-env.sh, smoke-test.sh, cleanup-env.sh) run from
inside the worktree, not the project root. The .worktrees_scripts/ directory
is tracked in git and present in every worktree checkout, so the correct
path is `.worktrees_scripts/<script>` — not `../../<worktree_scripts>/`.

smoke-test.sh and cleanup-env.sh take no arguments and auto-detect the
environment name from $PWD (basename of the current directory).

- Fix all path references across SKILL.md, README.md, WORKTREE.md template,
  and smoke-test.sh asset error messages
- Update activate-worktree-env: simplify Step 1 to direct path check,
  correct Step 2 to run from inside worktree, fix cleanup instructions
- Update generate-env-scripts: remove ONE-TIME framing from description,
  remove 'When to Use' section from body (moved to description), consolidate
  duplicated Common Mistakes + Troubleshooting sections, fix embedded
  CLAUDE.md template snippet
- Add hook integration note to activate-worktree-env explaining WorktreeCreate
  hook auto-surfaces the skill

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a new skill that tears down everything generate-env-scripts created:
- cleans up all active worktrees and drops their databases
- removes generated scripts (setup-env.sh, cleanup-env.sh, smoke-test.sh)
- removes WORKTREE.md and the CLAUDE.md isolation section

Updates CLAUDE.md flow diagram and trigger points table to document the
new uninstall skill.
@joel611
joel611 force-pushed the feat/setup-isolated-env-hooks branch from 7936895 to 00f8e92 Compare March 11, 2026 15:37
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.

2 participants