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

Function getSystemPrompt

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

Source from the content-addressed store, hash-verified

442}
443
444export async function getSystemPrompt(
445 tools: Tools,
446 model: string,
447 additionalWorkingDirectories?: string[],
448 mcpClients?: MCPServerConnection[],
449): Promise<string[]> {
450 if (isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE)) {
451 return [
452 `You are Claude Code, Anthropic's official CLI for Claude.\n\nCWD: ${getCwd()}\nDate: ${getSessionStartDate()}`,
453 ]
454 }
455
456 const cwd = getCwd()
457 const [skillToolCommands, outputStyleConfig, envInfo] = await Promise.all([
458 getSkillToolCommands(cwd),
459 getOutputStyleConfig(),
460 computeSimpleEnvInfo(model, additionalWorkingDirectories),
461 ])
462
463 const settings = getInitialSettings()
464 const enabledTools = new Set(tools.map(_ => _.name))
465
466 if (
467 (feature('PROACTIVE') || feature('KAIROS')) &&
468 proactiveModule?.isProactiveActive()
469 ) {
470 logForDebugging(`[SystemPrompt] path=simple-proactive`)
471 return [
472 `\nYou are an autonomous agent. Use the available tools to do useful work.
473
474${CYBER_RISK_INSTRUCTION}`,
475 getSystemRemindersSection(),
476 await loadMemoryPrompt(),
477 envInfo,
478 getLanguageSection(settings.language),
479 // When delta enabled, instructions are announced via persisted
480 // mcp_instructions_delta attachments (attachments.ts) instead.
481 isMcpInstructionsDeltaEnabled()
482 ? null
483 : getMcpInstructionsSection(mcpClients),
484 getScratchpadInstructions(),
485 getFunctionResultClearingSection(model),
486 SUMMARIZE_TOOL_RESULTS_SECTION,
487 getProactiveSection(),
488 ].filter(s => s !== null)
489 }
490
491 const dynamicSections = [
492 systemPromptSection('session_guidance', () =>
493 getSessionSpecificGuidanceSection(enabledTools, skillToolCommands),
494 ),
495 systemPromptSection('memory', () => loadMemoryPrompt()),
496 systemPromptSection('ant_model_override', () =>
497 getAntModelOverrideSection(),
498 ),
499 systemPromptSection('env_info_simple', () =>
500 computeSimpleEnvInfo(model, additionalWorkingDirectories),
501 ),

Callers 8

fetchSystemPromptPartsFunction · 0.50
analyzeContextUsageFunction · 0.50
runInProcessTeammateFunction · 0.50
getCacheSharingParamsFunction · 0.50
buildCacheSafeParamsFunction · 0.50
REPLFunction · 0.50
mainFunction · 0.50

Calls 15

isEnvTruthyFunction · 0.85
getCwdFunction · 0.85
getOutputStyleConfigFunction · 0.85
computeSimpleEnvInfoFunction · 0.85
getInitialSettingsFunction · 0.85
featureFunction · 0.85
logForDebuggingFunction · 0.85
loadMemoryPromptFunction · 0.85
getLanguageSectionFunction · 0.85

Tested by

no test coverage detected