Files
5chan/.claude/hooks/session-start.sh
T
Tommaso Casaburi d07f5b3962 chore(worktree): auto-run yarn install on new worktrees
Add a Claude Code SessionStart hook (matcher: startup) that runs
`corepack yarn install` when node_modules is missing, so worktrees Claude
creates internally are immediately usable. Also extend create-task-worktree.sh
to install deps after the worktree is created, covering Codex/Cursor/manual
flows that share that script.
2026-04-17 14:30:41 +07:00

23 lines
763 B
Bash
Executable File

#!/bin/bash
# SessionStart hook: ensure dependencies are installed for the current worktree.
# Runs `corepack yarn install` when node_modules is missing, so new Claude-created
# worktrees are usable immediately without a manual install step.
set -u
repo_root="${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
cd "$repo_root" 2>/dev/null || exit 0
# No yarn.lock → not a yarn project or fresh clone; nothing to do.
[ -f "yarn.lock" ] || exit 0
# node_modules already populated → nothing to do (fast path).
if [ -d "node_modules" ] && [ -n "$(ls -A node_modules 2>/dev/null | head -1)" ]; then
exit 0
fi
echo "[claude hook] node_modules missing in $repo_root — running corepack yarn install..."
corepack yarn install
exit 0