Run Claude Code tasks asynchronously on secure cloud infrastructure
在安全的云基础设施上异步运行 Claude Code 任务
一,What is Claude Code on the web?
网页上的 Claude Code 是什么?
Claude Code on the web lets developers kick off Claude Code from the Claude app. This is perfect for:
网页上的 Claude Code 允许开发者从 Claude app中启动 Claude Code。非常适合:
Answering questions: Ask about code architecture and how features are implemented
回答问题:询问代码架构以及功能是如何实现的
Bug fixes and routine tasks: Well-defined tasks that don't require frequent steering
Bug 修复和常规任务:定义明确且无需频繁指导的任务
Parallel work: Tackle multiple bug fixes in parallel
并行工作:同时处理多个 Bug 修复
Repositories not on your local machine: Work on code you don't have checked out locally
不在本地机器上的仓库:处理未在本地检出的代码
Backend changes: Where Claude Code can write tests and then write code to pass those tests
后端变更:Claude Code 可以编写测试,然后编写代码通过这些测试
Claude Code is also available on the Claude iOS app for kicking off tasks on the go and monitoring work in progress.
Claude Code 也可以在 Claude iOS app中使用,方便随时随地启动任务并监控进行中的工作。
You can move between local and remote development: send tasks from your terminal to run on the web with the & prefix,
or teleport web sessions back to your terminal to continue locally.
可以在本地和远程开发之间切换:通过在终端中使用 & 前缀发送任务,使其在网页上运行,
或者将网页会话传送回终端,以便在本地继续进行。
二,Who can use Claude Code on the web?
谁可以使用 Claude Code on the web?
Pro users 专业用户
Max users 最大用户数
Team premium seat users 团队高级席位用户
Enterprise premium seat users 企业高级席位用户
三,Getting started 开始使用
Visit claude.ai/code 访问 claude.ai/code
Connect your GitHub account
连接你的 GitHub 账户
Install the Claude GitHub app in your repositories
在你的仓库中安装 Claude GitHub 应用程序
Select your default environment
选择你的默认环境
Submit your coding task
提交你的编程任务
Review changes and create a pull request in GitHub
在 GitHub 上审查更改并创建拉取请求
四,How it works 工作原理
When you start a task on Claude Code on the web:
当你在 Claude Code on the web 上开始一个任务时:
1,Repository cloning: Your repository is cloned to an Anthropic-managed virtual machine
仓库克隆:你的仓库被克隆到 Anthropic 管理的虚拟机上
2,Environment setup: Claude prepares a secure cloud environment with your code
环境设置:Claude 准备了一个安全的云环境,包含你的代码
3,Network configuration: Internet access is configured based on your settings
网络配置:根据你的设置配置互联网访问
4,Task execution: Claude analyzes code, makes changes, runs tests, and checks its work
任务执行:Claude 分析代码,进行修改,运行测试,并检查其工作
5,Completion: You're notified when finished and can create a PR with the changes
完成:当任务完成后会通知您,您可以创建一个包含修改的 PR
6,Results: Changes are pushed to a branch, ready for pull request creation
结果:修改会被推送到一个分支,准备好创建PR拉取请求
五,Moving tasks between web and terminal
在网页和终端之间移动任务
You can start tasks on the web and continue them in your terminal, or send tasks from your terminal to run on the web.
Web sessions persist even if you close your laptop, and you can monitor them from anywhere including the Claude iOS app.
你可以在网页上启动任务并在你的终端中继续,或者从终端发送任务到网页上运行。
即使你关闭了笔记本电脑,网页会话仍然持续存在,并且你可以在任何地方监控它们,包括通过 Claude iOS app。
Session handoff is one-way: you can pull web sessions into your terminal, but you can't push an existing terminal session to the web.
The & prefix creates a new web session with your current conversation context.
会话转接是单向的:你可以将网页会话拉入你的终端,但你不能将现有的终端会话推送到网页。
& 前缀会创建一个带有你当前对话上下文的新网页会话。
5.1 From terminal to web 从终端到网页
Start a message with & inside Claude Code to send a task to run on the web:
在 Claude Code 中输入以 & 开头的信息来发送任务到网页上运行:
& Fix the authentication bug in src/auth/login.ts
修复src/auth/login.ts中的认证错误
This creates a new web session on claude.ai with your current conversation context. The task runs in the cloud while you continue working locally. Use /tasks to check progress,
or open the session on claude.ai or the Claude iOS app to interact directly. From there you can steer Claude, provide feedback, or answer questions just like any other conversation.
这将在 claude.ai 上创建一个新的网络会话,并包含您当前的对话上下文。任务在云端运行,而您可以在本地继续工作。使用 /tasks 检查进度,
或直接在 claude.ai 或 Claude iOS app上打开会话进行交互。从那里你可以像处理任何其他对话一样引导 Claude、提供反馈或回答问题。
You can also start a web session directly from the command line:
也可以直接从命令行启动网络会话:
claude --remote "Fix the authentication bug in src/auth/login.ts"
Tips for background tasks
后台任务小贴士
Plan locally, execute remotely: For complex tasks, start Claude in plan mode to collaborate on the approach before sending work to the web:
本地规划,远程执行:对于复杂任务,先以规划模式启动 Claude,在将工作发送到网络前 先协作制定好方案:
claude --permission-mode plan
In plan mode, Claude can only read files and explore the codebase. Once you're satisfied with the plan, send it to the web for autonomous execution:
在计划模式下,Claude 只能读取文件并探索代码库。当你对计划满意后,将其发送到网络进行自主执行:
& Execute the migration plan we discussed
This pattern gives you control over the strategy while letting Claude execute autonomously in the cloud.
这种模式让你能够控制策略,同时让 Claude 在云端自主执行。
Run tasks in parallel: Each & command creates its own web session that runs independently. You can kick off multiple tasks and they'll all run simultaneously in separate sessions:
并行运行任务:每个 & 命令都会创建自己的网络会话,独立运行。你可以启动多个任务,它们将在不同的会话中同时运行:
& Fix the flaky test in auth.spec.ts
& Update the API documentation
& Refactor the logger to use structured output
Monitor all sessions with /tasks. When a session completes, you can create a PR from the web interface or teleport the session to your terminal to continue working.
使用 /tasks 监控所有会话。当会话结束时,你可以从网页界面创建一个 PR,或者将会话传送到你的终端以继续工作。
5.2 From web to terminal 从网页到终端
There are several ways to pull a web session into your terminal:
有4种方法可以将网络会话拉入您的终端:
5.2.1 Using /teleport: From within Claude Code, run /teleport (or /tp) to see an interactive picker of your web sessions. If you have uncommitted changes, you'll be prompted to stash them first.
使用 /teleport :在 Claude Code 中,运行 /teleport (或 /tp )以查看您的网络会话的交互式选择器。如果您有未提交的更改,系统会提示你先暂存它们。
5.2.2 Using --teleport: From the command line, run claude --teleport for an interactive session picker, or claude --teleport <session-id> to resume a specific session directly.
使用 --teleport :在命令行中,运行 claude --teleport 以获取交互式会话选择器,或运行 claude --teleport <session-id> 直接恢复特定会话。
5.2.3 From /tasks: Run /tasks to see your background sessions, then press t to teleport into one
从 /tasks :运行 /tasks 查看您的后台会话,然后按 t 传送进入其中一个
5.2.4 From the web interface: Click "Open in CLI" to copy a command you can paste into your terminal
从网页界面:点击"在 CLI 中打开"以复制可粘贴到您终端的命令
When you teleport a session, Claude verifies you're in the correct repository, fetches and checks out the branch from the remote session, and loads the full conversation history into your terminal.
当你传送会话时,Claude 会验证你位于正确的仓库中,从远程会话中获取并切换到分支,并将完整的对话历史加载到你的终端中。
Requirements for teleporting
传送要求
Teleport checks these requirements before resuming a session. If any requirement isn't met, you'll see an error or be prompted to resolve the issue.
Teleport 在恢复会话前会检查这些要求。如果任何要求未满足,你会看到错误信息或被提示解决该问题。
1,Clean git state 干净的 git 状态
Your working directory must have no uncommitted changes. Teleport prompts you to stash changes if needed.
你的工作目录中不能有未提交的更改。如果需要,Teleport 会提示你暂存更改。
2,Correct repository 正确仓库
You must run --teleport from a checkout of the same repository, not a fork.
你必须在同一仓库中运行 --teleport ,而不是从fork的仓库中运行。
3,Branch available 可用的分支
The branch from the web session must have been pushed to the remote. Teleport automatically fetches and checks it out.
来自网络会话的分支必须已推送到远程仓库。Teleport 会自动获取并检出它。
4,Same account 相同账户
You must be authenticated to the same Claude.ai account used in the web session.
您必须使用与网络会话相同的 Claude.ai 账户进行身份验证。
六,Cloud environment 云环境
6.1 Default image 默认镜像
We build and maintain a universal image with common toolchains and language ecosystems pre-installed. This image includes:
我们构建并维护一个预装了通用工具链和语言生态系统的通用镜像。该镜像包括:
Popular programming languages and runtimes
流行的编程语言和运行时环境
Common build tools and package managers
常见的构建工具和包管理器
Testing frameworks and linters
测试框架和代码检查工具
6.1.1 Checking available tools 检查可用工具
To see what's pre-installed in your environment, ask Claude Code to run:
要查看您的环境中预装了什么,请让 Claude Code 运行:
check-tools
This command displays: 此命令会显示:
Programming languages and their versions
编程语言及其版本
Available package managers
可用的包管理器
Installed development tools
已安装的开发工具
6.1.2 Language-specific setups 特定语言的设置
The universal image includes pre-configured environments for:
通用镜像包含预配置的环境:
Python: Python 3.x with pip, poetry, and common scientific libraries
Python: Python 3.x 配合 pip、poetry 以及常见的科学计算库
Node.js: Latest LTS versions with npm, yarn, pnpm, and bun
Node.js: 最新 LTS 版本配合 npm、yarn、pnpm 和 bun
Ruby: Versions 3.1.6, 3.2.6, 3.3.6 (default: 3.3.6) with gem, bundler, and rbenv for version management
Ruby: 版本 3.1.6、3.2.6、3.3.6(默认:3.3.6)配合 gem、bundler 和 rbenv 进行版本管理
PHP: Version 8.4.14
PHP: 版本 8.4.14
Java: OpenJDK with Maven and Gradle
Go: Latest stable version with module support
Rust: Rust toolchain with cargo
C++: GCC and Clang compilers
6.1.3 Databases 数据库
The universal image includes the following databases:
通用镜像包含以下数据库:
PostgreSQL: Version 16
PostgreSQL: 版本 16
Redis: Version 7.0
Redis: 版本 7.0
6.2 Environment configuration
环境配置
When you start a session in Claude Code on the web, here's what happens under the hood:
当你在网页版 Claude Code 中启动一个会话时,后台会发生以下情况:
Environment preparation: We clone your repository and run any configured Claude hooks for initialization. The repo will be cloned with the default branch on your GitHub repo. If you would like to check out a specific branch, you can specify that in the prompt.
环境准备:我们会克隆你的仓库并运行任何配置的 Claude 钩子进行初始化。该仓库将使用你 GitHub 仓库的默认分支进行克隆。如果你想要检出特定分支,可以在提示中指定。
Network configuration: We configure internet access for the agent. Internet access is limited by default, but you can configure the environment to have no internet or full internet access based on your needs.
网络配置:我们为agent配置互联网访问。默认情况下,互联网访问是受限的,但你可以根据需要配置环境为 无互联网访问或完全的互联网访问。
Claude Code execution: Claude Code runs to complete your task, writing code, running tests, and checking its work. You can guide and steer Claude throughout the session via the web interface. Claude respects context you've defined in your CLAUDE.md.
Claude Code 执行:Claude Code 会运行以完成你的任务,编写代码、运行测试并检查其工作。你可以通过网页界面session在整个过程中指导和引导 Claude。Claude 会尊重你在 CLAUDE.md 中定义的上下文。
Outcome: When Claude completes its work, it will push the branch to remote. You will be able to create a PR for the branch.
结果:当 Claude 完成工作后,它会将分支推送到远程仓库。您将能够为该分支创建一个 PR(Pull Request)。
Claude operates entirely through the terminal and CLI tools available in the environment. It uses the pre-installed tools in the universal image and any additional tools you install through hooks or dependency management.
Claude 完全通过环境中的终端和 CLI 里面可用的工具运行。它使用通用镜像中预安装的工具,以及通过钩子或依赖管理安装的任何附加工具。
To add a new environment: Select the current environment to open the environment selector, and then select "Add environment". This will open a dialog where you can specify the environment name, network access level, and any environment variables you want to set.
添加新环境:选择当前环境以打开环境选择器,然后选择"添加环境"。这将打开一个对话框,您可以在其中指定环境名称、网络访问级别以及您想要设置的任何环境变量。
To update an existing environment: Select the current environment, to the right of the environment name, and select the settings button. This will open a dialog where you can update the environment name, network access, and environment variables.
更新现有环境:选择当前环境,在环境名称右侧,选择设置按钮。这将打开一个对话框,您可以在其中更新环境名称、网络访问和环境变量。
To select your default environment from the terminal: If you have multiple environments configured, run /remote-env to choose which one to use when starting web sessions from your terminal with & or --remote. With a single environment, this command shows your current configuration.
从终端选择默认环境:如果你配置了多个环境,运行 /remote-env 来选择 使用 & 或 --remote 启动网页会话时要使用的环境。对于单个环境,此命令显示你的当前配置。
Environment variables must be specified as key-value pairs, in .env format. For example:
环境变量必须以键值对的形式指定,格式为 .env 。例如:
API_KEY=your_api_key
DEBUG=true
6.3 Dependency management 依赖管理
Configure automatic dependency installation using SessionStart hooks. This can be configured in your repository's .claude/settings.json file:
使用 SessionStart 钩子配置自动依赖安装。这可以在您的仓库的 .claude/settings.json 文件中配置:
{
"hooks": {
"SessionStart": [
{
"matcher": "startup",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/scripts/install_pkgs.sh"
}
]
}
]
}
}
Create the corresponding script at scripts/install_pkgs.sh:
在 scripts/install_pkgs.sh 创建相应的脚本:
#!/bin/bash
npm install
pip install -r requirements.txt
exit 0
Make it executable: chmod +x scripts/install_pkgs.sh
使其可执行: chmod +x scripts/install_pkgs.sh
6.3.1 Local vs remote execution
本地执行与远程执行
By 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.
默认情况下,所有钩子都在本地和远程(网络)环境中执行。若要在仅一个环境中运行钩子,请在钩子脚本中检查 CLAUDE_CODE_REMOTE 环境变量。
#!/bin/bash
Example: Only run in remote environments
if [ "$CLAUDE_CODE_REMOTE" != "true" ]; then
exit 0
fi
npm install
pip install -r requirements.txt
6.3.2 Persisting environment variables
持久化环境变量
SessionStart hooks can persist environment variables for subsequent bash commands by writing to the file specified in the CLAUDE_ENV_FILE environment variable.
SessionStart 钩子可以通过写入 CLAUDE_ENV_FILE 环境变量指定的文件来持久化环境变量,以便后续的 bash 命令使用。
七,Network access and security
网络访问和安全
7.1 Network policy 网络策略
7.1.1 GitHub proxy
GitHub 代理
For security, all GitHub operations go through a dedicated proxy service that transparently handles all git interactions. Inside the sandbox, the git client authenticates using a custom-built scoped credential. This proxy:
出于安全考虑,所有 GitHub 操作都通过一个专用的代理服务进行,该服务透明地处理所有 git 交互。在沙盒内部,git 客户端使用一个 自定义构建的范围凭证 进行身份验证。这个代理:
Manages GitHub authentication securely - the git client uses a scoped credential inside the sandbox, which the proxy verifies and translates to your actual GitHub authentication token
安全地管理 GitHub 身份验证 - git 客户端在沙盒内部使用一个范围凭证,代理会验证并将其转换为您的实际 GitHub 身份验证令牌
Restricts git push operations to the current working branch for safety
为安全起见,限制 git push 操作仅限于当前工作分支
Enables seamless cloning, fetching, and PR operations while maintaining security boundaries
支持无缝克隆、获取和 PR 操作,同时保持安全边界
7.1.2 Security proxy 安全代理
Environments run behind an HTTP/HTTPS network proxy for security and abuse prevention purposes. All outbound internet traffic passes through this proxy, which provides:
环境在 HTTP/HTTPS 网络代理后面运行,目的是为了安全和防止滥用。所有出站互联网流量都通过这个代理,它提供:
Protection against malicious requests
防范恶意请求
Rate limiting and abuse prevention
速率限制和滥用防护
Content filtering for enhanced security
内容过滤以增强安全性
7.2 Access levels 访问权限
By default, network access is limited to allowlisted domains.
默认情况下,网络访问仅限于白名单域名。
You can configure custom network access, including disabling network access.
您可以配置自定义网络访问,包括禁用网络访问。
7.3 Default allowed domains 默认允许的域名
When using "Limited" network access, the following domains are allowed by default:
在使用"有限"网络访问时,默认允许官方指定的域名。
7.4 Security best practices for customized network access
定制网络访问的安全最佳实践
Principle of least privilege: Only enable the minimum network access required
最小权限原则:仅启用所需的最低网络访问权限
Audit regularly: Review allowed domains periodically
定期审计:定期审查允许的域名
Use HTTPS: Always prefer HTTPS endpoints over HTTP
使用 HTTPS:始终优先选择 HTTPS 端点而非 HTTP
八,Security and isolation 安全与隔离
Claude Code on the web provides strong security guarantees:
Claude Code on the web 提供了强大的安全保证:
Isolated virtual machines: Each session runs in an isolated, Anthropic-managed VM
隔离的虚拟机:每个会话都在一个隔离的、由 Anthropic 管理的虚拟机中运行
Network access controls: Network access is limited by default, and can be disabled
网络访问控制:默认情况下网络访问受限,可以禁用
When running with network access disabled, Claude Code is allowed to communicate with the Anthropic API which may still allow data to exit the isolated Claude Code VM.
当禁用网络访问时,Claude Code 允许与 Anthropic API 通信,这仍可能允许数据离开隔离的 Claude Code 虚拟机。
Credential protection: Sensitive credentials (such as git credentials or signing keys) are never inside the sandbox with Claude Code. Authentication is handled through a secure proxy using scoped credentials
凭证保护:敏感凭证(如 git 凭证或签名密钥)永远不会在 Claude Code 的沙盒内。认证通过使用限定凭证的安全代理进行处理。
Secure analysis: Code is analyzed and modified within isolated VMs before creating PRs
安全分析:在创建 PR 之前,代码会在隔离的虚拟机中进行分析和修改
九,Pricing and rate limits 定价和速率限制
Claude Code on the web shares rate limits with all other Claude and Claude Code usage within your account. Running multiple tasks in parallel will consume more rate limits proportionately.
Claude Code on the web 与你账户内所有其他 Claude 和 Claude Code 的使用共享速率限制。并行运行多个任务将按比例消耗更多速率限制。
十,Limitations 限制
Repository authentication: You can only move sessions from web to local when you are authenticated to the same account
仓库认证:只有当您认证到同一账户时,才能将会话从网络移动到本地
Platform restrictions: Claude Code on the web only works with code hosted in GitHub. GitLab and other non-GitHub repositories cannot be used with cloud sessions
平台限制:Claude Code on the web 仅适用于托管在 GitHub 上的代码。GitLab 和其他非 GitHub 仓库无法与云端会话一起使用
十一,Best practices 最佳实践
Use Claude Code hooks: Configure SessionStart hooks to automate environment setup and dependency installation.
使用 Claude Code 钩子:配置 SessionStart 钩子来自动化环境设置和依赖安装
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.
文档要求:在您的 CLAUDE.md 文件中明确指定依赖项和命令。如果您有 AGENTS.md 文件,您可以使用 @AGENTS.md 在 CLAUDE.md 中引用它,以维护单一事实来源。
小结:
使用&前缀可以启动多个任务,只适用于github, 使用 SessionStart 钩子安装依赖