claude-code-on-the-web.md +16 −17
245 245
246### Dependency management246### Dependency management
247 247
248248Configure automatic dependency installation using [SessionStart hooks](/en/hooks#sessionstart). This can be configured in your repository's `.claude/settings.json` file:Custom environment images and snapshots are not yet supported. As a workaround, you can use [SessionStart hooks](/en/hooks#sessionstart) to install packages when a session starts. This approach has [known limitations](#dependency-management-limitations).
249
250To configure automatic dependency installation, add a SessionStart hook to your repository's `.claude/settings.json` file:
249 251
250```json theme={null}252```json theme={null}
251{253{
269 271
270```bash theme={null}272```bash theme={null}
271#!/bin/bash273#!/bin/bash
272npm install
273pip install -r requirements.txt
274exit 0
275```
276
277Make it executable: `chmod +x scripts/install_pkgs.sh`
278
279#### Local vs remote execution
280
281By 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.
282 274
283275```bash theme={null}# Only run in remote environments
284#!/bin/bash
285
286# Example: Only run in remote environments
287if [ "$CLAUDE_CODE_REMOTE" != "true" ]; then276if [ "$CLAUDE_CODE_REMOTE" != "true" ]; then
288 exit 0277 exit 0
289fi278fi
290 279
291npm install280npm install
292pip install -r requirements.txt281pip install -r requirements.txt
282exit 0
293```283```
294 284
295285#### Persisting environment variablesMake it executable: `chmod +x scripts/install_pkgs.sh`
286
287#### Persist environment variables
288
289SessionStart 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/hooks#sessionstart) in the hooks reference.
290
291#### Dependency management limitations
296 292
297293SessionStart 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/hooks#sessionstart) in the hooks reference.* **Hooks fire for all sessions**: SessionStart hooks run in both local and remote environments. There is no hook configuration to scope a hook to remote sessions only. To skip local execution, check the `CLAUDE_CODE_REMOTE` environment variable in your script as shown above.
294* **Requires network access**: Install commands need network access to reach package registries. If your environment is configured with "No internet" access, these hooks will fail. Use "Limited" (the default) or "Full" network access. The [default allowlist](#default-allowed-domains) includes common registries like npm, PyPI, RubyGems, and crates.io.
295* **Proxy compatibility**: All outbound traffic in remote environments passes through a [security proxy](#security-proxy). Some package managers do not work correctly with this proxy. Bun is a known example.
296* **Runs on every session start**: Hooks run each time a session starts or resumes, adding startup latency. Keep install scripts fast by checking whether dependencies are already present before reinstalling.
298 297
299## Network access and security298## Network access and security
300 299