Skip to content

Commit 92718d5

Browse files
committed
chore(claude-code): strip boundary, agentapi, tasks, tools
- Remove boundary variables and install logic. - Drop agentapi module; orchestrate scripts through coder-utils instead. - Remove start-script-only variables not shared with install (resume_session_id, continue, ai_prompt, dangerously_skip_permissions). - Remove allowed_tools and disallowed_tools. - Remove report_tasks, system_prompt, claude_md_path, and coder exp mcp / coder_report_task wiring. - Rename claude_api_key to anthropic_api_key (ANTHROPIC_API_KEY) and claude_code_oauth_token to anthropic_auth_token (ANTHROPIC_AUTH_TOKEN).
1 parent b108185 commit 92718d5

7 files changed

Lines changed: 489 additions & 1357 deletions

File tree

Lines changed: 92 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,118 @@
11
---
22
display_name: Claude Code
3-
description: Run the Claude Code agent in your workspace.
3+
description: Install and configure the Claude Code CLI in your workspace.
44
icon: ../../../../.icons/claude.svg
55
verified: true
6-
tags: [agent, claude-code, ai, tasks, anthropic, aibridge]
6+
tags: [agent, claude-code, ai, anthropic, ai-gateway]
77
---
88

99
# Claude Code
1010

11-
Run the [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview) agent in your workspace to generate code and perform tasks. This module integrates with [AgentAPI](https://github.com/coder/agentapi) for task reporting in the Coder UI.
11+
Install and configure the [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview) CLI in your workspace. Starting Claude is left to the caller (template command, IDE launcher, or a custom `coder_script`).
1212

1313
```tf
1414
module "claude-code" {
15-
source = "registry.coder.com/coder/claude-code/coder"
16-
version = "4.9.2"
17-
agent_id = coder_agent.main.id
18-
workdir = "/home/coder/project"
19-
claude_api_key = "xxxx-xxxxx-xxxx"
15+
source = "registry.coder.com/coder/claude-code/coder"
16+
version = "5.0.0"
17+
agent_id = coder_agent.main.id
18+
workdir = "/home/coder/project"
19+
anthropic_api_key = "xxxx-xxxxx-xxxx"
2020
}
2121
```
2222

23-
> [!WARNING]
24-
> **Security Notice**: This module uses the `--dangerously-skip-permissions` flag when running Claude Code tasks. This flag bypasses standard permission checks and allows Claude Code broader access to your system than normally permitted. While this enables more functionality, it also means Claude Code can potentially execute commands with the same privileges as the user running it. Use this module _only_ in trusted environments and be aware of the security implications.
25-
26-
> [!NOTE]
27-
> By default, this module is configured to run the embedded chat interface as a path-based application. In production, we recommend that you configure a [wildcard access URL](https://coder.com/docs/admin/setup#wildcard-access-url) and set `subdomain = true`. See [here](https://coder.com/docs/tutorials/best-practices/security-best-practices#disable-path-based-apps) for more details.
28-
2923
## Prerequisites
3024

31-
- An **Anthropic API key** or a _Claude Session Token_ is required for tasks.
32-
- You can get the API key from the [Anthropic Console](https://console.anthropic.com/dashboard).
33-
- You can get the Session Token using the `claude setup-token` command. This is a long-lived authentication token (requires Claude subscription)
34-
35-
### Session Resumption Behavior
25+
Provide exactly one authentication method:
3626

37-
By default, Claude Code automatically resumes existing conversations when your workspace restarts. Sessions are tracked per workspace directory, so conversations continue where you left off. If no session exists (first start), your `ai_prompt` will run normally. To disable this behavior and always start fresh, set `continue = false`
27+
- **Anthropic API key**: get one from the [Anthropic Console](https://console.anthropic.com/dashboard) and pass it as `anthropic_api_key`.
28+
- **Claude.ai OAuth token** (Pro, Max, or Enterprise accounts): generate one by running `claude setup-token` locally and pass it as `claude_code_oauth_token`.
29+
- **Coder AI Gateway** (Coder Premium, Coder >= 2.30.0): set `enable_ai_gateway = true`. The module authenticates against the gateway using the workspace owner's session token. Do not combine with `anthropic_api_key` or `claude_code_oauth_token`.
3830

39-
## State Persistence
31+
## Examples
4032

41-
AgentAPI can save and restore its conversation state to disk across workspace restarts. This complements `continue` (which resumes the Claude CLI session) by also preserving the AgentAPI-level context. Enabled by default, requires agentapi >= v0.12.0 (older versions skip it with a warning).
33+
### Standalone mode with a launcher app
4234

43-
To disable:
35+
Authenticate Claude directly against Anthropic's API and add a `coder_app` that users can click from the workspace dashboard to open an interactive Claude session.
4436

4537
```tf
46-
module "claude-code" {
47-
# ... other config
48-
enable_state_persistence = false
38+
locals {
39+
claude_workdir = "/home/coder/project"
4940
}
50-
```
51-
52-
## Examples
53-
54-
### Usage with Agent Boundaries
55-
56-
This example shows how to configure the Claude Code module to run the agent behind a process-level boundary that restricts its network access.
5741
58-
By default, when `enable_boundary = true`, the module uses `coder boundary` subcommand (provided by Coder) without requiring any installation.
59-
60-
```tf
6142
module "claude-code" {
62-
source = "registry.coder.com/coder/claude-code/coder"
63-
version = "4.9.2"
64-
agent_id = coder_agent.main.id
65-
workdir = "/home/coder/project"
66-
enable_boundary = true
43+
source = "registry.coder.com/coder/claude-code/coder"
44+
version = "5.0.0"
45+
agent_id = coder_agent.main.id
46+
workdir = local.claude_workdir
47+
anthropic_api_key = "xxxx-xxxxx-xxxx"
48+
}
49+
50+
resource "coder_app" "claude" {
51+
agent_id = coder_agent.main.id
52+
slug = "claude"
53+
display_name = "Claude Code"
54+
icon = "/icon/claude.svg"
55+
open_in = "slim-window"
56+
command = <<-EOT
57+
#!/bin/bash
58+
set -e
59+
cd ${local.claude_workdir}
60+
claude
61+
EOT
6762
}
6863
```
6964

7065
> [!NOTE]
71-
> For developers: The module also supports installing boundary from a release version (`use_boundary_directly = true`) or compiling from source (`compile_boundary_from_source = true`). These are escape hatches for development and testing purposes.
66+
> `coder_app.command` runs when the user clicks the app tile. Combine with `anthropic_api_key`, `claude_code_oauth_token`, or `enable_ai_gateway = true` on the module to pre-authenticate the CLI.
7267
73-
### Usage with AI Bridge
68+
### Usage with AI Gateway
7469

75-
[AI Bridge](https://coder.com/docs/ai-coder/ai-bridge) is a Premium Coder feature that provides centralized LLM proxy management. To use AI Bridge, set `enable_aibridge = true`. Requires Coder version >= 2.29.0.
76-
77-
For tasks integration with AI Bridge, add `enable_aibridge = true` to the [Usage with Tasks](#usage-with-tasks) example below.
78-
79-
#### Standalone usage with AI Bridge
70+
[AI Gateway](https://coder.com/docs/ai-coder/ai-gateway) is a Premium Coder feature that provides centralized LLM proxy management. Requires Coder >= 2.30.0.
8071

8172
```tf
8273
module "claude-code" {
83-
source = "registry.coder.com/coder/claude-code/coder"
84-
version = "4.9.2"
85-
agent_id = coder_agent.main.id
86-
workdir = "/home/coder/project"
87-
enable_aibridge = true
74+
source = "registry.coder.com/coder/claude-code/coder"
75+
version = "5.0.0"
76+
agent_id = coder_agent.main.id
77+
workdir = "/home/coder/project"
78+
enable_ai_gateway = true
8879
}
8980
```
9081

91-
When `enable_aibridge = true`, the module automatically sets:
82+
When `enable_ai_gateway = true`, the module sets:
9283

9384
- `ANTHROPIC_BASE_URL` to `${data.coder_workspace.me.access_url}/api/v2/aibridge/anthropic`
94-
- `CLAUDE_API_KEY` to the workspace owner's session token
95-
96-
This allows Claude Code to route API requests through Coder's AI Bridge instead of directly to Anthropic's API.
97-
Template build will fail if either `claude_api_key` or `claude_code_oauth_token` is provided alongside `enable_aibridge = true`.
98-
99-
### Usage with Tasks
100-
101-
This example shows how to configure Claude Code with Coder tasks.
102-
103-
```tf
104-
resource "coder_ai_task" "task" {
105-
count = data.coder_workspace.me.start_count
106-
app_id = module.claude-code.task_app_id
107-
}
85+
- `ANTHROPIC_AUTH_TOKEN` to the workspace owner's Coder session token
10886

109-
data "coder_task" "me" {}
87+
Claude Code then routes API requests through Coder's AI Gateway instead of directly to Anthropic.
11088

111-
module "claude-code" {
112-
source = "registry.coder.com/coder/claude-code/coder"
113-
version = "4.9.2"
114-
agent_id = coder_agent.main.id
115-
workdir = "/home/coder/project"
116-
ai_prompt = data.coder_task.me.prompt
117-
118-
# Optional: route through AI Bridge (Premium feature)
119-
# enable_aibridge = true
120-
}
121-
```
89+
> [!CAUTION]
90+
> `enable_ai_gateway = true` is mutually exclusive with `anthropic_api_key` and `claude_code_oauth_token`. Setting any of them together fails at plan time.
12291
12392
### Advanced Configuration
12493

125-
This example shows additional configuration options for version pinning, custom models, and MCP servers.
126-
127-
> [!NOTE]
128-
> The `claude_binary_path` variable can be used to specify where a pre-installed Claude binary is located.
94+
This example shows version pinning, a pre-installed binary path, a custom model, and MCP servers.
12995

13096
> [!WARNING]
131-
> **Deprecation Notice**: The npm installation method (`install_via_npm = true`) will be deprecated and removed in the next major release. Please use the default binary installation method instead.
97+
> **Deprecation notice**: `install_via_npm = true` will be removed in the next major release. Prefer the default binary installer.
13298
13399
```tf
134100
module "claude-code" {
135101
source = "registry.coder.com/coder/claude-code/coder"
136-
version = "4.9.2"
102+
version = "5.0.0"
137103
agent_id = coder_agent.main.id
138104
workdir = "/home/coder/project"
139105
140-
claude_api_key = "xxxx-xxxxx-xxxx"
141-
# OR
142-
claude_code_oauth_token = "xxxxx-xxxx-xxxx"
106+
anthropic_api_key = "xxxx-xxxxx-xxxx"
107+
108+
claude_code_version = "2.0.62" # Pin to a specific Claude CLI version.
143109
144-
claude_code_version = "2.0.62" # Pin to a specific version
145-
claude_binary_path = "/opt/claude/bin" # Path to pre-installed Claude binary
146-
agentapi_version = "0.11.4"
110+
# Skip the module's installer and point at a pre-installed Claude binary.
111+
# claude_binary_path can only be customized when install_claude_code is false.
112+
install_claude_code = false
113+
claude_binary_path = "/opt/claude/bin"
147114
148-
model = "sonnet"
149-
permission_mode = "plan"
115+
model = "sonnet"
150116
151117
mcp = <<-EOF
152118
{
@@ -166,6 +132,9 @@ module "claude-code" {
166132
}
167133
```
168134

135+
> [!NOTE]
136+
> Swap `anthropic_api_key` for `claude_code_oauth_token = "xxxxx-xxxx-xxxx"` to authenticate via a Claude.ai OAuth token instead. Pass exactly one.
137+
169138
> [!NOTE]
170139
> Remote URLs should return a JSON body in the following format:
171140
>
@@ -180,41 +149,37 @@ module "claude-code" {
180149
> }
181150
> ```
182151
>
183-
> The `Content-Type` header doesn't matter—both `text/plain` and `application/json` work fine.
152+
> The `Content-Type` header doesn't matter, both `text/plain` and `application/json` work fine.
153+
154+
### Serialize a downstream `coder_script` after the install pipeline
184155
185-
### Standalone Mode
156+
The module exposes the `coder exp sync` name of each script it creates via the `scripts` output: an ordered list (`pre_install`, `install`, `post_install`) of names for scripts this module actually creates. Scripts that were not configured are absent from the list.
186157
187-
Run and configure Claude Code as a standalone CLI in your workspace.
158+
Downstream `coder_script` resources can wait for this module's install pipeline to finish using `coder exp sync want <self> <each name>`:
188159
189160
```tf
190161
module "claude-code" {
191-
source = "registry.coder.com/coder/claude-code/coder"
192-
version = "4.9.2"
193-
agent_id = coder_agent.main.id
194-
workdir = "/home/coder/project"
195-
install_claude_code = true
196-
claude_code_version = "2.0.62"
197-
report_tasks = false
162+
source = "registry.coder.com/coder/claude-code/coder"
163+
version = "5.0.0"
164+
agent_id = coder_agent.main.id
165+
workdir = "/home/coder/project"
166+
anthropic_api_key = "xxxx-xxxxx-xxxx"
198167
}
199-
```
200168
201-
### Usage with Claude Code Subscription
202-
203-
```tf
204-
205-
variable "claude_code_oauth_token" {
206-
type = string
207-
description = "Generate one using `claude setup-token` command"
208-
sensitive = true
209-
value = "xxxx-xxx-xxxx"
210-
}
169+
resource "coder_script" "post_claude" {
170+
agent_id = coder_agent.main.id
171+
display_name = "Run after Claude Code install"
172+
run_on_start = true
173+
script = <<-EOT
174+
#!/bin/bash
175+
set -euo pipefail
176+
trap 'coder exp sync complete post-claude' EXIT
177+
coder exp sync want post-claude ${join(" ", module.claude-code.scripts)}
178+
coder exp sync start post-claude
211179
212-
module "claude-code" {
213-
source = "registry.coder.com/coder/claude-code/coder"
214-
version = "4.9.2"
215-
agent_id = coder_agent.main.id
216-
workdir = "/home/coder/project"
217-
claude_code_oauth_token = var.claude_code_oauth_token
180+
# Your work here runs after claude-code finishes installing.
181+
claude --version
182+
EOT
218183
}
219184
```
220185
@@ -245,14 +210,12 @@ variable "aws_access_key_id" {
245210
type = string
246211
description = "Your AWS access key ID. Create this in the AWS IAM console under 'Security credentials'."
247212
sensitive = true
248-
value = "xxxx-xxx-xxxx"
249213
}
250214
251215
variable "aws_secret_access_key" {
252216
type = string
253217
description = "Your AWS secret access key. This is shown once when you create an access key in the AWS IAM console."
254218
sensitive = true
255-
value = "xxxx-xxx-xxxx"
256219
}
257220
258221
resource "coder_env" "aws_access_key_id" {
@@ -273,7 +236,6 @@ variable "aws_bearer_token_bedrock" {
273236
type = string
274237
description = "Your AWS Bedrock bearer token. This provides access to Bedrock without needing separate access key and secret key."
275238
sensitive = true
276-
value = "xxxx-xxx-xxxx"
277239
}
278240
279241
resource "coder_env" "bedrock_api_key" {
@@ -284,7 +246,7 @@ resource "coder_env" "bedrock_api_key" {
284246
285247
module "claude-code" {
286248
source = "registry.coder.com/coder/claude-code/coder"
287-
version = "4.9.2"
249+
version = "5.0.0"
288250
agent_id = coder_agent.main.id
289251
workdir = "/home/coder/project"
290252
model = "global.anthropic.claude-sonnet-4-5-20250929-v1:0"
@@ -341,7 +303,7 @@ resource "coder_env" "google_application_credentials" {
341303
342304
module "claude-code" {
343305
source = "registry.coder.com/coder/claude-code/coder"
344-
version = "4.9.2"
306+
version = "5.0.0"
345307
agent_id = coder_agent.main.id
346308
workdir = "/home/coder/project"
347309
model = "claude-sonnet-4@20250514"
@@ -375,26 +337,17 @@ module "claude-code" {
375337
376338
## Troubleshooting
377339

378-
If you encounter any issues, check the log files in the `~/.claude-module` directory within your workspace for detailed information.
340+
If you encounter any issues, check the log files in the `~/.coder-modules/coder/claude-code` directory within your workspace for detailed information.
379341

380342
```bash
381343
# Installation logs
382-
cat ~/.claude-module/install.log
383-
384-
# Startup logs
385-
cat ~/.claude-module/agentapi-start.log
344+
cat ~/.coder-modules/coder/claude-code/install.log
386345

387346
# Pre/post install script logs
388-
cat ~/.claude-module/pre_install.log
389-
cat ~/.claude-module/post_install.log
347+
cat ~/.coder-modules/coder/claude-code/pre_install.log
348+
cat ~/.coder-modules/coder/claude-code/post_install.log
390349
```
391350

392-
> [!NOTE]
393-
> To use tasks with Claude Code, you must provide an `anthropic_api_key` or `claude_code_oauth_token`.
394-
> The `workdir` variable is required and specifies the directory where Claude Code will run.
395-
396351
## References
397352

398353
- [Claude Code Documentation](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview)
399-
- [AgentAPI Documentation](https://github.com/coder/agentapi)
400-
- [Coder AI Agents Guide](https://coder.com/docs/tutorials/ai-agents)

0 commit comments

Comments
 (0)