
session-start-hook
Creating and developing startup hooks for Claude Code. Use when the user wants to set up a repository for Claude Code, create a SessionStart hook to ensure their project can run tests and linters during sessions (CLI, web, or API).
- Installs
- 569
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/camacho/ai-skills --skill session-start-hook- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads session-start-hook automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Startup Hook Skill for Claude Code
Create SessionStart hooks that install dependencies so tests and linters work in Claude Code sessions (CLI, web, or API).
Hook Basics
Input (via stdin)
{
"session_id": "abc123",
"source": "startup|resume|clear|compact",
"transcript_path": "/path/to/transcript.jsonl",
"permission_mode": "default",
"hook_event_name": "SessionStart",
"cwd": "/workspace/repo"
}
Async Mode
#!/bin/bash
set -euo pipefail
echo '{"async": true, "asyncTimeout": 300000}'
npm install
The hook runs in background while the session starts. Using async mode reduces latency, but introduces a race condition where the agent loop might depend on something that is being done in the startup hook before it completed.
Environment Variables
Available environment variables:
$CLAUDE_PROJECT_DIR- Repository root path$CLAUDE_ENV_FILE- Path to write environment variables$CLAUDE_CODE_REMOTE- If running in a remote environment (i.e. Claude code on the web)
Use $CLAUDE_ENV_FILE to persist variables for the session:
echo 'export PYTHONPATH="."' >> "$CLAUDE_ENV_FILE"
Use $CLAUDE_CODE_REMOTE to only run a script in a remote env:
if [ "${CLAUDE_CODE_REMOTE:-}" != "true" ]; then
exit 0
fi
Workflow
Make a todo list for all the tasks in this workflow and work on them one after another
1. Analyze Dependencies
Find dependency manifests and analyze them. Examples:
package.json/package-lock.json→ npmpyproject.toml/requirements.txt→ pip/PoetryCargo.toml→ cargogo.mod→ goGemfile→ bundler
Additionally, read though any documentation (i.e. README.md or similar) to see if you can get additional context on how the environment setup works
2. Design Hook
Create a script that installs dependencies.
Key principles:
- Don't use async mode in the first iteration. Only switch to it if the user asks for it
- Write the hook only for the web unless user asks otherwise (see $CLAUDE_CODE_REMOTE)
- The container state gets cached after the hook completes, prefer dependency install methods that take advantage of that (i.e. prefer npm install over npm ci)
- Be idempotent (safe to run multiple times)
- Non-interactive (no user input)
What NOT to put in a SessionStart hook:
- Do NOT copy skills between user scope (
~/.claude/skills/) and project scope (.claude/skills/) — that's what./dotfiles/sync.shis for.
Skills freshness check (install if missing or outdated):
SKILLS_DIR="$HOME/.claude/skills"
REPO_SKILLS_DIR="${CLAUDE_PROJECT_DIR}/dotfiles/claude/skills"
SKILLS_REPO="${AI_SKILLS_REPO:-camacho/ai-skills}"
skills_stale() {
[[ ! -d "$SKILLS_DIR" ]] && return 0 # missing → stale
if [[ -d "$REPO_SKILLS_DIR" ]]; then
# Compare repo snapshot to installed — if different, stale
! diff -rq "$REPO_SKILLS_DIR" "$SKILLS_DIR" >/dev/null 2>&1 && return 0
fi
return 1 # up to date
}
if skills_stale; then
echo "Skills missing or outdated — installing from $SKILLS_REPO..."
if command -v npx &>/dev/null; then
npx skills install "$SKILLS_REPO" --scope personal \
|| echo "Warning: skills install failed — project-scope skills still available" >&2
else
echo '{"message": "Skills are outdated but npx not found.\n\nRun: ./dotfiles/sync.sh push", "continue": true}'
fi
fi
The check is local (fast diff) — network only when stale. The default repo (camacho/ai-skills) can be overridden with AI_SKILLS_REPO.
Dotfiles-missing check (surface as a session prompt, not a stderr warning):
# Surface a visible prompt if user dotfiles are missing — informational only
if [[ ! -d "$HOME/.claude/skills" ]]; then
echo '{"message": "~/.claude/skills not found.\n\nRun: ./dotfiles/sync.sh push\n\nThis sets up user-level skills and configs from the dotfiles repo.", "continue": true}'
exit 0
fi
Using the hook's JSON message field (instead of stderr) surfaces this inside Claude's session context where the user will see and act on it. "continue": true keeps the session running — this is informational, not a blocker.
3. Create Hook File
mkdir -p .claude/hooks
cat > .claude/hooks/session-start.sh << 'EOF'
#!/bin/bash
set -euo pipefail
echo '{"async": true, "asyncTimeout": 300000}'
# Install dependencies here
EOF
chmod +x .claude/hooks/session-start.sh
4. Register in Settings
Add to .claude/settings.json (create if doesn't exist):
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/session-start.sh"
}
]
}
]
}
}
If .claude/settings.json exists, merge the hooks configuration.
5. Validate Hook
Run the hook script directly:
CLAUDE_CODE_REMOTE=true ./.claude/hooks/session-start.sh
IMPORTANT: Verify dependencies are installed and script completes successfully.
6. Validate Linter
IMPORTANT: Figure out what the right command is to run the linters and run it for an example file. No need to lint the whole project. If there are any issues, update the startup script accordingly and re-test.
7. Validate Test
IMPORTANT: Figure out what the right command is to run the tests and run it for one test. No need to run the whole test suite. If there are any issues, update the startup script accordingly and re-test.
8. Commit and push
Make a commit and push it to the remote branch
Wrap up
We're all done. In your last message to the user, Provide a detailed summary to the user with the format below:
- Summary of the changes made
- Validation results
- Session hook execution (include details if it failed)
- linter execution (include details if it failed)
- test execution (include details if it failed)
- Hook execution mode: Syncronous
- inform user that hook is running syncronous and the below trade-offs. Let them know that we can change it to async if they prefer faster session startup.
- Pros: Guarantees dependencies are installed before your session starts, preventing race conditions where Claude might try to run tests or linters before they're ready
- Cons: Your remote session will only start once the session start hook is completed
- inform user that hook is running syncronous and the below trade-offs. Let them know that we can change it to async if they prefer faster session startup.
- inform user that once they merge the session start hook into their repo's default branch, all future sessions will use it.
FAQ
What does the session-start-hook skill do?
Creating and developing startup hooks for Claude Code. Use when the user wants to set up a repository for Claude Code, create a SessionStart hook to ensure their project can run tests and linters during sessions (CLI, web, or API).
How do I install session-start-hook?
Run npx skills add https://github.com/camacho/ai-skills --skill session-start-hook in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/session-start-hook/ (personal) or .claude/skills/session-start-hook/ (project).
Which AI agents can use session-start-hook?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is session-start-hook safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains session-start-hook?
It is published by camacho in camacho/ai-skills. It has 569 recorded installs.
More from camacho/ai-skills
archive
camacho/ai-skills
Fills Outcomes & Learnings in a plan file and renames it to .done.md.
bail
camacho/ai-skills
Reflects, updates GitHub Issue, closes PR if open, cleans up worktree/branch.
capture
camacho/ai-skills
Creates a draft GitHub Issue with triage label from natural language description.
plan-review
camacho/ai-skills
Auto-assembles review panel using deterministic rules, dispatches agents against plan file, collects verdicts.
orient
camacho/ai-skills
Fetches issue context, auto-detects task type, maps to branch prefix, presents brief.
reflect
camacho/ai-skills
Use after merging a branch or completing a task to consolidate learnings into memory layers, close out issues, and verify the phase gate.
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.