Back to Skills

session-start-hook

verified

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.

View on GitHub

Marketplace

cameronsjo

cameronsjo/claude-marketplace

Plugin

cc-web

Repository

cameronsjo/claude-marketplace
3stars

plugins/cc-web/skills/session-start-hook/SKILL.md

Last Verified

January 21, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/cameronsjo/claude-marketplace/blob/main/plugins/cc-web/skills/session-start-hook/SKILL.md -a claude-code --skill session-start-hook

Installation paths:

Claude
.claude/skills/session-start-hook/
Powered by add-skill CLI

Instructions

# SessionStart Hook Configuration

Configure 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.

## Overview

**SessionStart hooks** execute when Claude Code begins a session, allowing you to:
- Install project dependencies (npm, pip, etc.)
- Set up environment variables
- Configure databases or services
- Run initialization scripts
- Validate the environment

## Quick Setup

### 1. Create the settings file

Create `.claude/settings.json` in your repository root:

```json
{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "startup",
        "hooks": [
          {
            "type": "command",
            "command": "./scripts/claude-setup.sh",
            "timeout": 120
          }
        ]
      }
    ]
  }
}
```

### 2. Create the setup script

Create `scripts/claude-setup.sh`:

```bash
#!/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
```

### 3. Make the script executable

```bash
chmod +x scripts/claude-setup.sh
```

## Hook Configuration Reference

### Basic Structure

```json
{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "<pattern>",
        "hooks": [
          {
            "type": "command",
            "command": "<script-or-command>",
            "timeout": <seconds>,
            "statusMessage": "<optional-message>"
          }
        ]
      }
    ]
  }

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
5804 chars