中文 | English
Why is QueryEngine.ts more than a wrapper around query? Why is it the session-level orchestration center?
l1-startupl2-agent-loopl9-context
QueryEngine.tsbootstrap/state.tsconstants/prompts.ts
class QueryEnginebefore_getSystemPromptafter_getSystemPromptsystem_message_yieldedfetchSystemPromptParts
- how the default system prompt, append prompt, and memory mechanics prompt get assembled
- why slash-command processing, transcript persistence, and skill/plugin loading happen before the main query
- why QueryEngine acts like both a session controller and a staging area before each turn
QueryEngine.ts:184:export class QueryEngineQueryEngine.ts:284-301: profiler checkpoints around system prompt assemblyQueryEngine.ts:554:system_message_yielded
query.ts answers “how does a turn run?” QueryEngine.ts answers “what must be prepared before a turn can run at all?” If you want to understand how Claude Code unifies slash commands, memory, skills, plugins, and structured output under one entry path, this layer matters more than the loop itself.
- Why is system-prompt assembly centralized in QueryEngine instead of scattered across tools?
- Why is transcript persistence handled before entering the main loop?
- Where is the boundary between QueryEngine and the REPL?