source dump of claude code
at main 28 lines 1.9 kB view raw
1import { isCompactLinePrefixEnabled } from '../../utils/file.js' 2import { FILE_READ_TOOL_NAME } from '../FileReadTool/prompt.js' 3 4function getPreReadInstruction(): string { 5 return `\n- You must use your \`${FILE_READ_TOOL_NAME}\` tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file. ` 6} 7 8export function getEditToolDescription(): string { 9 return getDefaultEditDescription() 10} 11 12function getDefaultEditDescription(): string { 13 const prefixFormat = isCompactLinePrefixEnabled() 14 ? 'line number + tab' 15 : 'spaces + line number + arrow' 16 const minimalUniquenessHint = 17 process.env.USER_TYPE === 'ant' 18 ? `\n- Use the smallest old_string that's clearly unique — usually 2-4 adjacent lines is sufficient. Avoid including 10+ lines of context when less uniquely identifies the target.` 19 : '' 20 return `Performs exact string replacements in files. 21 22Usage:${getPreReadInstruction()} 23- When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: ${prefixFormat}. Everything after that is the actual file content to match. Never include any part of the line number prefix in the old_string or new_string. 24- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required. 25- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked. 26- The edit will FAIL if \`old_string\` is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use \`replace_all\` to change every instance of \`old_string\`.${minimalUniquenessHint} 27- Use \`replace_all\` for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.` 28}