Ctx Purge

mksglu/context-mode/skills/ctx-purge

作者 mksglua6c43765d26b无许可证25K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库今天更新

Purge the context-mode knowledge base. Permanently deletes all indexed content and resets session stats. This is destructive and cannot be undone. Trigger: /context-mode:ctx-purge

仅含说明DevOps & Cloud
AI 生成的概览

清除 context-mode 知识库,按项目或会话范围永久删除已索引内容和会话数据。

功能
该技能指导代理永久删除某个项目的 context-mode 会话数据。它支持两种范围:项目范围会清空知识库、所有会话数据库行、事件 markdown 文件和统计信息;会话范围只删除匹配会话的行和 FTS5 分块,保留同级会话和项目统计。技能要求代理先与用户确认范围,警告项目级删除的破坏性,以 confirm 为 true 调用 ctx_purge MCP 工具,并报告删除结果。
适用场景
适用于已索引的 context-mode 内容过时或错误并污染搜索结果时、需要完全重新开始时,或需要隔离单个被污染的会话而不丢失主工作会话统计信息时。
运行要求
需要提供 ctx_purge 工具的 context-mode MCP 服务器;不附带脚本,仅为指令。

Context Mode Purge

Permanently deletes session data for this project. Two scopes are supported (issue #520):

  • Project scope (scope: "project"): wipes EVERYTHING — knowledge base, all session DB rows for every session, events markdown, and stats.
  • Session scope (sessionId: "<id>" or scope: "session"): wipes ONLY the matching session's rows + FTS5 chunks. Sibling sessions, project stats, and the FTS5 store file are preserved.

Instructions

  1. Decide the scope first with the user:
    • "Wipe just one session?" → ask for the sessionId.
    • "Wipe the whole project?" → confirm scope:'project' (this is the destructive, irreversible default).
  2. Warn the user about scope:'project'. Everything will be deleted:
    • FTS5 knowledge base (all indexed content from ctx_index, ctx_fetch_and_index, ctx_batch_execute)
    • Session events DB (analytics, metadata, resume snapshots) for ALL sessions in the project
    • Session events markdown file
    • In-memory session stats + persisted stats file
  3. Call the mcp__context-mode__ctx_purge MCP tool with the chosen parameters:
    • Scoped: { confirm: true, sessionId: "<id>" } — implies scope:'session'.
    • Project: { confirm: true, scope: "project" } — explicit destructive form.
    • Bare { confirm: true } still works but emits a deprecation warning. Prefer the explicit forms.
  4. Report the result to the user — the response lists exactly what was deleted and (for scoped purges) confirms that other sessions and project stats were preserved.

Schema rules

  • confirm: true is always required.
  • sessionId and scope: "project" together is REJECTED as ambiguous (the sessionId implies session scope; combining with project scope contradicts intent).
  • scope: "session" without sessionId throws — sessionId is required.

When to Use

  • Scoped (per-session): scratch acceptance scenarios, drill replays, isolating a polluted session without losing the main working session's stats.
  • Project: KB contains stale or incorrect content polluting search results, switching between unrelated projects in the same session, completely fresh start.

Important

  • ctx_purge is the only way to delete session data. No other mechanism exists.
  • ctx_stats is read-only — shows statistics only.
  • /clear and /compact do NOT affect any context-mode data.
  • There is no undo. Re-index content if you need it again.

来源与署名

来源:mksglu/context-mode位于skills/ctx-purge提交a6c4376

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架