claude-code-on-the-web.md +35 −6
129 129
130### Dependency management130### Dependency management
131 131
132132Configure automatic dependency installation using the `sessionStart` hook:Configure automatic dependency installation using [SessionStart hooks](/en/docs/claude-code/hooks#sessionstart). This can be configured in your repository's `.claude/settings.json` file:
133 133
134```json theme={null}134```json theme={null}
135{135{
136 "hooks": {136 "hooks": {
137137 "sessionStart": [ "SessionStart": [
138 {138 {
139139 "matcher": "", "matcher": "startup",
140 "hooks": [140 "hooks": [
141 {141 {
142 "type": "command",142 "type": "command",
143143 "command": "./scripts/install_pkgs.sh" "command": "\"$CLAUDE_PROJECT_DIR\"/scripts/install_pkgs.sh"
144 }144 }
145 ]145 ]
146 }146 }
149}149}
150```150```
151 151
152152This ensures dependencies are installed automatically when a new session starts with proper network access.Create the corresponding script at `scripts/install_pkgs.sh`:
153
154```bash theme={null}
155#!/bin/bash
156npm install
157pip install -r requirements.txt
158exit 0
159```
160
161Make it executable: `chmod +x scripts/install_pkgs.sh`
162
163#### Local vs remote execution
164
165By default, all hooks execute both locally and in remote (web) environments. To run a hook only in one environment, check the `CLAUDE_CODE_REMOTE` environment variable in your hook script.
166
167```bash theme={null}
168#!/bin/bash
169
170# Example: Only run in remote environments
171if [ "$CLAUDE_CODE_REMOTE" != "true" ]; then
172 exit 0
173fi
174
175npm install
176pip install -r requirements.txt
177```
178
179#### Persisting environment variables
180
181SessionStart hooks can persist environment variables for subsequent bash commands by writing to the file specified in the `CLAUDE_ENV_FILE` environment variable. For details, see [SessionStart hooks](/en/docs/claude-code/hooks#sessionstart) in the hooks reference.
153 182
154## Network access and security183## Network access and security
155 184
430 459
431## Best practices460## Best practices
432 461
4334621. **Use Claude Code hooks**: Configure [sessionStart hooks](/en/docs/claude-code/hooks#sessionstart) to automate environment setup, dependency installation, and network configuration1. **Use Claude Code hooks**: Configure [sessionStart hooks](/en/docs/claude-code/hooks#sessionstart) to automate environment setup and dependency installation.
4342. **Document requirements**: Clearly specify dependencies and commands in your `CLAUDE.md` file. If you have an `AGENTS.md` file, you can source it in your `CLAUDE.md` using `@AGENTS.md` to maintain a single source of truth.4632. **Document requirements**: Clearly specify dependencies and commands in your `CLAUDE.md` file. If you have an `AGENTS.md` file, you can source it in your `CLAUDE.md` using `@AGENTS.md` to maintain a single source of truth.
435 464
436## Related resources465## Related resources