prune

A command that finds memory databases for projects whose folders no longer exist on disk and can remove those orphaned databases.

In plain words
What is it for?
Use it first as a dry run to review orphan databases, then run it with the apply option to delete the selected files.
Why use it?
It cleans up stored data left behind after projects are deleted or moved.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/cbuntingde/kimi-memory/prune
Clone the repo
git clone --depth 1 https://github.com/cbuntingde/kimi-memory
Per session 27 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 677 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00027 $0.00677
Opus 5 $0.00014 $0.00338
Sonnet 5 $0.00005 $0.00135
Haiku 4.5 $0.00003 $0.00068

Measured yesterday against content hash 96e972e4e1dd, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

prune scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/prune.md · 70 lines

How it starts

The opening of the file, as written. The whole thing — 70 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/kimi-memory:prune

Remove kimi-memory project databases for projects that no longer exist on disk.

Usage

/kimi-memory:prune                # dry run — list orphan databases, do not remove
/kimi-memory:prune --apply        # actually remove the orphan database files

What this does

The plugin stores one SQLite database per project under $KIMI_CODE_HOME/kimi-memory/<project-key>/memory.sqlite, keyed by the SHA-256 of the canonical project root. When a project is deleted or moved, the database is left behind and the file becomes unreachable through normal agent flow. This command finds and removes those orphans.

The dry run is the default — it always shows what would be removed before touching the filesystem. Review the list, then re-run with --apply if the deletions are correct.

Procedure

  1. Call memory_prune(scope: "all-projects", apply: false). The MCP tool enumerates every project DB in the data root, looks up the recorded canonical root, and reports exists_on_disk: true|false for each.
  2. Print the list of orphans (exists_on_disk: false) clearly:
    Found 2 orphan project databases:
      - 5344107ff52a7a33 → /Users/me/old-projects/foo
      - aabbccdd00112233 → /Users/me/old-projects/bar
    
  3. Stop. Tell the user the dry-run result. If they want to proceed, wait for confirmation; this command is destructive.
  4. After explicit confirmation, call memory_prune(scope: "all-projects", apply: true) and report the final removed count. The global database is never touched.

When not to use

  • Do not invoke with --apply on someone else's behalf. The MCP tool is idempotent and the dry-run is the safe default; the user must confirm before destructive removal.
  • Do not use this command to remove a project the user is still working on. The dry run shows the canonical root for each project — if the path exists, the project is alive and the entry should not be removed.
  • The global cross-project database ($KIMI_CODE_HOME/kimi-memory/_global/) is not in scope. Removing it is a separate manual cleanup, not memory_prune.

Read the full file on GitHub · 70 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 70 lines · 27 tokens per session scan A 96e972e4e1dd

Subscribe to this mod's changes

prune is a command published in the GitHub repository cbuntingde/kimi-memory (0 stars, last pushed 2d ago), licensed MIT. It adds 27 tokens to every session and 677 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.