Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitea71808

Browse files
authored
docs: update Tasks Template Code (#19770)
1 parent8db82d2 commitea71808

File tree

1 file changed

+39
-10
lines changed

1 file changed

+39
-10
lines changed

‎docs/ai-coder/tasks.md‎

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,53 @@ To import the template and begin configuring it, follow the [documentation in th
4646
4747
###Option 2) Create or Duplicate Your Own Template
4848

49-
A template becomes a Task template if it defines a`coder_ai_task` resource and a`coder_parameter` named`"AI Prompt"`. Coder analyzes template files during template version import to determine if these requirements are met.
49+
A template becomes a Task template if it defines a`coder_ai_task` resource and a`coder_parameter` named`"AI Prompt"`. Coder analyzes template files during template version import to determine if these requirements are met. Try adding this terraform block to an existing template where you'll add our Claude Code module. Note: the`coder_ai_task` resource is defined within the[Claude Code Module](https://registry.coder.com/modules/coder/claude-code?tab=readme), so it's not defined within this block.
5050

5151
```hcl
5252
data "coder_parameter" "ai_prompt" {
5353
name = "AI Prompt"
5454
type = "string"
5555
}
5656
57-
# Multiple coder_ai_tasks can be defined in a template
58-
resource "coder_ai_task" "claude-code" {
59-
# At most one coder ai task can be instantiated during a workspace build.
60-
# Coder fails the build if it would instantiate more than 1.
61-
count = data.coder_parameter.ai_prompt.value != "" ? 1 : 0
57+
data "coder_parameter" "setup_script" {
58+
name = "setup_script"
59+
display_name = "Setup Script"
60+
type = "string"
61+
form_type = "textarea"
62+
description = "Script to run before running the agent"
63+
mutable = false
64+
default = ""
65+
}
66+
67+
# The Claude Code module does the automatic task reporting
68+
# Other agent modules: https://registry.coder.com/modules?search=agent
69+
# Or use a custom agent:
70+
module "claude-code" {
71+
count = data.coder_workspace.me.start_count
72+
source = "registry.coder.com/coder/claude-code/coder"
73+
version = "2.2.0"
74+
agent_id = coder_agent.main.id
75+
folder = "/home/coder/projects"
76+
install_claude_code = true
77+
claude_code_version = "latest"
78+
order = 999
79+
80+
# experiment_post_install_script = data.coder_parameter.setup_script.value
81+
82+
# This enables Coder Tasks
83+
experiment_report_tasks = true
84+
}
85+
86+
variable "anthropic_api_key" {
87+
type = string
88+
description = "Generate one at: https://console.anthropic.com/settings/keys"
89+
sensitive = true
90+
}
6291
63-
sidebar_app {
64-
# which app to display in the sidebar on the task page
65-
id = coder_app.claude-code.id
66-
}
92+
resource "coder_env" "anthropic_api_key" {
93+
agent_id = coder_agent.main.id
94+
name= "CODER_MCP_CLAUDE_API_KEY"
95+
value = var.anthropic_api_key
6796
}
6897
```
6998

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp