# prompt-autopsy System-prompt autopsy command for Pi. ## Install / load Loaded through the root pi-ext package. See the [root README](../../README.md). ## Commands / tools / settings - Command: `/prompt-autopsy` - Shortcut: `Ctrl+Alt+A` - Hooks: `session_start`, `session_shutdown`, `before_agent_start`, `agent_start` - Tools: none - Settings: none ## Bench Run `mise run bench` here, or `mise //extensions/prompt-autopsy:bench` from the repository root, to benchmark system prompt grouping. ## Behavior Writes the current generated system prompt to a private temporary file. Opens it with `$VISUAL`, else `$EDITOR`, else `vi`. `before_agent_start` captures Pi's rendered system prompt. `agent_start` replaces it with the final prompt after every `before_agent_start` edit. Grouping reads Pi 0.86 top-level XML sections from the final prompt: - `[TOOLS]` for `` - `[RULES]` for Pi's native `` - `[GENERAL GUIDELINES]` for PFUI's `` - `[TOOL GUIDELINES]` for PFUI's `` - `[DOCS]` for `` - `[APPEND]` for `` - `[CTX]` for `` - `[SKILLS]` for `` - `[CWD]` for `` - `[SECTION name]` for custom sections - `[PREAMBLE]` for text before the first section - `[CORE]` for later unsectioned text Nested XML remains inside its owning top-level section. If no turn has started since session start or reload, the command warns and writes nothing rather than showing Pi's pre-hook base prompt as provider-effective context. ## Debug Opt in through [debug configuration](../DEBUG.md). Safe events: `session.start`, `session.shutdown`, `prompt.open.start`, `prompt.open.finish`, `prompt.open.error`.