CLAUDE_CODE_REMOTE is set when a Claude Code session runs in the cloud (claude --cloud) and unset on your machine. Check it inside a repo hook when a step should run only in the cloud VM.
Use
Repository hooks live in .claude/settings.json, so they run the same way locally and in the cloud. Gate the cloud-only part:
#!/usr/bin/env bash
# SessionStart hook
if [ -n "$CLAUDE_CODE_REMOTE" ]; then
npm install # fresh VM: install deps; locally they already exist
fi
Running processes do not survive the cloud environment cache, so start services in this hook rather than in a setup script. More in claude —cloud: the GitHub token never enters the VM.