@@ -114,6 +114,7 @@ func (*RootCmd) mcpConfigureClaudeCode() *serpent.Command {
114
114
claudeConfigPath string
115
115
claudeMDPath string
116
116
systemPrompt string
117
+ coderPrompt string
117
118
appStatusSlug string
118
119
testBinaryName string
119
120
@@ -185,8 +186,18 @@ func (*RootCmd) mcpConfigureClaudeCode() *serpent.Command {
185
186
reportTaskPrompt = defaultReportTaskPrompt
186
187
}
187
188
189
+ // If a user overrides the coder prompt, we don't want to append
190
+ // the report task prompt, as it then becomes the responsibility
191
+ // of the user.
192
+ actualCoderPrompt := defaultCoderPrompt
193
+ if coderPrompt != "" {
194
+ actualCoderPrompt = coderPrompt
195
+ } else if reportTaskPrompt != "" {
196
+ actualCoderPrompt += "\n \n " + reportTaskPrompt
197
+ }
198
+
188
199
// We also write the system prompt to the CLAUDE.md file.
189
- if err := injectClaudeMD (fs , systemPrompt , reportTaskPrompt , claudeMDPath ); err != nil {
200
+ if err := injectClaudeMD (fs , actualCoderPrompt , systemPrompt , claudeMDPath ); err != nil {
190
201
return xerrors .Errorf ("failed to modify CLAUDE.md: %w" , err )
191
202
}
192
203
cliui .Infof (inv .Stderr , "Wrote CLAUDE.md to %s" , claudeMDPath )
@@ -231,6 +242,14 @@ func (*RootCmd) mcpConfigureClaudeCode() *serpent.Command {
231
242
Value : serpent .StringOf (& systemPrompt ),
232
243
Default : "Send a task status update to notify the user that you are ready for input, and then wait for user input." ,
233
244
},
245
+ {
246
+ Name : "coder-prompt" ,
247
+ Description : "The coder prompt to use for the Claude Code server." ,
248
+ Env : "CODER_MCP_CLAUDE_CODER_PROMPT" ,
249
+ Flag : "claude-coder-prompt" ,
250
+ Value : serpent .StringOf (& coderPrompt ),
251
+ Default : "" , // Empty default means we'll use defaultCoderPrompt from the variable
252
+ },
234
253
{
235
254
Name : "app-status-slug" ,
236
255
Description : "The app status slug to use when running the Coder MCP server." ,
@@ -603,7 +622,7 @@ Task summaries MUST:
603
622
systemPromptEndGuard = "</system-prompt>"
604
623
)
605
624
606
- func injectClaudeMD (fs afero.Fs , systemPrompt , reportTaskPrompt , claudeMDPath string ) error {
625
+ func injectClaudeMD (fs afero.Fs , coderPrompt , systemPrompt , claudeMDPath string ) error {
607
626
_ , err := fs .Stat (claudeMDPath )
608
627
if err != nil {
609
628
if ! os .IsNotExist (err ) {
@@ -614,7 +633,7 @@ func injectClaudeMD(fs afero.Fs, systemPrompt, reportTaskPrompt, claudeMDPath st
614
633
return xerrors .Errorf ("failed to create claude config directory: %w" , err )
615
634
}
616
635
617
- return afero .WriteFile (fs , claudeMDPath , []byte (promptsBlock (defaultCoderPrompt , reportTaskPrompt , systemPrompt , "" )), 0o600 )
636
+ return afero .WriteFile (fs , claudeMDPath , []byte (promptsBlock (coderPrompt , systemPrompt , "" )), 0o600 )
618
637
}
619
638
620
639
bs , err := afero .ReadFile (fs , claudeMDPath )
@@ -647,7 +666,7 @@ func injectClaudeMD(fs afero.Fs, systemPrompt, reportTaskPrompt, claudeMDPath st
647
666
cleanContent = strings .TrimSpace (cleanContent )
648
667
649
668
// Create the new content with coder and system prompt prepended
650
- newContent := promptsBlock (defaultCoderPrompt , reportTaskPrompt , systemPrompt , cleanContent )
669
+ newContent := promptsBlock (coderPrompt , systemPrompt , cleanContent )
651
670
652
671
// Write the updated content back to the file
653
672
err = afero .WriteFile (fs , claudeMDPath , []byte (newContent ), 0o600 )
@@ -658,19 +677,11 @@ func injectClaudeMD(fs afero.Fs, systemPrompt, reportTaskPrompt, claudeMDPath st
658
677
return nil
659
678
}
660
679
661
- func promptsBlock (coderPrompt , reportTaskPrompt , systemPrompt , existingContent string ) string {
680
+ func promptsBlock (coderPrompt , systemPrompt , existingContent string ) string {
662
681
var newContent strings.Builder
663
682
_ , _ = newContent .WriteString (coderPromptStartGuard )
664
683
_ , _ = newContent .WriteRune ('\n' )
665
684
_ , _ = newContent .WriteString (coderPrompt )
666
-
667
- // Only include the report task prompt if it's provided
668
- if reportTaskPrompt != "" {
669
- _ , _ = newContent .WriteRune ('\n' )
670
- _ , _ = newContent .WriteRune ('\n' )
671
- _ , _ = newContent .WriteString (reportTaskPrompt )
672
- }
673
-
674
685
_ , _ = newContent .WriteRune ('\n' )
675
686
_ , _ = newContent .WriteString (coderPromptEndGuard )
676
687
_ , _ = newContent .WriteRune ('\n' )
0 commit comments