Purge Knowledge Base
ctx_purgePermanently delete indexed content for a single session or entire project. Confirmation is required to prevent irreversible data loss.
Instructions
DESTRUCTIVE: permanently delete indexed content. Cannot be undone. Requires confirm:true and exactly one scope.
WHEN:
User explicitly asks to clear a specific session ('purge this session', 'wipe this conversation')
User explicitly asks to reset the whole project ('reset everything', 'wipe the knowledge base')
WHEN NOT:
User says 'reset', 'clear', or 'wipe' without naming a scope -> ask which scope before calling
User wants to free memory or improve performance -> recommend ctx_stats first, do not purge
SCOPES (pass exactly one):
Per-session: ctx_purge(confirm: true, sessionId: "") deletes that session's events (auto-captured decisions, errors, plans, user prompts, rejected approaches, etc.) and per-session FTS5 chunks; sibling sessions and stats file are preserved.
Per-project: ctx_purge(confirm: true, scope: "project") wipes FTS5 knowledge base, every session DB row, events markdown, and resets the stats file. Use ctx_stats first to preview category counts before purging.
CONTRACT:
confirm:true is required; confirm:false returns 'purge cancelled'.
sessionId and scope:'project' together return 'ambiguous - pick one'.
scope:'session' without sessionId throws (sessionId required).
Bare {confirm:true} is deprecated: maps to scope:'project' with a stderr warning; will hard-error in a future major.
RETURNS: A summary of removed rows + the resolved scope.
EXAMPLE: ctx_purge(confirm: true, sessionId: "7c8a-1234-5678-9abc-def012345678") EXAMPLE: ctx_purge(confirm: true, scope: "project")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| confirm | Yes | MUST be true. Destructive operation; false returns 'purge cancelled'. | |
| sessionId | No | UUID of a single session. Pairs with confirm:true to wipe only that session's events + per-session FTS5 chunks. Sibling sessions and the stats file are preserved. MUST NOT be combined with scope:'project'. | |
| scope | No | Explicit scope selector. 'session' REQUIRES sessionId. 'project' wipes the entire project (FTS5 + every session + stats). Omit only for the deprecated bare-{confirm:true} back-compat path. |