Loading...
#!/bin/bash
rm -rf node_modules
npm install#!/bin/bash
set -euo pipefail
if [ ! -d node_modules ]; then
npm ci --silent || { echo "npm ci failed" >&2; exit 1; }
fi
echo "Branch: $(git branch --show-current)"Installing only when needed makes the hook idempotent and fast, and errors are printed instead of hidden.
Installing dependencies, loading environment variables and adding a short project status, such as the branch or open tasks, to the agent's context.
It depends on the tool. Some run it on new, resumed and cleared sessions and pass the reason to the hook.
AGENTS.md is static text. A session start hook runs commands, so it can prepare the environment and add facts that change between sessions.