Urgent.News

What's breaking now, across hundreds of outlets.

AI

A sandbox for Claude Code: running it headless in a cloud workspace

Short answer: if you want Claude Code's commands off your machine, run Claude Code itself on a cloud computer and drive it with claude -p . A Sandscale workspace is a Firecracker microVM with its own kernel and a disk that survives between sessions, so the repository, the installed tools and Claude Code's own session files are still there next time, and nothing it runs touches your laptop. This…

To run Claude Code headlessly in the cloud, follow these steps:

1. Create a Sandscale workspace, install Claude Code, clone your repository, and sign in to Claude Code. The workspace provides a separate environment for Claude Code to run code without affecting your local machine.

2. Run Claude Code in headless mode using the -p flag. Specify the tools Claude Code is allowed to use with the --allowedTools flag. The output will be returned in JSON format, including the session ID.

3. To continue a session, use the session ID retrieved in the previous step. Use the claude -p command with the --resume flag followed by the session ID.

4. To keep the Claude Code workspace running even after you disconnect, use a terminal multiplexer like tmux to detach from the session. The workspace will continue running until it is stopped or reaches a scheduled stop time.

5. To view the results from your local machine, reconnect to the workspace using sandscale workspace open or sandscale workspace ssh. If the Claude Code session started a development server, you can access it locally using sandscale workspace port-forward.

Running Claude Code in a Sandscale workspace provides a sandboxed environment for the model to execute code without impacting your local machine. The workspace keeps its disk when stopped, preserving your repository, installed tools, and Claude Code session files. Network access is required for Claude Code to communicate with Anthropic's API.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in AI

How much does AI integration cost? Read the drivers before the quote

If you're trying to work out how much an AI integration will cost, you've probably noticed that nobody will answer without a call, and that quotes for what sounds like the same job can be far apart.

  • Identify systems as readers or writers to determine integration cost.
  • Consider data quality issues and permissions for additional expenses.
  • Evaluate building, buying, or using existing AI capabilities for cost-effectiveness.

More from Friday 27 November →