Skip to main content

AI-Powered Development with Claude Code on Morph Cloud

tl;dr Launch cloud development environments with Claude Code AI assistance. Use Devboxes for the fastest path to a shareable, persistent workspace—or use instances/snapshots if you need VM primitives.

Claude Code Development Environment

Prerequisites

Install the Morph Cloud SDK

To get started, install the Morph Python SDK:

uv pip install morphcloud

Set your API key

export MORPH_API_KEY='your-key-here'

You can generate an API key in the Morph Cloud console.

Devboxes are the best default for Claude Code because they're designed for development:

  • one-click VSCode/Cursor access
  • SSH when you need it
  • tmux integration for CLI agents (and human-in-the-loop workflows)

If Claude Code needs to self-manage the current devbox through morphcloud-devbox-service, use a least-privilege agent token instead of handing the session a broad MORPH_API_KEY.

Quick start (dashboard)

  1. Create a devbox: https://cloud.morph.so/web/devboxes/new
  2. Open it in VSCode/Cursor (or SSH into it)
  3. Install Claude Code in the devbox and start a tmux session for your agent
  4. Share the devbox or preview URLs with your team inside your organization

Quick start (CLI)

export MORPH_API_KEY="..."

morphcloud devbox template list
TEMPLATE_ID="<template-id>"
DEVBOX_ID=$(
morphcloud devbox start "$TEMPLATE_ID" --name "claude-dev" --json | jq -r '.id'
)

# Install claude-code and dev tooling inside the devbox
morphcloud devbox ssh "$DEVBOX_ID" bash -lc "sudo apt update && sudo apt install -y git gh nodejs npm tmux"
morphcloud devbox ssh "$DEVBOX_ID" bash -lc "npm install -g @anthropic-ai/claude-code"

Power users: VM primitives (instances + snapshots)

Here's the complete setup script for Claude Code development:

# claude_dev_setup.py
from morphcloud.api import MorphCloudClient

def setup_claude_dev_environment():
client = MorphCloudClient()

# Create a new instance
instance = client.instances.start()
print(f"Instance started: {instance.id}")

# Install Claude Code CLI
instance.exec("curl -fsSL https://claude.ai/install.sh | sh")
instance.exec("npm install -g @anthropic-ai/claude-code")

# Install development tools
instance.exec("sudo apt update")
instance.exec("sudo apt install -y git gh nodejs npm python3 python3-pip tmux")

# Configure Git and GitHub CLI
instance.exec("git config --global init.defaultBranch main")

# Set up workspace directory
instance.exec("mkdir -p /workspace")
instance.exec("cd /workspace")

# Configure Claude Code with API key
instance.exec("echo 'export ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY' >> ~/.bashrc")

# Create tmux session for Claude
instance.exec("tmux new-session -d -s claude-session")

# Create snapshot
snapshot = instance.snapshot()
print(f"Snapshot created: {snapshot.id}")

return snapshot.id

if __name__ == "__main__":
snapshot_id = setup_claude_dev_environment()
print(f"Setup complete! Use snapshot ID: {snapshot_id}")

Installation

# Install dependencies
curl -LsSf https://astral.sh/uv/install.sh | sh
source ~/.local/bin/env
uv venv && source .venv/bin/activate
uv pip install morphcloud

# Set your API keys
export MORPH_API_KEY='your-key-here'
export ANTHROPIC_API_KEY='your-claude-key-here'

# Run the setup script
uv run python claude_dev_setup.py

The setup script will:

  1. Create or reuse a base MorphVM snapshot
  2. Launch a new instance
  3. Install and configure Claude Code CLI
  4. Set up development tools (Git, GitHub CLI, Node.js, Python)
  5. Configure persistent tmux sessions
  6. Expose the environment via SSH

Once the initial setup is complete, launching new Claude Code instances takes just seconds, enabling:

  • Instant AI-powered development environments
  • Perfect state preservation via Morph Cloud snapshots
  • Isolated development sessions for different projects