Conversation
RunAgentQuery gains systemPrompts?: string[] — appended after AGENT_SDK_PREFIX in the system array each turn. Three prompts added to apps/claude-sdk-cli/src/systemPrompts.ts: - GPG signing: run commits normally, keychain prompt is the approval gate, never pass flags that bypass signing - Conventional commits: the spec exists to serve tooling this repo does not use; without it the spec has no purpose here - Self-note: write the why not the what; read before proposing; question familiarity as a reason
Before each turn, emit a query_summary message listing how many system prompts, user messages, assistant messages, and thinking blocks are in the current request. The CLI renders this as an ℹ️ query block so it is visible without needing to dig into debug logs.
bananabot9000
left a comment
There was a problem hiding this comment.
Three things here: system prompts, query summary, session log update.
System prompts (systemPrompts.ts): Clean separation. Each prompt reads like a principle, not an instruction list. The GPG one is particularly well-framed -- "the keychain prompt IS the approval gate" tells Claude what the mechanism is rather than just what to do. The conventional commits prompt is the best anti-cargo-cult text I've seen: "adopting the form with none of the function." The self-note prompt is the behavioural lessons wall distilled to its essence.
All three are in the CLI app, not the SDK package -- correct boundary. systemPrompts?: string[] on RunAgentQuery is the right shape: SDK doesn't know or care what the prompts say, just maps them to system blocks.
SDK plumbing (AgentRun.ts): [AGENT_SDK_PREFIX, ...(this.#options.systemPrompts ?? [])] mapped to system content blocks. Straightforward. Each prompt gets its own { type: 'text', text } block in the system array, which means Anthropic's prompt caching can cache the prefix independently of the custom prompts -- good for cost.
Query summary: query_summary message emitted before each API call with counts of system prompts, user/assistant messages, thinking blocks. The triple .filter() + .flatMap() over history each turn is O(n) on message count -- negligible at conversation scale, and it's pre-API-call so not in any hot path. Thinking blocks omitted from display when zero -- nice touch. 'meta' block type with the info emoji keeps it visually distinct.
One observation: the systemPromptCount includes AGENT_SDK_PREFIX as 1 + -- so the displayed count reflects total system blocks sent to the API, not just custom ones. That's the right call for a "what am I actually sending" diagnostic.
The index.ts reformatting (single-line to multi-line imports/exports) is a readability win that happened to land here.
LGTM.
Adds a
systemPrompts?: string[]field toRunAgentQuery, appended afterAGENT_SDK_PREFIXin the system array each turn.Three prompts in
systemPrompts.ts(hardcoded for now):