MCPcopy
hub / github.com/claude-code-best/claude-code / getSystemPrompt

Function getSystemPrompt

src/constants/prompts.ts:410–530  ·  view source on GitHub ↗
(
  tools: Tools,
  model: string,
  additionalWorkingDirectories?: string[],
  mcpClients?: MCPServerConnection[],
)

Source from the content-addressed store, hash-verified

408}
409
410export async function getSystemPrompt(
411 tools: Tools,
412 model: string,
413 additionalWorkingDirectories?: string[],
414 mcpClients?: MCPServerConnection[],
415): Promise<string[]> {
416 if (isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE)) {
417 return [
418 `You are Claude Code, Anthropic's official CLI for Claude.\n\nCWD: ${getCwd()}\nDate: ${getSessionStartDate()}`,
419 ]
420 }
421
422 const cwd = getCwd()
423 const [skillToolCommands, outputStyleConfig, envInfo] = await Promise.all([
424 getSkillToolCommands(cwd),
425 getOutputStyleConfig(),
426 computeSimpleEnvInfo(model, additionalWorkingDirectories),
427 ])
428
429 const settings = getInitialSettings()
430 const enabledTools = new Set(tools.map(_ => _.name))
431
432 if (
433 (feature('PROACTIVE') || feature('KAIROS')) &&
434 proactiveModule?.isProactiveActive()
435 ) {
436 logForDebugging(`[SystemPrompt] path=simple-proactive`)
437 return [
438 `\nYou are an autonomous agent. Use the available tools to do useful work.
439
440${CYBER_RISK_INSTRUCTION}`,
441 getSystemRemindersSection(),
442 await loadMemoryPrompt(),
443 envInfo,
444 getLanguageSection(settings.language),
445 // When delta enabled, instructions are announced via persisted
446 // mcp_instructions_delta attachments (attachments.ts) instead.
447 isMcpInstructionsDeltaEnabled()
448 ? null
449 : getMcpInstructionsSection(mcpClients),
450 getScratchpadInstructions(),
451 SUMMARIZE_TOOL_RESULTS_SECTION,
452 getProactiveSection(),
453 ].filter(s => s !== null)
454 }
455
456 const dynamicSections = [
457 systemPromptSection('mode_persona', () => getModePersonaSection()),
458 systemPromptSection('session_guidance', () =>
459 getSessionSpecificGuidanceSection(enabledTools, skillToolCommands),
460 ),
461 systemPromptSection('memory', () => loadMemoryPrompt()),
462 systemPromptSection('ant_model_override', () =>
463 getAntModelOverrideSection(),
464 ),
465 systemPromptSection('env_info_simple', () =>
466 computeSimpleEnvInfo(model, additionalWorkingDirectories),
467 ),

Callers 10

getFullPromptFunction · 0.70
fetchSystemPromptPartsFunction · 0.50
analyzeContextUsageFunction · 0.50
runInProcessTeammateFunction · 0.50
getCacheSharingParamsFunction · 0.50
buildCacheSafeParamsFunction · 0.50
REPLFunction · 0.50
mainFunction · 0.50
dump-prompt.tsFile · 0.50

Calls 15

getCwdFunction · 0.85
getOutputStyleConfigFunction · 0.85
computeSimpleEnvInfoFunction · 0.85
loadMemoryPromptFunction · 0.85
getLanguageSectionFunction · 0.85
getProactiveSectionFunction · 0.85
systemPromptSectionFunction · 0.85
getModePersonaSectionFunction · 0.85

Tested by

no test coverage detected