Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions registry/coder/modules/claude-code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Run the [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude
```tf
module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "4.2.7"
version = "4.3.0"
agent_id = coder_agent.main.id
workdir = "/home/coder/project"
claude_api_key = "xxxx-xxxxx-xxxx"
Expand Down Expand Up @@ -45,7 +45,7 @@ This example shows how to configure the Claude Code module to run the agent behi
```tf
module "claude-code" {
source = "dev.registry.coder.com/coder/claude-code/coder"
version = "4.2.7"
version = "4.3.0"
agent_id = coder_agent.main.id
workdir = "/home/coder/project"
enable_boundary = true
Expand All @@ -72,7 +72,7 @@ data "coder_parameter" "ai_prompt" {

module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "4.2.7"
version = "4.3.0"
agent_id = coder_agent.main.id
workdir = "/home/coder/project"

Expand Down Expand Up @@ -108,7 +108,7 @@ Run and configure Claude Code as a standalone CLI in your workspace.
```tf
module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "4.2.7"
version = "4.3.0"
agent_id = coder_agent.main.id
workdir = "/home/coder/project"
install_claude_code = true
Expand All @@ -130,7 +130,7 @@ variable "claude_code_oauth_token" {

module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "4.2.7"
version = "4.3.0"
agent_id = coder_agent.main.id
workdir = "/home/coder/project"
claude_code_oauth_token = var.claude_code_oauth_token
Expand Down Expand Up @@ -203,7 +203,7 @@ resource "coder_env" "bedrock_api_key" {

module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "4.2.7"
version = "4.3.0"
agent_id = coder_agent.main.id
workdir = "/home/coder/project"
model = "global.anthropic.claude-sonnet-4-5-20250929-v1:0"
Expand Down Expand Up @@ -260,7 +260,7 @@ resource "coder_env" "google_application_credentials" {

module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "4.2.7"
version = "4.3.0"
agent_id = coder_agent.main.id
workdir = "/home/coder/project"
model = "claude-sonnet-4@20250514"
Expand Down
16 changes: 8 additions & 8 deletions registry/coder/modules/claude-code/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,20 @@

test("claude-model", async () => {
const model = "opus";
const { id } = await setup({
const { id, state } = await setup({
moduleVariables: {
model: model,
ai_prompt: "test prompt",
},
});
await execModuleScript(id);

const startLog = await execContainer(id, [
"bash",
"-c",
"cat /home/coder/.claude-module/agentapi-start.log",
]);
expect(startLog.stdout).toContain(`--model ${model}`);
// Verify ANTHROPIC_MODEL env var is set via coder_env
const envResources = state.resources.filter(

Check failure on line 195 in registry/coder/modules/claude-code/main.test.ts

View workflow job for this annotation

GitHub Actions / Validate Terraform output

TypeError: undefined is not an object (evaluating 'state.resources')

at <anonymous> (/home/runner/work/registry/registry/registry/coder/modules/claude-code/main.test.ts:195:26)
(r) => r.type === "coder_env" && r.name === "anthropic_model",
);
expect(envResources.length).toBe(1);
expect(envResources[0].instances[0].attributes.name).toBe("ANTHROPIC_MODEL");
expect(envResources[0].instances[0].attributes.value).toBe(model);
});

test("claude-continue-resume-task-session", async () => {
Expand Down
19 changes: 16 additions & 3 deletions registry/coder/modules/claude-code/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ variable "claude_api_key" {

variable "model" {
type = string
description = "Sets the model for the current session with an alias for the latest model (sonnet or opus) or a model’s full name."
description = "Sets the default model for Claude Code via ANTHROPIC_MODEL env var. If empty, Claude Code uses its default (Sonnet 4.5). Supports aliases (sonnet, opus) or full model names."
default = ""
}

Expand Down Expand Up @@ -288,10 +288,24 @@ resource "coder_env" "disable_autoupdater" {
value = "1"
}

variable "claude_path" {
type = string
description = "Path to prepend to PATH for Claude Code binary. Defaults to $HOME/.local/bin"
default = ""
}

resource "coder_env" "claude_binary_path" {
agent_id = var.agent_id
name = "PATH"
value = "$HOME/.local/bin:$PATH"
value = var.claude_path != "" ? "${var.claude_path}:$PATH" : "$HOME/.local/bin:$PATH"
}

resource "coder_env" "anthropic_model" {
count = var.model != "" ? 1 : 0

agent_id = var.agent_id
name = "ANTHROPIC_MODEL"
value = var.model
}

locals {
Expand Down Expand Up @@ -364,7 +378,6 @@ module "agentapi" {
echo -n '${base64encode(local.start_script)}' | base64 -d > /tmp/start.sh
chmod +x /tmp/start.sh

ARG_MODEL='${var.model}' \
ARG_RESUME_SESSION_ID='${var.resume_session_id}' \
ARG_CONTINUE='${var.continue}' \
ARG_DANGEROUSLY_SKIP_PERMISSIONS='${var.dangerously_skip_permissions}' \
Expand Down
6 changes: 0 additions & 6 deletions registry/coder/modules/claude-code/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ command_exists() {
command -v "$1" > /dev/null 2>&1
}

ARG_MODEL=${ARG_MODEL:-}
ARG_RESUME_SESSION_ID=${ARG_RESUME_SESSION_ID:-}
ARG_CONTINUE=${ARG_CONTINUE:-false}
ARG_DANGEROUSLY_SKIP_PERMISSIONS=${ARG_DANGEROUSLY_SKIP_PERMISSIONS:-}
Expand All @@ -26,7 +25,6 @@ ARG_CODER_HOST=${ARG_CODER_HOST:-}

echo "--------------------------------"

printf "ARG_MODEL: %s\n" "$ARG_MODEL"
printf "ARG_RESUME: %s\n" "$ARG_RESUME_SESSION_ID"
printf "ARG_CONTINUE: %s\n" "$ARG_CONTINUE"
printf "ARG_DANGEROUSLY_SKIP_PERMISSIONS: %s\n" "$ARG_DANGEROUSLY_SKIP_PERMISSIONS"
Expand Down Expand Up @@ -171,10 +169,6 @@ function start_agentapi() {
mkdir -p "$ARG_WORKDIR"
cd "$ARG_WORKDIR"

if [ -n "$ARG_MODEL" ]; then
ARGS+=(--model "$ARG_MODEL")
fi

if [ -n "$ARG_PERMISSION_MODE" ]; then
ARGS+=(--permission-mode "$ARG_PERMISSION_MODE")
fi
Expand Down
Loading