Skip to content

Commit 7dc7563

Browse files
authored
fix(examples/templates/tasks-docker): support coder/claude-code 4.0.0 (#20420)
Relates to coder/internal#1065 Essentially the same steps as coder/registry#497
1 parent b0f3eff commit 7dc7563

File tree

1 file changed

+22
-18
lines changed
  • examples/templates/tasks-docker

1 file changed

+22
-18
lines changed

examples/templates/tasks-docker/main.tf

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
terraform {
22
required_providers {
33
coder = {
4-
source = "coder/coder"
4+
source = "coder/coder"
5+
version = ">= 2.13"
56
}
67
docker = {
78
source = "kreuzwerker/docker"
@@ -12,22 +13,32 @@ terraform {
1213
# This template requires a valid Docker socket
1314
# However, you can reference our Kubernetes/VM
1415
# example templates and adapt the Claude Code module
15-
#
16-
# see: https://registry.coder.com/templates
16+
#
17+
# See: https://registry.coder.com/templates
1718
provider "docker" {}
1819

20+
# A `coder_ai_task` resource enables Tasks and associates
21+
# the task with the coder_app that will act as an AI agent.
22+
resource "coder_ai_task" "task" {
23+
count = data.coder_workspace.me.start_count
24+
app_id = module.claude-code[count.index].task_app_id
25+
}
26+
27+
# You can read the task prompt from the `coder_task` data source.
28+
data "coder_task" "me" {}
29+
1930
# The Claude Code module does the automatic task reporting
2031
# Other agent modules: https://registry.coder.com/modules?search=agent
21-
# Or use a custom agent:
32+
# Or use a custom agent:
2233
module "claude-code" {
2334
count = data.coder_workspace.me.start_count
2435
source = "registry.coder.com/coder/claude-code/coder"
25-
version = "3.4.4"
36+
version = "4.0.0"
2637
agent_id = coder_agent.main.id
2738
workdir = "/home/coder/projects"
2839
order = 999
2940
claude_api_key = ""
30-
ai_prompt = data.coder_parameter.ai_prompt.value
41+
ai_prompt = data.coder_task.me.prompt
3142
system_prompt = data.coder_parameter.system_prompt.value
3243
model = "sonnet"
3344
permission_mode = "plan"
@@ -51,13 +62,13 @@ data "coder_workspace_preset" "default" {
5162
(servers, dev watchers, GUI apps).
5263
- Built-in tools - use for everything else:
5364
(file operations, git commands, builds & installs, one-off shell commands)
54-
65+
5566
Remember this decision rule:
5667
- Stays running? → desktop-commander
5768
- Finishes immediately? → built-in tools
58-
69+
5970
-- Context --
60-
There is an existing app and tmux dev server running on port 8000. Be sure to read it's CLAUDE.md (./realworld-django-rest-framework-angular/CLAUDE.md) to learn more about it.
71+
There is an existing app and tmux dev server running on port 8000. Be sure to read it's CLAUDE.md (./realworld-django-rest-framework-angular/CLAUDE.md) to learn more about it.
6172
6273
Since this app is for demo purposes and the user is previewing the homepage and subsequent pages, aim to make the first visual change/prototype very quickly so the user can preview it, then focus on backend or logic which can be a more involved, long-running architecture plan.
6374
@@ -107,7 +118,7 @@ data "coder_workspace_preset" "default" {
107118

108119
# Pre-builds is a Coder Premium
109120
# feature to speed up workspace creation
110-
#
121+
#
111122
# see https://coder.com/docs/admin/templates/extending-templates/prebuilt-workspaces
112123
# prebuilds {
113124
# instances = 1
@@ -126,13 +137,6 @@ data "coder_parameter" "system_prompt" {
126137
description = "System prompt for the agent with generalized instructions"
127138
mutable = false
128139
}
129-
data "coder_parameter" "ai_prompt" {
130-
type = "string"
131-
name = "AI Prompt"
132-
default = ""
133-
description = "Write a prompt for Claude Code"
134-
mutable = true
135-
}
136140
data "coder_parameter" "setup_script" {
137141
name = "setup_script"
138142
display_name = "Setup Script"
@@ -373,4 +377,4 @@ resource "docker_container" "workspace" {
373377
label = "coder.workspace_name"
374378
value = data.coder_workspace.me.name
375379
}
376-
}
380+
}

0 commit comments

Comments
 (0)