7.3 KiB
| display_name | description | icon | verified | tags | |||||
|---|---|---|---|---|---|---|---|---|---|
| Claude Code | Run the Claude Code agent in your workspace. | ../../../../.icons/claude.svg | true |
|
Claude Code
Run the Claude Code agent in your workspace to generate code and perform tasks. This module integrates with AgentAPI for task reporting in the Coder UI.
module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "3.0.1"
agent_id = coder_agent.example.id
workdir = "/home/coder/project"
claude_api_key = "xxxx-xxxxx-xxxx"
}
Warning
Security Notice: This module uses the
--dangerously-skip-permissionsflag when running Claude Code tasks. This flag bypasses standard permission checks and allows Claude Code broader access to your system than normally permitted. While this enables more functionality, it also means Claude Code can potentially execute commands with the same privileges as the user running it. Use this module only in trusted environments and be aware of the security implications.
Note
By default, this module is configured to run the embedded chat interface as a path-based application. In production, we recommend that you configure a wildcard access URL and set
subdomain = true. See here for more details.
Prerequisites
- An Anthropic API key or a Claude Session Token is required for tasks.
- You can get the API key from the Anthropic Console.
- You can get the Session Token using the
claude setup-tokencommand. This is a long-lived authentication token (requires Claude subscription)
Examples
Usage with Tasks and Advanced Configuration
This example shows how to configure the Claude Code module with an AI prompt, API key shared by all users of the template, and other custom settings.
data "coder_parameter" "ai_prompt" {
type = "string"
name = "AI Prompt"
default = ""
description = "Initial task prompt for Claude Code."
mutable = true
}
module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "3.0.1"
agent_id = coder_agent.example.id
workdir = "/home/coder/project"
claude_api_key = "xxxx-xxxxx-xxxx"
# OR
claude_code_oauth_token = "xxxxx-xxxx-xxxx"
claude_code_version = "1.0.82" # Pin to a specific version
agentapi_version = "v0.6.1"
ai_prompt = data.coder_parameter.ai_prompt.value
model = "sonnet"
permission_mode = "plan"
mcp = <<-EOF
{
"mcpServers": {
"my-custom-tool": {
"command": "my-tool-server"
"args": ["--port", "8080"]
}
}
}
EOF
}
Standalone Mode
Run and configure Claude Code as a standalone CLI in your workspace.
module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "3.0.1"
agent_id = coder_agent.example.id
workdir = "/home/coder"
install_claude_code = true
claude_code_version = "latest"
report_tasks = false
cli_app = true
}
Usage with Claude Code Subscription
variable "claude_code_oauth_token" {
type = string
description = "Generate one using `claude setup-token` command"
sensitive = true
value = "xxxx-xxx-xxxx"
}
module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "3.0.1"
agent_id = coder_agent.example.id
workdir = "/home/coder/project"
claude_code_oauth_token = var.claude_code_oauth_token
}
Usage with AWS Bedrock
Prerequisites
AWS account with Bedrock access, Claude models enabled in Bedrock console, appropriate IAM permissions.
Configure Claude Code to use AWS Bedrock for accessing Claude models through your AWS infrastructure.
module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "3.0.1"
agent_id = coder_agent.example.id
workdir = "/home/coder/project"
model = "anthropic.claude-3-5-sonnet-20241022-v2:0" # Bedrock model ID
use_bedrock = true
aws_region = "us-west-2"
# Option 1: Using AWS credentials
aws_access_key_id = "AKIA..."
aws_secret_access_key = "your-secret-key"
# Option 2: Using Bedrock API key (alternative to AWS credentials)
# aws_bearer_token_bedrock = "your-bedrock-api-key"
}
Note
For model IDs and available models in your region, refer to the AWS Bedrock documentation. For additional Bedrock configuration options (model selection, token limits, region overrides, etc.), see the Claude Code Bedrock documentation.
Usage with Google Vertex AI
Prerequisites
GCP project with Vertex AI API enabled, Claude models enabled through Model Garden, Google Cloud authentication configured, appropriate IAM permissions.
Configure Claude Code to use Google Vertex AI for accessing Claude models through Google Cloud Platform.
module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "3.0.1"
agent_id = coder_agent.example.id
workdir = "/home/coder/project"
model = "claude-3-5-sonnet@20241022" # Vertex AI model name
use_vertex = true
vertex_project_id = "your-gcp-project-id"
vertex_region = "us-central1" # or "global"
}
Authentication
Vertex AI uses Google Cloud authentication. Ensure your workspace has access to Google Cloud credentials through one of these methods:
- Application Default Credentials (ADC): Set up through
gcloud auth application-default login - Service Account: Configure
GOOGLE_APPLICATION_CREDENTIALSenvironment variable - Workload Identity: For GKE deployments
Refer to the Google Cloud authentication documentation for detailed setup instructions.
Note
For additional Vertex AI configuration options (model selection, token limits, region overrides, etc.), see the Claude Code Vertex AI documentation.
Troubleshooting
If you encounter any issues, check the log files in the ~/.claude-module directory within your workspace for detailed information.
# Installation logs
cat ~/.claude-module/install.log
# Startup logs
cat ~/.claude-module/agentapi-start.log
# Pre/post install script logs
cat ~/.claude-module/pre_install.log
cat ~/.claude-module/post_install.log
Note
To use tasks with Claude Code, you must provide an
anthropic_api_keyorclaude_code_oauth_token. Theworkdirvariable is required and specifies the directory where Claude Code will run.