Skip to main content

AI-Powered Development with Claude Code on Morph Cloud

tl;dr Launch cloud development environments with Claude Code AI assistance. Create, branch, and restore AI-powered development environments within seconds for intelligent coding, debugging, and code review.

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.

Quick Start

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