brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
prune-agent-memoryAudit, classify, and selectively forget stored memories. Covers memory enumeration and classification by type/age/access frequency, staleness detection for outdated references, fidelity checks using external anchors, a decision tree for selective deletion, counter-memory inoculation for failed strategies that would otherwise be re-derived, preemptive filter…
Independent GitHub snapshot · Automated classification · Original documentation governs
稽核、分類並擇要遺忘所存之記憶。記憶為基礎設施,遺忘為政策。本技能即定該政策。
manage-memory 聚焦於組織與生長記憶(留何、如何結構化),本技能聚焦於其反面:捨何、如何偵衰、並使遺忘為刻意而非意外。二者互補,宜於定期維護中並用。
~/.claude/projects/<project-path>/memory/)讀全部記憶檔,並依四維分類每條目。
# Inventory the memory directory
ls -la <memory-dir>/
wc -l <memory-dir>/*.md
# Count total entries (approximate by counting top-level bullets and headers)
grep -c "^- \|^## " <memory-dir>/MEMORY.md
for f in <memory-dir>/*.md; do echo "$f: $(grep -c '^- \|^## ' "$f") entries"; done
將每一記憶條目歸為下列類型之一:
| Type | Description | Example | Default retention |
|---|---|---|---|
| Project | Facts about project structure, architecture, conventions | "skills/ has 310 SKILL.md files across 55 domains" | Keep until verified stale |
| Decision | Choices made and their rationale | "Chose hub-and-spoke over sequential for review teams because..." | Keep indefinitely |
| Pattern | Debugging solutions, workflow insights, recurring behaviors | "Exit code 5 means quoting error — use temp files" | Keep until superseded |
| Reference | Links, version numbers, external resources | "mcptools docs: https://..." | Keep until verified stale |
| Feedback | User preferences, corrections, style guidance | "User prefers kebab-case for file names" | Keep indefinitely |
| Ephemeral | Session-specific context that leaked into persistent memory | "Currently working on issue #42" | Prune immediately |
亦記每條目之:
預期: 一份完整盤點,每條目皆已分類且附年齡與存取頻率估。Ephemeral 條目已標為立即移除。
失敗時: 若記憶檔過大或缺結構難以逐條分類,於章節層次作之。將整節分類,而非逐項。目標為涵蓋,非粒度。
將記憶主張與當前專案狀態相較。陳舊為記憶衰退之最常型。
檢下列陳舊模式:
# Spot-check counts against source of truth
grep -oP '\d+ skills' <memory-dir>/MEMORY.md
grep -c "^ - id:" skills/_registry.yml
# Check for references to files that no longer exist
grep -oP '`[^`]+\.(md|yml|R|js|ts)`' <memory-dir>/MEMORY.md | sort -u | while read f; do
path="${f//\`/}"
[ ! -f "$path" ] && echo "STALE: $path referenced but not found"
done
# Check for references to old names/paths
grep -i "old-name\|previous-name\|renamed-from" <memory-dir>/*.md
對每一陳舊條目註其陳舊類型與當前正確值。
預期: 一份陳舊條目清單,附具體之變動證據。每條皆有建議行動:更新(若知正確值)、驗證(若不確)、修剪(若整條已過時)。
失敗時: 若無法驗證某主張因其涉外部狀態(API、第三方文件、部署狀態),標為 unverifiable,勿假定其為正。Unverifiable 條目若非積極有用,即修剪候選。
測試記憶被取回時是否仍能產出有用脈絡。此為最難之步,因代理無法驗證自身壓縮記憶之忠實性——須藉外部錨。
擬真度檢查之法:
往返驗證:讀一記憶條目,再檢其所述之專案實際狀態。記憶能否引你至正確之檔案、模式、結論?
壓縮失真偵測:將記憶摘要與原始來源相較。當 50 行討論被壓為 2 行記憶時,壓縮是否保留可行動之洞見,抑或僅留主題標籤?
# Find the source that a memory entry was derived from
# (git log, old PRs, original files)
git log --oneline --all --grep="<keyword from memory entry>" | head -5
矛盾掃描:搜互相矛盾之記憶或與 CLAUDE.md/專案文件矛盾者。
# Look for potential contradictions in counts
grep -n "total" <memory-dir>/MEMORY.md
grep -n "total" CLAUDE.md
# Compare the values — they should agree
效用測試:對每條目問:「若此條被刪,未來 5 個會話中是否會出錯?」答若「大概不會」,即為低擬真度價值,無論其準確與否。
預期: 每記憶條目皆有擬真度評估:高(已驗為準且有用)、中(大概準、偶有用)、低(未驗或鮮有用)、失(已驗為不準或矛盾)。
失敗時: 若多條之擬真度檢查無定論,聚焦於潛在影響最大之條目。錯誤之專案架構記憶比錯誤之除錯訣竅危險。先檢骨架級事實,後檢細節。
依下列決策樹定何者修剪,依優先序套:
Pruning Decision Tree (apply in order):
1. EPHEMERAL entries (Step 1 classification)
→ Delete immediately. These should never have been persisted.
2. FAILED fidelity entries (Step 3)
→ Delete immediately. Inaccurate memories are worse than no memories.
3. DUPLICATES
→ Keep the most complete/accurate version, delete others.
→ If duplicates span MEMORY.md and a topic file, keep the topic file version.
4. STALE entries with known corrections (Step 2)
→ UPDATE if the entry is otherwise useful (change the stale value to current).
→ DELETE if the entire entry is obsolete (the topic no longer matters).
5. LOW fidelity, low access frequency entries
→ Delete. These are taking space without providing value.
6. MEDIUM fidelity entries about completed/closed work
→ Archive or delete. Past sprint details, resolved incidents, merged PRs.
→ Exception: keep if the resolution contains a reusable pattern.
7. REFERENCE entries with freely available sources
→ Delete if the reference is a Google search away.
→ Keep if the reference is hard to find or has project-specific context.
對每一刪除,記其條目、分類與刪除理由(用於步驟七)。
於施本樹中任何 DELETE 行動之前,先檢該條目是否值得接種(步驟五)。已敗之策略、已棄之路徑、危險之模式皆為「刪併接種」而非單刪之候選。
預期: 一份明確之擬刪、擬更新、擬保留清單,每項皆附文件化理由。保留/刪除比視記憶健康而定;維護良好者修 5-10%,被忽略者可至 30-50%。
失敗時: 若決策樹對多項產生模糊結果,套更嚴篩:「以今日所知,是否仍會寫此條?」否則即為刪除候選。傾向修剪——重學一事比繞過錯誤記憶易。
某些已棄之結論不可徒刪。單刪無效,因生此記憶之條件仍存——系統將自相同輸入沿相同推理路徑重建已刪之記憶。對此等情形,須與刪除並行(或以代之)寫一反向記憶以阻再推導。
決策規則——單刪 vs. 刪併接種 vs. 僅接種:
| Memory category | Action | Why |
|---|---|---|
| Stale fact, outdated pointer, expired context | Delete-only | Retrieval cleanup; no behavioral risk if regenerated |
| Failed strategy, dangerous pattern, abandoned approach with persistent triggers | Delete + inoculate | The reasoning path will regenerate the conclusion otherwise |
| Decision later overridden but original rationale matters | Inoculate-only | Preserve original entry; add SUPERSEDED counter-memory pointing to it |
SUPERSEDED 記錄之格式(適用於 auto-memory 之 frontmatter;其結構可改以適他種記憶系統):
---
name: superseded-<short-id>
description: Counter-memory preventing re-derivation of <pattern>
type: superseded
---
SUPERSEDED <YYYY-MM-DD>
Pattern: <what was tried — describe the conclusion or strategy>
Period: <start> to <end>
Evidence: <what happened — concrete data, not narrative>
Abandonment reason: <specific cause; not "did not work">
Do not re-derive from: <signal types or input patterns that previously led here>
Supersedes: <path to original memory if delete + inoculate, or N/A>
將 SUPERSEDED 記錄各成一檔置於記憶目錄(如 superseded_strategy_X.md),俾與現行記憶並出於取回。此反向記憶即為制衡之機制:當類似訊號至,SUPERSEDED 記錄浮現並阻其再生路徑。
何時不宜接種:
接種之衛生:
Pattern 與 Do not re-derive from 宜具體。模糊之反向記憶(如「勿試複雜方案」)為雜訊。預期: 凡步驟四中涉已棄策略或危險模式之刪除候選,皆於原條目刪除前建一相應之 SUPERSEDED 反向記憶檔。修剪日誌兩記其刪與其接種。現行記憶仍精簡,而再生路徑已被阻。
失敗時: 若不確該條是否值得接種,則默接種之。多餘之 SUPERSEDED 記錄成本甚低;再生之惡模式成本甚高。若 SUPERSEDED 清單龐大至本身成雜訊,即為訊號:須查上游條件何以反覆生棄案——治本在輸入層,非記憶層。
定「不存何」之規以防未來之記憶污染。檢視既有記憶以辨應於寫入時即過濾之模式。
下列模式永不應入持久記憶:
| Pattern | Why | Example |
|---|---|---|
| Session-specific task state | Stale by next session | "Currently debugging issue #42" |
| Intermediate reasoning | Not a conclusion | "Tried approach A, didn't work because..." |
| Debug output / stack traces | Ephemeral diagnostic data | "Error was: TypeError at line 234..." |
| Exact command sequences | Brittle, version-dependent | "Run npm install foo@3.2.1 && ..." |
| Emotional/tonal notes | Not actionable | "User seemed frustrated" |
| Duplicates of CLAUDE.md | Already in system prompt | "Project uses renv for dependencies" |
| Unverified single observations | May be wrong | "I think the API rate limit is 100/min" |
若既有記憶中見此等模式,加入步驟四之刪除清單。
將過濾規則記於 MEMORY.md 或 retention-policy.md 主題檔,俾未來會話寫入新記憶前可查。
預期: 一組記於記憶目錄之先發過濾規則。任何與此等模式吻合之既有條目皆已標待刪。
失敗時: 若記錄規則感覺過早(記憶尚小、污染輕微),跳過記錄但仍施過濾以捕獲既有違例。規則可待目錄更成熟時再形式化。
將每一刪除記錄之,俾遺忘本身可審。建或更新修剪日誌。
<!-- In <memory-dir>/pruning-log.md or appended to MEMORY.md -->
## Pruning Log
### YYYY-MM-DD Audit
- **Entries audited**: N
- **Entries pruned**: M (X%)
- **Entries updated**: K
- **Staleness found**: [list of stale patterns detected]
- **Fidelity failures**: [list of entries that failed verification]
#### Deletions
| Entry (summary) | Type | Reason |
|-----------------|------|--------|
| "Currently working on issue #42" | Ephemeral | Session-specific, stale |
| "skills/ has 280 SKILL.md files" | Project | Count drift: actual is 310 |
| "Use acquaint::mcp_session()" | Pattern | Package renamed to mcptools |
修剪日誌宜簡。其為問責而存,非為考古。若日誌本身龐大,將舊條目摘述:「2025:3 次稽核,共修剪 47 條(多為計數漂移與短暫滲漏)。」
預期: 一份附時戳之修剪日誌條目,記何被刪、為何被刪。日誌與記憶並存於記憶目錄。
失敗時: 若另建日誌檔感覺過度(僅 1-2 條被剪),於 MEMORY.md 加簡註替之:<!-- Last pruned: YYYY-MM-DD, removed 2 stale entries -->。任何記錄勝於默默刪除。
某些記憶條目應免於修剪,無論年齡、存取頻率或擬真度分數如何。其代表不可替代之脈絡,若失之需重大努力以重建。
受保護記憶之準則:
| Category | Examples | Why protected |
|---|---|---|
| Architecture decisions | "Chose flat skill directory over nested" | Rationale is lost if re-derived later |
| User identity preferences | "Always use kebab-case," "Never auto-commit" | Explicit user intent, not inferrable |
| Security audit results | "Last audit: 2025-12-13 — PASSED" | Compliance evidence with timestamps |
| Rename/migration records | "Repo renamed: X to Y on date Z" | Cross-reference integrity depends on this |
標示法:以 <!-- PROTECTED --> 內聯標保護條目,或於修剪日誌維 protected 清單。步驟四之決策樹於施任何刪除規則前須先檢保護狀態。
解除保護:欲修剪受保護條目,須先明示移除標示,並於修剪日誌記理由。此二步流程防高價值記憶之意外刪除。
預期: 受保護條目歷次修剪皆存。修剪日誌記任何保護之增刪。
失敗時: 若受保護集過大(>30% 條目),重審準則——保護是為不可替代之脈絡,非為「重要」條目。重要但可重建之事實仍應接受常態修剪。
刪除之後,殘存記憶恐成片段——交叉參照指向已刪條目、主題檔失連貫、MEMORY.md 出現缺口。重新合成恢復結構完整性。
重新合成查核表:
預期: 修剪後記憶結構健全——無孤立參照、無冗餘片段、無不連貫之主題檔。冷條目已分類以供未來修剪決策。
失敗時: 若重新合成顯示修剪過猛(關鍵脈絡已失),檢修剪日誌並自稽核軌跡重建。此即稽核軌跡存在之由。
記憶漂移發生於所存事實默默失真——非其本即錯,而是底層現實已變而記憶未更新。漂移復原試圖就地修復記憶,而非修剪之。
漂移偵測之觸發:
復原程序:
[corrected YYYY-MM-DD] 註unverifiable 並列為修剪候選預期: 已漂移之記憶於可能處就地校正,保留脈絡。無從校正者標為修剪。預防規則減未來漂移。
失敗時: 若漂移已普遍(>20% 條目),記憶恐須整重建,而非逐項修補。彼時將當前記憶目錄存檔、自零開始、擇要重新匯入通過驗證之條目。
manage-memory —— 組織與生長記憶之互補技能;二者並用以盡記憶維護meditate —— 清明與立基,可揭出哪些記憶在製造雜訊rest —— 有時最佳記憶維護即不作記憶維護assess-context —— 評估推理脈絡之健康,記憶品質直接影響之