How to Set Up Claude Code on Daytona

How to create a Daytona workspace, install Claude Code inside it, and run a fully cloud-based agent — laptop closed, session persistent, optionally accessible from your phone.

You can run Claude Code entirely in the cloud using a Daytona workspace — no local machine required. Create a workspace, install Claude Code, and the agent runs on Daytona's infrastructure while your laptop stays closed. Here's the complete setup.

TL;DR

  • Create a Daytona workspace pointing at your Git repo
  • Install Claude Code inside the workspace: npm install -g @anthropic-ai/claude-code
  • Wrap the session in tmux so it survives terminal disconnects
  • The Daytona VM keeps running whether your laptop is on or off
  • Optional: install Grass for mobile access without a terminal

Prerequisites

  • A Daytona account at daytona.io — the free tier is sufficient for this setup
  • A Git repository to work in
  • An Anthropic API key
  • Familiarity with cloud dev environments

Why run Claude Code on Daytona?

Running Claude Code locally means keeping your laptop on and awake. Long AI coding agent tasks — the 99.9th percentile Claude Code turn duration exceeded 45 minutes as of early 2026 per Anthropic's agent autonomy research — drain battery and tie up a machine. Daytona workspaces are transient dev servers: cloud VMs that run independently of your local hardware. The agent runs there; your laptop is irrelevant.

Step 1: Create a Daytona workspace

Log into daytona.io and create a new workspace. Point it at your Git repository — Daytona clones the repo and provisions a cloud VM with a terminal ready.

Alternatively, create a workspace from the CLI:

daytona create --repo https://github.com/your-org/your-repo

See the Daytona workspaces documentation for configuration options including custom base images and devcontainer support.

Step 2: Open the workspace terminal

Open the workspace in the Daytona web IDE, or SSH in directly:

daytona ssh your-workspace-name

You're now in a terminal inside the Daytona VM.

Step 3: Verify Node.js 18+

Daytona workspaces come with Node.js available. Verify the version:

node --version

If it's below 18, install via nvm:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install --lts

Step 4: Install Claude Code

npm install -g @anthropic-ai/claude-code

Verify:

claude --version

The Claude Code getting started guide covers any additional setup steps for authentication and initial configuration.

Step 5: Set the Anthropic API key

export ANTHROPIC_API_KEY="sk-ant-your-key-here"

To make it persist across sessions, add it to ~/.bashrc:

echo 'export ANTHROPIC_API_KEY="sk-ant-your-key-here"' >> ~/.bashrc
source ~/.bashrc

Daytona also supports workspace-level environment variables — set them in the workspace settings so you don't have to re-export on every connection.

Step 6: Verify Claude Code can read the repo

Navigate to the project root and start a session:

cd /workspace/your-repo
claude

Claude Code should start and be able to read the repository contents. Run a quick test — ask it to describe the project structure — before starting any long-running task.

Step 7: Wrap in tmux for persistence

The Daytona workspace VM keeps running when you close the web IDE or SSH connection. But the Claude Code process itself will exit if it's in a foreground terminal that closes. Fix this with tmux:

tmux new -s claude
cd /workspace/your-repo
claude

Detach without stopping: Ctrl+B D. The tmux session keeps running on the Daytona VM.

Reconnect later:

daytona ssh your-workspace-name
tmux attach -t claude

Resume the Claude Code session if it exited:

claude --continue

claude --continue restores the conversation history from the .jsonl transcript file at ~/.claude/projects/<cwd>/. See the Claude Code CLI reference for session management options.

Your laptop can now stay closed

At this point, Claude Code is running on the Daytona VM. The workspace runs independently of your local machine — no laptop required. You can:

  • Close the web IDE
  • Close your SSH connection
  • Put your laptop to sleep
  • Leave overnight

The agent keeps running. When you come back, daytona ssh your-workspace-name then tmux attach -t claude.

Going further: connecting from your phone

Claude Code is running in the cloud. To monitor it, approve tool requests, and send instructions from your phone without a terminal, install Grass in the workspace:

npm install -g @grass-ai/ide

In the project directory (or a second tmux window):

grass start --network remote-ip
# or: grass start --network tailscale (if Tailscale is set up on the workspace)

A QR code appears. Scan it from the Grass iOS or Android app. The Daytona workspace keeps running whether your laptop is on or off — and Grass keeps you connected to it from your phone.

Grass gives you live output streaming, native permission modals for agent approval gates, a file browser, diff viewer, and prompt input — all without opening a terminal. For mobile coding agent access to a cloud-based session, this is the direct path.

Frequently asked questions

How do I install Claude Code on Daytona?

Open a terminal in your Daytona workspace, verify Node.js 18+ is available, then run npm install -g @anthropic-ai/claude-code. Set your Anthropic API key and run claude in your project directory.

Can I run Claude Code on a Daytona workspace?

Yes. Daytona workspaces are Linux VMs with Node.js available. Claude Code installs and runs identically to any other Linux server. Wrap sessions in tmux to survive terminal disconnects.

Does Daytona support Claude Code out of the box?

Daytona doesn't install Claude Code automatically, but the prerequisites (Linux, Node.js) are available in standard Daytona workspaces. Install Claude Code manually with npm install -g @anthropic-ai/claude-code.

How do I keep Claude Code running in a Daytona workspace after I close the terminal?

Use tmux. Start a session with tmux new -s claude, run Claude Code inside it, and detach with Ctrl+B D. The Daytona VM keeps the tmux session running even after you close the web IDE or SSH connection.

Do I need to keep my laptop open to use Claude Code on Daytona?

No. Daytona workspaces run on cloud infrastructure independently of your local machine. Once you've started Claude Code inside a tmux session, you can close your laptop entirely. The agent runs on Daytona's VMs.

How do I set environment variables in a Daytona workspace?

For one-time sessions: export ANTHROPIC_API_KEY="sk-...". For persistence: add to ~/.bashrc. For workspace-level persistence across all sessions: set environment variables in the Daytona workspace settings via the web UI or daytona env set.

How do I access a Claude Code session running on Daytona from my phone?

Install Grass in the workspace (npm install -g @grass-ai/ide), then run grass start --network remote-ip or grass start --network tailscale. Scan the QR code from the Grass iOS or Android app. No SSH or terminal needed on the phone — the Grass app provides a native mobile interface to the running session.