Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 8 additions & 9 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.6"
version = "4.2.7"
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.6"
version = "4.2.7"
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.6"
version = "4.2.7"
agent_id = coder_agent.main.id
workdir = "/home/coder/project"

Expand All @@ -92,10 +92,9 @@ module "claude-code" {
{
"mcpServers": {
"my-custom-tool": {
"command": "my-tool-server"
"command": "my-tool-server",
"args": ["--port", "8080"]
}

}
}
EOF
Expand All @@ -109,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.6"
version = "4.2.7"
agent_id = coder_agent.main.id
workdir = "/home/coder/project"
install_claude_code = true
Expand All @@ -131,7 +130,7 @@ variable "claude_code_oauth_token" {

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

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

module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "4.2.6"
version = "4.2.7"
agent_id = coder_agent.main.id
workdir = "/home/coder/project"
model = "claude-sonnet-4@20250514"
Expand Down
20 changes: 11 additions & 9 deletions registry/coder/modules/claude-code/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ interface SetupProps {
agentapiMockScript?: string;
}

const setup = async (props?: SetupProps): Promise<{ id: string }> => {
const setup = async (
props?: SetupProps,
): Promise<{ id: string; coderEnvVars: Record<string, string> }> => {
const projectDir = "/home/coder/project";
const { id } = await setupUtil({
const { id, coderEnvVars } = await setupUtil({
moduleDir: import.meta.dir,
moduleVariables: {
install_claude_code: props?.skipClaudeMock ? "true" : "false",
Expand All @@ -61,7 +63,7 @@ const setup = async (props?: SetupProps): Promise<{ id: string }> => {
content: await loadTestFile(import.meta.dir, "claude-mock.sh"),
});
}
return { id };
return { id, coderEnvVars };
};

setDefaultTimeout(60 * 1000);
Expand All @@ -79,14 +81,14 @@ describe("claude-code", async () => {

test("install-claude-code-version", async () => {
const version_to_install = "1.0.40";
const { id } = await setup({
const { id, coderEnvVars } = await setup({
skipClaudeMock: true,
moduleVariables: {
install_claude_code: "true",
claude_code_version: version_to_install,
},
});
await execModuleScript(id);
await execModuleScript(id, coderEnvVars);
const resp = await execContainer(id, [
"bash",
"-c",
Expand All @@ -96,14 +98,14 @@ describe("claude-code", async () => {
});

test("check-latest-claude-code-version-works", async () => {
const { id } = await setup({
const { id, coderEnvVars } = await setup({
skipClaudeMock: true,
skipAgentAPIMock: true,
moduleVariables: {
install_claude_code: "true",
},
});
await execModuleScript(id);
await execModuleScript(id, coderEnvVars);
await expectAgentAPIStarted(id);
});

Expand Down Expand Up @@ -133,13 +135,13 @@ describe("claude-code", async () => {
},
},
});
const { id } = await setup({
const { id, coderEnvVars } = await setup({
skipClaudeMock: true,
moduleVariables: {
mcp: mcpConfig,
},
});
await execModuleScript(id);
await execModuleScript(id, coderEnvVars);

const resp = await readFileContainer(id, "/home/coder/.claude.json");
expect(resp).toContain("test-cmd");
Expand Down
6 changes: 6 additions & 0 deletions registry/coder/modules/claude-code/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ resource "coder_env" "disable_autoupdater" {
value = "1"
}

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

locals {
# we have to trim the slash because otherwise coder exp mcp will
# set up an invalid claude config
Expand Down
10 changes: 0 additions & 10 deletions registry/coder/modules/claude-code/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/bash

if [ -f "$HOME/.bashrc" ]; then
source "$HOME"/.bashrc
fi

# Set strict error handling AFTER sourcing bashrc to avoid unbound variable errors from user dotfiles
set -euo pipefail

BOLD='\033[0;1m'
Expand Down Expand Up @@ -45,11 +40,6 @@ function install_claude_code_cli() {
if [ $CURL_EXIT -ne 0 ]; then
echo "Claude Code installer failed with exit code $$CURL_EXIT"
fi

# Ensure binaries are discoverable.
echo "Creating a symlink for claude"
sudo ln -s /home/coder/.local/bin/claude /usr/local/bin/claude

echo "Installed Claude Code successfully. Version: $(claude --version || echo 'unknown')"
else
echo "Skipping Claude Code installation as per configuration."
Expand Down
7 changes: 0 additions & 7 deletions registry/coder/modules/claude-code/scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
#!/bin/bash

if [ -f "$HOME/.bashrc" ]; then
source "$HOME"/.bashrc
fi

# Set strict error handling AFTER sourcing bashrc to avoid unbound variable errors from user dotfiles
set -euo pipefail

export PATH="$HOME/.local/bin:$PATH"

command_exists() {
command -v "$1" > /dev/null 2>&1
}
Expand Down