From aa69e8579506f174bda63f86e625c9c0f5381fac Mon Sep 17 00:00:00 2001 From: Vasanth T <148849890+Vasanthdev2004@users.noreply.github.com> Date: Fri, 3 Apr 2026 08:36:26 +0530 Subject: [PATCH] fix: correct prompt identity branding (#224) --- src/constants/promptIdentity.test.ts | 48 +++++++++++++++++++ src/constants/prompts.ts | 4 +- src/constants/system.ts | 9 ++-- src/tools/AgentTool/built-in/exploreAgent.ts | 2 +- .../AgentTool/built-in/generalPurposeAgent.ts | 2 +- 5 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 src/constants/promptIdentity.test.ts diff --git a/src/constants/promptIdentity.test.ts b/src/constants/promptIdentity.test.ts new file mode 100644 index 00000000..9c06f11c --- /dev/null +++ b/src/constants/promptIdentity.test.ts @@ -0,0 +1,48 @@ +import { afterEach, expect, test } from 'bun:test' + +import { getSystemPrompt, DEFAULT_AGENT_PROMPT } from './prompts.js' +import { CLI_SYSPROMPT_PREFIXES, getCLISyspromptPrefix } from './system.js' +import { GENERAL_PURPOSE_AGENT } from '../tools/AgentTool/built-in/generalPurposeAgent.js' +import { EXPLORE_AGENT } from '../tools/AgentTool/built-in/exploreAgent.js' + +const originalSimpleEnv = process.env.CLAUDE_CODE_SIMPLE + +afterEach(() => { + process.env.CLAUDE_CODE_SIMPLE = originalSimpleEnv +}) + +test('CLI identity prefixes describe OpenClaude instead of Claude Code', () => { + expect(getCLISyspromptPrefix()).toContain('OpenClaude') + expect(getCLISyspromptPrefix()).not.toContain("Anthropic's official CLI for Claude") + + for (const prefix of CLI_SYSPROMPT_PREFIXES) { + expect(prefix).toContain('OpenClaude') + expect(prefix).not.toContain("Anthropic's official CLI for Claude") + } +}) + +test('simple mode identity describes OpenClaude instead of Claude Code', async () => { + process.env.CLAUDE_CODE_SIMPLE = '1' + + const prompt = await getSystemPrompt([], 'gpt-4o') + + expect(prompt[0]).toContain('OpenClaude') + expect(prompt[0]).not.toContain("Anthropic's official CLI for Claude") +}) + +test('built-in agent prompts describe OpenClaude instead of Claude Code', () => { + expect(DEFAULT_AGENT_PROMPT).toContain('OpenClaude') + expect(DEFAULT_AGENT_PROMPT).not.toContain("Anthropic's official CLI for Claude") + + const generalPrompt = GENERAL_PURPOSE_AGENT.getSystemPrompt({ + toolUseContext: { options: {} as never }, + }) + expect(generalPrompt).toContain('OpenClaude') + expect(generalPrompt).not.toContain("Anthropic's official CLI for Claude") + + const explorePrompt = EXPLORE_AGENT.getSystemPrompt({ + toolUseContext: { options: {} as never }, + }) + expect(explorePrompt).toContain('OpenClaude') + expect(explorePrompt).not.toContain("Anthropic's official CLI for Claude") +}) diff --git a/src/constants/prompts.ts b/src/constants/prompts.ts index 9eb49b36..aea13021 100644 --- a/src/constants/prompts.ts +++ b/src/constants/prompts.ts @@ -449,7 +449,7 @@ export async function getSystemPrompt( ): Promise { if (isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE)) { return [ - `You are Claude Code, Anthropic's official CLI for Claude.\n\nCWD: ${getCwd()}\nDate: ${getSessionStartDate()}`, + `You are OpenClaude, an open-source fork of Claude Code.\n\nCWD: ${getCwd()}\nDate: ${getSessionStartDate()}`, ] } @@ -755,7 +755,7 @@ export function getUnameSR(): string { return `${osType()} ${osRelease()}` } -export const DEFAULT_AGENT_PROMPT = `You are an agent for Claude Code, Anthropic's official CLI for Claude. Given the user's message, you should use the tools available to complete the task. Complete the task fully—don't gold-plate, but don't leave it half-done. When you complete the task, respond with a concise report covering what was done and any key findings — the caller will relay this to the user, so it only needs the essentials.` +export const DEFAULT_AGENT_PROMPT = `You are an agent for OpenClaude, an open-source fork of Claude Code. Given the user's message, you should use the tools available to complete the task. Complete the task fully—don't gold-plate, but don't leave it half-done. When you complete the task, respond with a concise report covering what was done and any key findings — the caller will relay this to the user, so it only needs the essentials.` export async function enhanceSystemPromptWithEnvDetails( existingSystemPrompt: string[], diff --git a/src/constants/system.ts b/src/constants/system.ts index 0cd2e765..c1117bce 100644 --- a/src/constants/system.ts +++ b/src/constants/system.ts @@ -7,9 +7,12 @@ import { isEnvDefinedFalsy } from '../utils/envUtils.js' import { getAPIProvider } from '../utils/model/providers.js' import { getWorkload } from '../utils/workloadContext.js' -const DEFAULT_PREFIX = `You are Claude Code, Anthropic's official CLI for Claude.` -const AGENT_SDK_CLAUDE_CODE_PRESET_PREFIX = `You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK.` -const AGENT_SDK_PREFIX = `You are a Claude agent, built on Anthropic's Claude Agent SDK.` +const DEFAULT_PREFIX = + `You are OpenClaude, an open-source fork of Claude Code.` +const AGENT_SDK_CLAUDE_CODE_PRESET_PREFIX = + `You are OpenClaude, an open-source fork of Claude Code, running within the Claude Agent SDK.` +const AGENT_SDK_PREFIX = + `You are a Claude agent running in OpenClaude, built on the Claude Agent SDK.` const CLI_SYSPROMPT_PREFIX_VALUES = [ DEFAULT_PREFIX, diff --git a/src/tools/AgentTool/built-in/exploreAgent.ts b/src/tools/AgentTool/built-in/exploreAgent.ts index f508dc62..af84a90a 100644 --- a/src/tools/AgentTool/built-in/exploreAgent.ts +++ b/src/tools/AgentTool/built-in/exploreAgent.ts @@ -21,7 +21,7 @@ function getExploreSystemPrompt(): string { ? `- Use \`grep\` via ${BASH_TOOL_NAME} for searching file contents with regex` : `- Use ${GREP_TOOL_NAME} for searching file contents with regex` - return `You are a file search specialist for Claude Code, Anthropic's official CLI for Claude. You excel at thoroughly navigating and exploring codebases. + return `You are a file search specialist for OpenClaude, an open-source fork of Claude Code. You excel at thoroughly navigating and exploring codebases. === CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS === This is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from: diff --git a/src/tools/AgentTool/built-in/generalPurposeAgent.ts b/src/tools/AgentTool/built-in/generalPurposeAgent.ts index 7d39b284..98a63218 100644 --- a/src/tools/AgentTool/built-in/generalPurposeAgent.ts +++ b/src/tools/AgentTool/built-in/generalPurposeAgent.ts @@ -1,6 +1,6 @@ import type { BuiltInAgentDefinition } from '../loadAgentsDir.js' -const SHARED_PREFIX = `You are an agent for Claude Code, Anthropic's official CLI for Claude. Given the user's message, you should use the tools available to complete the task. Complete the task fully—don't gold-plate, but don't leave it half-done.` +const SHARED_PREFIX = `You are an agent for OpenClaude, an open-source fork of Claude Code. Given the user's message, you should use the tools available to complete the task. Complete the task fully—don't gold-plate, but don't leave it half-done.` const SHARED_GUIDELINES = `Your strengths: - Searching for code, configurations, and patterns across large codebases