本文へ移動
cccskills
無料GitHub で公開

session-start-hook

Creating and developing startup hooks for Claude Code on the web. Use when the user wants to set up a repository for Claude Code on the web, create a SessionStart hook to ensure their project can run tests and linters during web sessions.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md4.8 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Startup Hook Skill for Claude Code on the web

Create SessionStart hooks that install dependencies so tests and linters work in Claude Code on the web sessions.

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 → npm
  • pyproject.toml / requirements.txt → pip/Poetry
  • Cargo.toml → cargo
  • go.mod → go
  • Gemfile → 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)

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
    1. ✅/‼️ Session hook execution (include details if it failed)
    2. ✅/‼️ linter execution (include details if it failed)
    3. ✅/‼️ 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 once they merge the session start hook into their repo's default branch, all future sessions will use it.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

3d-object

無料

three.js model, downloadable as OBJ or GLB

日本語の概要は準備中です。原文の説明を表示しています。

asgeirtj/system_prompts_leaks7万2026年10月12日 更新

Manage your private to-do list for the user. Use to add or update tasks, record what they are waiting on, track blockers, mark tasks complete or canceled, and clean up the list. Not for Dreamers or external task trackers.

日本語の概要は準備中です。原文の説明を表示しています。

asgeirtj/system_prompts_leaks7万2026年10月12日 更新

agents

無料

Run a goal as a project: you coordinate. Use for "agents <task>", "take this to done", "work on this in parallel", "what are my threads doing", "pick up <slug>", "resume <slug>", "keep going until it is merged". Under `/agents` you do the work yourself unless it needs several lanes or a long wait — you judge; the plan line says why. No target you could verify (a file, API, number or measure) → the grill interview first, not threads. Read this skill before proposing anything for `/agents`: without it a proposal is in-session subagents.

日本語の概要は準備中です。原文の説明を表示しています。

asgeirtj/system_prompts_leaks7万2026年10月12日 更新

Timeline-based motion design

日本語の概要は準備中です。原文の説明を表示しています。

asgeirtj/system_prompts_leaks7万2026年10月12日 更新

The user's synced Apple Health (HealthKit) data: daily metrics (steps, distance, calories, heart rate, HRV, VO2max), sleep sessions (stages, quality, efficiency), and workouts.

日本語の概要は準備中です。原文の説明を表示しています。

asgeirtj/system_prompts_leaks7万2026年10月12日 更新

Create, read, edit, or manipulate Word documents (.docx) and Word templates (.dotx). Use whenever a build task's artifact kind is document with the default docx output, or the task mentions a Word doc, .docx, or .dotx, extracts or reorganizes content from one, inserts or replaces images, does find-and-replace in one, or works with tracked changes (redlines) or comments. Covers python-docx generation, raw OOXML editing of existing files, document structure and formatting, and render verification. Not for PDFs, spreadsheets, or Google Docs.

日本語の概要は準備中です。原文の説明を表示しています。

asgeirtj/system_prompts_leaks7万2026年10月12日 更新

asgeirtj のスキルをすべて見る

このスキルの問題を報告する