From 901a1a34b9a4690aca2716928a4f521eaa2f2997 Mon Sep 17 00:00:00 2001 From: Ben Potter Date: Sun, 1 Jun 2025 20:50:36 +0000 Subject: [PATCH 1/5] chore: run post install script after coder MCP is configured --- registry/coder/modules/claude-code/main.tf | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/registry/coder/modules/claude-code/main.tf b/registry/coder/modules/claude-code/main.tf index 8e63ca606..411e34b81 100644 --- a/registry/coder/modules/claude-code/main.tf +++ b/registry/coder/modules/claude-code/main.tf @@ -131,6 +131,11 @@ resource "coder_script" "claude_code" { npm install -g @anthropic-ai/claude-code@${var.claude_code_version} fi + if [ "${var.experiment_report_tasks}" = "true" ]; then + echo "Configuring Claude Code to report tasks via Coder MCP..." + coder exp mcp configure claude-code ${var.folder} + fi + # Run post-install script if provided if [ -n "${local.encoded_post_install_script}" ]; then echo "Running post-install script..." @@ -139,11 +144,6 @@ resource "coder_script" "claude_code" { /tmp/post_install.sh fi - if [ "${var.experiment_report_tasks}" = "true" ]; then - echo "Configuring Claude Code to report tasks via Coder MCP..." - coder exp mcp configure claude-code ${var.folder} - fi - # Handle terminal multiplexer selection (tmux or screen) if [ "${var.experiment_use_tmux}" = "true" ] && [ "${var.experiment_use_screen}" = "true" ]; then echo "Error: Both experiment_use_tmux and experiment_use_screen cannot be true simultaneously." @@ -171,6 +171,7 @@ resource "coder_script" "claude_code" { # Send the prompt to the tmux session if needed if [ -n "$CODER_MCP_CLAUDE_TASK_PROMPT" ]; then + echo "Sending prompt to tmux session..." tmux send-keys -t claude-code "$CODER_MCP_CLAUDE_TASK_PROMPT" sleep 5 tmux send-keys -t claude-code Enter From 9b2465e89d6511bf7860ce571aca850247e0d088 Mon Sep 17 00:00:00 2001 From: Ben Potter Date: Sun, 1 Jun 2025 20:56:45 +0000 Subject: [PATCH 2/5] attempt to send prompt directly --- registry/coder/modules/claude-code/main.tf | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/registry/coder/modules/claude-code/main.tf b/registry/coder/modules/claude-code/main.tf index 411e34b81..1e5b7e381 100644 --- a/registry/coder/modules/claude-code/main.tf +++ b/registry/coder/modules/claude-code/main.tf @@ -167,15 +167,8 @@ resource "coder_script" "claude_code" { export LC_ALL=en_US.UTF-8 # Create a new tmux session in detached mode - tmux new-session -d -s claude-code -c ${var.folder} "claude --dangerously-skip-permissions" - - # Send the prompt to the tmux session if needed - if [ -n "$CODER_MCP_CLAUDE_TASK_PROMPT" ]; then - echo "Sending prompt to tmux session..." - tmux send-keys -t claude-code "$CODER_MCP_CLAUDE_TASK_PROMPT" - sleep 5 - tmux send-keys -t claude-code Enter - fi + tmux new-session -d -s claude-code -c ${var.folder} "claude --dangerously-skip-permissions \"${CODER_MCP_CLAUDE_TASK_PROMPT}\"" + fi # Run with screen if enabled From a41954d2b3d01a375dd6015f34f5a580d7ec92f3 Mon Sep 17 00:00:00 2001 From: Ben Potter Date: Sun, 1 Jun 2025 20:58:38 +0000 Subject: [PATCH 3/5] send full prompt not first argument --- registry/coder/modules/claude-code/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/coder/modules/claude-code/main.tf b/registry/coder/modules/claude-code/main.tf index 1e5b7e381..2c7be1f01 100644 --- a/registry/coder/modules/claude-code/main.tf +++ b/registry/coder/modules/claude-code/main.tf @@ -167,7 +167,7 @@ resource "coder_script" "claude_code" { export LC_ALL=en_US.UTF-8 # Create a new tmux session in detached mode - tmux new-session -d -s claude-code -c ${var.folder} "claude --dangerously-skip-permissions \"${CODER_MCP_CLAUDE_TASK_PROMPT}\"" + tmux new-session -d -s claude-code -c ${var.folder} "claude --dangerously-skip-permissions \"$CODER_MCP_CLAUDE_TASK_PROMPT\"" fi From 89e1b68270bc2d410a898da2e390e0e9702ed4b1 Mon Sep 17 00:00:00 2001 From: Ben Potter Date: Sun, 1 Jun 2025 21:00:35 +0000 Subject: [PATCH 4/5] same for screen --- registry/coder/modules/claude-code/main.tf | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/registry/coder/modules/claude-code/main.tf b/registry/coder/modules/claude-code/main.tf index 2c7be1f01..1435a2f3a 100644 --- a/registry/coder/modules/claude-code/main.tf +++ b/registry/coder/modules/claude-code/main.tf @@ -203,15 +203,9 @@ resource "coder_script" "claude_code" { screen -U -dmS claude-code bash -c ' cd ${var.folder} - claude --dangerously-skip-permissions | tee -a "$HOME/.claude-code.log" + claude --dangerously-skip-permissions "$CODER_MCP_CLAUDE_TASK_PROMPT" | tee -a "$HOME/.claude-code.log" exec bash ' - # Extremely hacky way to send the prompt to the screen session - # This will be fixed in the future, but `claude` was not sending MCP - # tasks when an initial prompt is provided. - screen -S claude-code -X stuff "$CODER_MCP_CLAUDE_TASK_PROMPT" - sleep 5 - screen -S claude-code -X stuff "^M" else # Check if claude is installed before running if ! command_exists claude; then From da5a72106b192fe3611400efc42179ef427b6360 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Mon, 2 Jun 2025 23:32:56 +0000 Subject: [PATCH 5/5] chore: bump claude-code module version to 1.3.1 in README.md --- registry/coder/modules/claude-code/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/registry/coder/modules/claude-code/README.md b/registry/coder/modules/claude-code/README.md index 3fe11a055..5056ce713 100644 --- a/registry/coder/modules/claude-code/README.md +++ b/registry/coder/modules/claude-code/README.md @@ -14,7 +14,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 = "1.3.0" + version = "1.3.1" agent_id = coder_agent.example.id folder = "/home/coder" install_claude_code = true @@ -88,7 +88,7 @@ resource "coder_agent" "main" { module "claude-code" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/claude-code/coder" - version = "1.1.0" + version = "1.3.1" agent_id = coder_agent.example.id folder = "/home/coder" install_claude_code = true @@ -107,7 +107,7 @@ Run Claude Code as a standalone app in your workspace. This will install Claude ```tf module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "1.3.0" + version = "1.3.1" agent_id = coder_agent.example.id folder = "/home/coder" install_claude_code = true