Configure SessionStart hooks for Claude Code on the web. Use when setting up a repository to run on cloud infrastructure, installing dependencies, or initializing environments for remote Claude Code sessions.
Automates repository setup for cloud Claude Code sessions by creating SessionStart hooks that install dependencies and configure environments. Use when preparing repositories for web-based Claude Code to run initialization scripts automatically on session start.
/plugin marketplace add cameronsjo/claude-marketplace/plugin install cc-web@cameronsjoThis skill inherits all available tools. When active, it can use any tool Claude has access to.
scripts/generate-hook.shtemplates/fullstack-setup.shtemplates/nodejs-setup.shtemplates/python-setup.shConfigure your repository for Claude Code on the web using SessionStart hooks. This skill helps you create hooks that automatically run when Claude Code starts a session in the cloud environment.
SessionStart hooks execute when Claude Code begins a session, allowing you to:
Create .claude/settings.json in your repository root:
{
"hooks": {
"SessionStart": [
{
"matcher": "startup",
"hooks": [
{
"type": "command",
"command": "./scripts/claude-setup.sh",
"timeout": 120
}
]
}
]
}
}
Create scripts/claude-setup.sh:
#!/bin/bash
set -e
# Detect package manager and install dependencies
if [ -f "package.json" ]; then
if [ -f "pnpm-lock.yaml" ]; then
pnpm install
elif [ -f "yarn.lock" ]; then
yarn install
elif [ -f "bun.lockb" ]; then
bun install
else
npm install
fi
fi
if [ -f "requirements.txt" ]; then
pip install -r requirements.txt
fi
if [ -f "pyproject.toml" ]; then
if command -v uv &> /dev/null; then
uv sync
elif command -v poetry &> /dev/null; then
poetry install
else
pip install -e .
fi
fi
exit 0
chmod +x scripts/claude-setup.sh
{
"hooks": {
"SessionStart": [
{
"matcher": "<pattern>",
"hooks": [
{
"type": "command",
"command": "<script-or-command>",
"timeout": <seconds>,
"statusMessage": "<optional-message>"
}
]
}
]
}
}
| Field | Required | Description |
|---|---|---|
matcher | Optional | Pattern to match (use "startup" for all sessions) |
type | Yes | Must be "command" |
command | Yes | Shell command or script path |
timeout | Optional | Max execution time in seconds (default: 60) |
statusMessage | Optional | Message shown during execution |
The CLAUDE_CODE_REMOTE environment variable indicates cloud execution:
#!/bin/bash
# Run only in web/cloud environment
if [ "$CLAUDE_CODE_REMOTE" != "true" ]; then
echo "Skipping - not running in cloud environment"
exit 0
fi
# Cloud-specific setup here
npm install
#!/bin/bash
# Skip in cloud environment
if [ "$CLAUDE_CODE_REMOTE" = "true" ]; then
exit 0
fi
# Local-only setup here
Write to $CLAUDE_ENV_FILE to set environment variables for the session:
#!/bin/bash
# Set environment variables for Claude Code
echo "DATABASE_URL=postgresql://localhost:5432/mydb" >> "$CLAUDE_ENV_FILE"
echo "NODE_ENV=development" >> "$CLAUDE_ENV_FILE"
echo "API_KEY=test-key" >> "$CLAUDE_ENV_FILE"
#!/bin/bash
set -e
# Install dependencies
npm install
# Build if needed
if [ -f "tsconfig.json" ]; then
npm run build 2>/dev/null || true
fi
# Set up environment
if [ ! -f ".env" ] && [ -f ".env.example" ]; then
cp .env.example .env
fi
exit 0
#!/bin/bash
set -e
# Create virtual environment if needed
if [ ! -d ".venv" ]; then
python -m venv .venv
fi
# Activate and install
source .venv/bin/activate
pip install -r requirements.txt
# Set environment variables
echo "PYTHONPATH=$(pwd)" >> "$CLAUDE_ENV_FILE"
exit 0
#!/bin/bash
set -e
# Backend setup
cd backend
pip install -r requirements.txt
# Frontend setup
cd ../frontend
npm install
# Database
cd ..
if command -v docker &> /dev/null; then
docker-compose up -d db redis 2>/dev/null || true
fi
exit 0
#!/bin/bash
set -e
# Set Ruby version if .ruby-version exists
if [ -f ".ruby-version" ]; then
rbenv local $(cat .ruby-version) 2>/dev/null || true
fi
# Install gems
bundle install
exit 0
#!/bin/bash
set -e
# Download dependencies
go mod download
# Build to verify
go build ./... 2>/dev/null || true
exit 0
The Claude Code web environment includes:
Check available tools with: check-tools
Limited network access by default. Allowed domains include:
chmod +x scripts/claude-setup.sh#!/bin/bashset -e to fail fast on errors$CLAUDE_ENV_FILE, not export>>) not overwrite (>)echo "VAR=value" >> "$CLAUDE_ENV_FILE"See templates/ directory for ready-to-use setup scripts:
templates/nodejs-setup.sh - Node.js/TypeScript projectstemplates/python-setup.sh - Python projectstemplates/fullstack-setup.sh - Full-stack applications