hooks-session-start-hook

v2026.09.24

Create a SessionStart hook for Claude Code on the web. Use when setting up a repo so dependencies install and tests/linters run automatically on remote session start.

GitHub
Install command
npx skhub add laurigates/hooks-session-start-hook
Markdown
SKILL.md

/hooks:session-start-hook

Generate a SessionStart hook that prepares your repository for Claude Code on the web — installing dependencies, configuring environment variables, and verifying that tests and linters work.

When to Use This Skill

Use this skill when...Use /hooks:hooks-configuration instead when...
Setting up a repo for Claude Code on the webConfiguring other hook types (PreToolUse, Stop, etc.)
Need automatic dependency install in web sessionsNeed general hooks knowledge or debugging
Want tests/linters verified on session startWriting custom hook logic from scratch
Onboarding a project to remote Claude CodeUnderstanding hook lifecycle events

Context

Detect project stack:

  • Lockfiles: !find . -maxdepth 1 \( -name 'package-lock.json' -o -name 'yarn.lock' -o -name 'pnpm-lock.yaml' -o -name 'bun.lockb' -o -name 'poetry.lock' -o -name 'uv.lock' -o -name 'Cargo.lock' -o -name 'go.sum' -o -name 'Gemfile.lock' \)
  • Project files: !find . -maxdepth 1 \( -name 'package.json' -o -name 'pyproject.toml' -o -name 'requirements.txt' -o -name 'Cargo.toml' -o -name 'go.mod' -o -name 'Gemfile' -o -name 'pom.xml' \) -o -maxdepth 1 -name 'build.gradle*'
  • Linter configs: !find . -maxdepth 1 \( -name 'biome.json' -o -name 'biome.jsonc' -o -name '.eslintrc*' -o -name 'eslint.config.*' \)
  • Existing settings: !find . -path '*/.claude/settings.json' -maxdepth 3 -type f
  • Existing hooks dir: !find . -maxdepth 2 -type d -name 'scripts'

Parameters

FlagDefaultDescription
--remote-onlyoffWrap script in CLAUDE_CODE_REMOTE guard — hook exits immediately in local sessions
--no-verifyoffSkip test/linter verification step in the generated script

Execution

Step 1: Detect project stack

Identify all languages and tooling from the context above.

Language detection:

File PresentLanguagePackage Manager (from lockfile)
package.jsonNode.jsnpm (package-lock.json), yarn (yarn.lock), pnpm (pnpm-lock.yaml), bun (bun.lockb)
pyproject.tomlPythonpoetry (poetry.lock), uv (uv.lock), pip (fallback)
requirements.txtPythonpip
Cargo.tomlRustcargo
go.modGogo modules
GemfileRubybundler
pom.xmlJavamaven
build.gradle*Java/Kotlingradle

Test runner detection:

LanguageHow to DetectTest Command
Node.jsscripts.test in package.jsonnpm test / bun test / etc.
Python[tool.pytest] in pyproject.toml, or pytest in depspytest
Rustalways availablecargo test
Goalways availablego test ./...
RubyGemfile contains rspec or minitestbundle exec rspec / bundle exec rake test
Javapom.xml / build.gradlemvn test / gradle test

Linter detection:

Config FileLinterCommand
biome.json / biome.jsoncBiomenpx biome check .
.eslintrc* / eslint.config.*ESLintnpx eslint .
[tool.ruff] in pyproject.tomlRuffruff check .
Cargo.tomlClippycargo clippy

Report detected stack to user before generating.

Step 2: Generate hook script

Create the script at scripts/claude-session-start.sh (or .claude/hooks/session-start.sh if no scripts/ directory exists).

Use the Script Template from REFERENCE.md. Adapt it by:

  1. Including only sections for detected languages
  2. Using the correct package manager commands with frozen lockfile flags
  3. Using the correct test runner and linter commands
  4. Setting appropriate environment variables per language

Step 3: Configure .claude/settings.json

Read existing .claude/settings.json if it exists. Merge the SessionStart hook — preserve all existing configuration.

If a SessionStart hook already exists, ask the user whether to:

  • Replace the existing SessionStart hook
  • Add alongside the existing hook (both will run)
  • Abort and keep existing configuration

Configuration to merge:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "startup",
        "hooks": [
          {
            "type": "command",
            "command": "bash \"$CLAUDE_PROJECT_DIR/scripts/claude-session-start.sh\"",
            "timeout": 120
          }
        ]
      }
    ]
  }
}

Use timeout: 120 (2 minutes) for dependency installation. Adjust path if script is in .claude/hooks/ instead of scripts/.

Step 4: Finalize

  1. Make the script executable: chmod +x <script-path>
  2. Create .claude/ directory if needed for settings.json
  3. Report summary of what was created

Step 5: Verify (unless --no-verify)

Run the generated script locally to confirm it executes without errors. Report results.

Post-Actions

After generating the hook:

  1. Suggest committing the new files:
    scripts/claude-session-start.sh
    .claude/settings.json
    
  2. If --remote-only was NOT used, mention the flag for web-only behavior
  3. If the project needs network access beyond defaults, remind about Claude Code web network settings
  4. Mention matcher options: "startup" (new sessions), "resume" (resumed), "" (all events)

SessionStart Matcher Reference

MatcherFires When
"startup"New session starts
"resume"Session is resumed
"clear"After /clear command
"compact"After context compaction
"" (empty)All SessionStart events

Agentic Optimizations

ContextApproach
Quick setup, skip verification/hooks:session-start-hook --remote-only --no-verify
Full setup with verification/hooks:session-start-hook
Web-only with tests/hooks:session-start-hook --remote-only
Dependency install commandsUse --frozen-lockfile / ci variants for reproducibility
Test verificationUse --bail=1 / -x for fast failure
Linter verificationUse --max-diagnostics=0 / --quiet for pass/fail only

Quick Reference

ItemValue
Script locationscripts/claude-session-start.sh or .claude/hooks/session-start.sh
Settings location.claude/settings.json
Timeout120 seconds (adjustable)
Output formatJSON with hookSpecificOutput.additionalContext
Environment persistenceVia CLAUDE_ENV_FILE
Remote detectionCLAUDE_CODE_REMOTE=true
Discovery
Tags

No tags published for this skill.

Version
Latest version metadata

Version

v2026.09.24

Published

Sep 24, 2026

Category

Uncategorized

License

MIT

Source path

hooks-plugin/skills/hooks-session-start-hook

Default branch

main

Latest commit

1668324

Tree SHA

b2d4cc3