startup-hook-skill
Skill0 starsChanged 8 months agoMITView on GitHub
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.
- Installs packages
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- amirbiron/claude-skillsedited, first seen Oct 11, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- amirbiron/claude-skills★ 063% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 4 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Create SessionStart hooks that install dependencies so tests and linters work in Claude Code on the web sessions.
- Very specific: line 43
Use $CLAUDE_ENV_FILE to persist variables for the session:
- Very specific: line 48
Use $CLAUDE_CODE_REMOTE to only run a script in a remote env:
- Distinctive: line 72
Create a script that installs dependencies.
- Distinctive: line 75
Don't use async mode in the first iteration.
- Very specific: line 76
Write the hook only for the web unless user asks otherwise (see $CLAUDE_CODE_REMOTE)
- Very specific: line 98
Add to .claude/settings.json (create if doesn't exist):
- Very specific: line 116
If .claude/settings.json exists, merge the hooks configuration.
- Distinctive: line 120
Run the hook script directly:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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 installThe 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
fiWorkflow
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)
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.sh4. 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.shIMPORTANT: 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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

