MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getPrompt

Function getPrompt

src/tools/PowerShellTool/prompt.ts:73–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71}
72
73export async function getPrompt(): Promise<string> {
74 const backgroundNote = getBackgroundUsageNote()
75 const sleepGuidance = getSleepGuidance()
76 const edition = await getPowerShellEdition()
77
78 return `Executes a given PowerShell command with optional timeout. Working directory persists between commands; shell state (variables, functions) does not.
79
80IMPORTANT: This tool is for terminal operations via PowerShell: git, npm, docker, and PS cmdlets. DO NOT use it for file operations (reading, writing, editing, searching, finding files) - use the specialized tools for this instead.
81
82${getEditionSection(edition)}
83
84Before executing the command, please follow these steps:
85
861. Directory Verification:
87 - If the command will create new directories or files, first use \`Get-ChildItem\` (or \`ls\`) to verify the parent directory exists and is the correct location
88
892. Command Execution:
90 - Always quote file paths that contain spaces with double quotes
91 - Capture the output of the command.
92
93PowerShell Syntax Notes:
94 - Variables use $ prefix: $myVar = "value"
95 - Escape character is backtick (\`), not backslash
96 - Use Verb-Noun cmdlet naming: Get-ChildItem, Set-Location, New-Item, Remove-Item
97 - Common aliases: ls (Get-ChildItem), cd (Set-Location), cat (Get-Content), rm (Remove-Item)
98 - Pipe operator | works similarly to bash but passes objects, not text
99 - Use Select-Object, Where-Object, ForEach-Object for filtering and transformation
100 - String interpolation: "Hello $name" or "Hello $($obj.Property)"
101 - Registry access uses PSDrive prefixes: \`HKLM:\\SOFTWARE\\...\`, \`HKCU:\\...\` — NOT raw \`HKEY_LOCAL_MACHINE\\...\`
102 - Environment variables: read with \`$env:NAME\`, set with \`$env:NAME = "value"\` (NOT \`Set-Variable\` or bash \`export\`)
103 - Call native exe with spaces in path via call operator: \`& "C:\\Program Files\\App\\app.exe" arg1 arg2\`
104
105Interactive and blocking commands (will hang — this tool runs with -NonInteractive):
106 - NEVER use \`Read-Host\`, \`Get-Credential\`, \`Out-GridView\`, \`$Host.UI.PromptForChoice\`, or \`pause\`
107 - Destructive cmdlets (\`Remove-Item\`, \`Stop-Process\`, \`Clear-Content\`, etc.) may prompt for confirmation. Add \`-Confirm:$false\` when you intend the action to proceed. Use \`-Force\` for read-only/hidden items.
108 - Never use \`git rebase -i\`, \`git add -i\`, or other commands that open an interactive editor
109
110Passing multiline strings (commit messages, file content) to native executables:
111 - Use a single-quoted here-string so PowerShell does not expand \`$\` or backticks inside. The closing \`'@\` MUST be at column 0 (no leading whitespace) on its own line — indenting it is a parse error:
112<example>
113git commit -m @'
114Commit message here.
115Second line with $literal dollar signs.
116'@
117</example>
118 - Use \`@'...'@\` (single-quoted, literal) not \`@"..."@\` (double-quoted, interpolated) unless you need variable expansion
119 - For arguments containing \`-\`, \`@\`, or other characters PowerShell parses as operators, use the stop-parsing token: \`git log --% --format=%H\`
120
121Usage notes:
122 - The command argument is required.
123 - You can specify an optional timeout in milliseconds (up to ${getMaxTimeoutMs()}ms / ${getMaxTimeoutMs() / 60000} minutes). If not specified, commands will timeout after ${getDefaultTimeoutMs()}ms (${getDefaultTimeoutMs() / 60000} minutes).
124 - It is very helpful if you write a clear, concise description of what this command does.
125 - If the output exceeds ${getMaxOutputLength()} characters, output will be truncated before being returned to you.
126${backgroundNote ? backgroundNote + '\n' : ''}\
127 - Avoid using PowerShell to run commands that have dedicated tools, unless explicitly instructed:
128 - File search: Use ${GLOB_TOOL_NAME} (NOT Get-ChildItem -Recurse)
129 - Content search: Use ${GREP_TOOL_NAME} (NOT Select-String)
130 - Read files: Use ${FILE_READ_TOOL_NAME} (NOT Get-Content)

Callers 1

promptFunction · 0.70

Calls 7

getSleepGuidanceFunction · 0.85
getPowerShellEditionFunction · 0.85
getEditionSectionFunction · 0.85
getMaxOutputLengthFunction · 0.85
getBackgroundUsageNoteFunction · 0.70
getMaxTimeoutMsFunction · 0.70
getDefaultTimeoutMsFunction · 0.70

Tested by

no test coverage detected