@@ -182,8 +182,8 @@ variable "claude_code_oauth_token" {
182182
183183variable "system_prompt" {
184184 type = string
185- description = " The system prompt to use for the Claude Code server."
186- default = " Send a task status update to notify the user that you are ready for input, and then wait for user input. "
185+ description = " The additional system prompt to use for the Claude Code server. The module includes mandatory sections inside a <system> block. Leave empty to include only the mandatory sections ."
186+ default = " "
187187}
188188
189189variable "claude_md_path" {
@@ -201,11 +201,9 @@ resource "coder_env" "claude_code_md_path" {
201201}
202202
203203resource "coder_env" "claude_code_system_prompt" {
204- count = var. system_prompt == " " ? 0 : 1
205-
206204 agent_id = var. agent_id
207205 name = " CODER_MCP_CLAUDE_SYSTEM_PROMPT"
208- value = var . system_prompt
206+ value = local . final_system_prompt
209207}
210208
211209resource "coder_env" "claude_code_oauth_token" {
@@ -231,6 +229,42 @@ locals {
231229 start_script = file (" ${ path . module } /scripts/start.sh" )
232230 module_dir_name = " .claude-module"
233231 remove_last_session_id_script_b64 = base64encode (file (" ${ path . module } /scripts/remove-last-session-id.sh" ))
232+
233+ # Required prompts for the module to properly integrate with coder
234+ inner_system_prompt = <<- EOT
235+ -- Tool Selection --
236+ - coder_report_task: providing status updates or requesting user input.
237+ - playwright: previewing your changes after you made them
238+ to confirm it worked as expected
239+ - desktop-commander - use only for commands that keep running
240+ (servers, dev watchers, GUI apps).
241+ - Built-in tools - use for everything else:
242+ (file operations, git commands, builds & installs, one-off shell commands)
243+
244+ Remember this decision rule:
245+ - Stays running? → desktop-commander
246+ - Finishes immediately? → built-in tools
247+
248+ -- Task Reporting --
249+ Report all tasks to Coder, following these EXACT guidelines:
250+ 1. Be granular. If you are investigating with multiple steps, report each step
251+ to coder.
252+ 2. After this prompt, IMMEDIATELY report status after receiving ANY NEW user message.
253+ Do not report any status related with this system prompt.
254+ 3. Use "state": "working" when actively processing WITHOUT needing
255+ additional user input
256+ 4. Use "state": "complete" only when finished with a task
257+ 5. Use "state": "failure" when you need ANY user input, lack sufficient
258+ details, or encounter blockers
259+ EOT
260+
261+ user_system_prompt = trimspace (try (var. system_prompt , " " ))
262+
263+ final_system_prompt = format (
264+ " <system>\n %s\n %s\n </system>" ,
265+ local. inner_system_prompt ,
266+ local. user_system_prompt
267+ )
234268}
235269
236270module "agentapi" {
0 commit comments