Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugins/compound-engineering/skills/git-worktree/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh creat
2. Updates the base branch from remote
3. Creates new worktree and branch
4. **Copies all .env files from main repo** (.env, .env.local, .env.test, etc.)
5. Shows path for cd-ing to the worktree
5. **Trusts dev tool configs** (mise, direnv) so hooks and scripts work immediately
6. Shows path for cd-ing to the worktree

### `list` or `ls`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,33 @@ copy_env_files() {
echo -e " ${GREEN}✓ Copied $copied environment file(s)${NC}"
}

# Trust development tool configs in a new worktree.
# Worktrees get a new filesystem path that tools like mise and direnv
# have never seen. Without trusting, these tools block with interactive
# prompts (or silently fail) when invoked from hooks or scripts.
trust_dev_tools() {
local worktree_path="$1"
local trusted=0

# mise: trust .mise.toml / mise.toml / .tool-versions
if command -v mise &>/dev/null; then
if [[ -f "$worktree_path/.mise.toml" ]] || [[ -f "$worktree_path/mise.toml" ]] || [[ -f "$worktree_path/.tool-versions" ]]; then
(cd "$worktree_path" && mise trust --quiet 2>/dev/null) && trusted=$((trusted + 1))
Comment thread
NimbleEngineer21 marked this conversation as resolved.
Outdated
fi
fi

# direnv: allow .envrc
if command -v direnv &>/dev/null; then
if [[ -f "$worktree_path/.envrc" ]]; then
(cd "$worktree_path" && direnv allow 2>/dev/null) && trusted=$((trusted + 1))
Comment thread
NimbleEngineer21 marked this conversation as resolved.
Outdated
fi
fi

if [[ $trusted -gt 0 ]]; then
echo -e " ${GREEN}✓ Trusted $trusted dev tool config(s)${NC}"
fi
}

# Create a new worktree
create_worktree() {
local branch_name="$1"
Expand Down Expand Up @@ -107,6 +134,9 @@ create_worktree() {
# Copy environment files
copy_env_files "$worktree_path"

# Trust dev tool configs (mise, direnv) so hooks and scripts work immediately
trust_dev_tools "$worktree_path"

echo -e "${GREEN}✓ Worktree created successfully!${NC}"
echo ""
echo "To switch to this worktree:"
Expand Down Expand Up @@ -321,6 +351,12 @@ Environment Files:
- Creates .backup files if destination already exists
- Use 'copy-env' to refresh env files after main repo changes

Dev Tool Trust:
- Automatically trusts mise config (.mise.toml, mise.toml, .tool-versions)
- Automatically allows direnv config (.envrc)
- Only runs if the tool is installed and config exists
- Prevents hooks/scripts from hanging on interactive trust prompts

Examples:
worktree-manager.sh create feature-login
worktree-manager.sh create feature-auth develop
Expand Down