用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/flonat/claude-research --skill memory-cleanup命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Use when you need to audit a research project against the init-project-research template.
Use when you need to validate a paper's bibliography — cross-references \cite{} keys against .bib files or embedded \bibitem entries, finds missing/unused/typo'd keys, and checks every key against the Paperpile library via the local resolver. Deep verification mode spawns parallel agents for DOI/metadata validation at scale. Fix mode rekeys drifted keys to canonical and stages missing entries for Paperpile.
Use when you need to bootstrap a full research project with directory scaffold and Overleaf symlink.
基于 SOC 职业分类
正在显示 SKILL.md
| name | memory-cleanup |
| description | Use when you need to prune duplicates and merge overlapping entries in MEMORY.md files. |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion |
| argument-hint | [project-path or 'all' for global consolidation] |
Periodic refinement of MEMORY.md files across projects. Prunes redundant entries, merges overlapping knowledge, generates higher-order abstractions from accumulated patterns, and removes stale or superseded entries.
Inspired by npcsh's knowledge graph sleep/dream cycles — memory consolidation applied to research project knowledge.
/system-audit)MEMORY.md exceeds 100 entriesMEMORY.md feels clutteredMEMORY.md has fewer than 10 entries — not enough to consolidate[LEARN] tags — let knowledge accumulate firstAsk the user which mode to run:
| Mode | Scope | What it does |
|---|---|---|
| Project (default) | Single project's MEMORY.md + .claude/state/personal-memory.md | Consolidate both tiers |
| Global | All MEMORY.md + personal-memory files across projects + Task Management | Consolidate all, cross-pollinate shared patterns |
Read the target MEMORY.md file(s) and .claude/state/personal-memory.md (if it exists) and perform:
Find entries that say the same thing in different words.
Signals:
Action: Merge into a single entry, keeping the most precise wording. Note the merge in a comment: <!-- merged from 2 entries -->.
Find entries that contradict each other (e.g., "use X" in one entry, "don't use X" in another).
Signals:
Action: Keep the most recent/correct entry. Flag contradictions for user review if the resolution isn't obvious.
Find entries that are no longer relevant.
Signals:
Action: Mark as [STALE?] and present to user for confirmation before removing. Never auto-delete.
Check whether entries are in the correct tier (see learn-tags rule for the two-tier system).
Promotion candidates (personal-memory → MEMORY.md):
.claude/state/personal-memory.md that would help a collaborator on a different machineDemotion candidates (MEMORY.md → personal-memory):
MEMORY.md that reference local paths, machine-specific tool versions, or environment quirksAction: Present promotion/demotion suggestions to the user. Move entries only after explicit approval.
Entries that have been independently confirmed multiple times are high-confidence knowledge.
Signals:
Action: Move to the top of their section. Add [CONFIRMED] marker if supported by 3+ independent occurrences.
Generate higher-order patterns from the accumulated entries.
Look for patterns that span multiple entries:
When consolidating across all projects, look for knowledge that applies everywhere:
For each pattern found, generate an abstraction:
## Abstraction: [Name]
**Pattern:** [What keeps happening]
**Root cause:** [Why it happens]
**Prevention:** [How to avoid it in future]
**Evidence:** [Which entries support this]
Present abstractions to the user. Only write the ones they approve.
Rewrite MEMORY.md with:
## Patterns)If .claude/state/personal-memory.md exists, also rewrite it with consolidated machine-specific entries. Apply any user-approved promotions (move to MEMORY.md) and demotions (move from MEMORY.md to personal-memory).
Before writing, show a summary:
## Consolidation Summary
| Action | Count |
|--------|-------|
| Duplicates merged | X |
| Contradictions resolved | X |
| Stale entries flagged | X |
| Stale entries removed | X (user-confirmed) |
| Entries strengthened | X |
| Abstractions generated | X |
| Tier promotions (personal → generic) | X |
| Tier demotions (generic → personal) | X |
| Cross-project promotions | X (global mode) |
### Entries Before: XX
### Entries After: YY
### Net reduction: ZZ
Always show the full proposed MEMORY.md before writing. Wait for explicit approval. The user may want to keep entries flagged as stale, adjust abstractions, or revert merges.
Why: scripts/sync-push-memory.sh append-merges MEMORY.md. Deletions propagate via tombstones: each shared dir carries a git-tracked .tombstones file (one filename per line, # comments allowed) that both sync scripts honour since 2026-07-03 — tombstoned entries are removed from both sides on every sync, so other machines self-clean instead of resurrecting deleted entries. This phase mirrors the cleanup to shared AND writes the tombstones.
When to run: Whenever this skill deletes files or shortens MEMORY.md (not needed for pure additions). If only adding entries, the normal append-merge sync handles it.
What to do:
Identify the shared copy location(s) that correspond to the local scope:
~/.claude/projects/-Users-user-*Task-Management/memory/) → $TM/.context/auto-memory/task-management/~/.claude/projects/*/memory/ for non-TM projects) → $TM/.context/auto-memory/global/Mirror local → shared for each location:
$shared_dir/.tombstones with a dated # comment — this is what makes the deletion stick on other machines..tombstones (a tombstoned name is a confirmed prior deletion, not a missing entry — re-delete it, don't pull it), is a legit entry this machine never pulled (shared aggregates across machines/sessions). Pull it into local + flag it for indexing — never delete it.⚠️ Do NOT infer deletion from a local/shared set difference. The naive
[ ! -f local/$name ] && rm shared/$nameis a data-loss bug: shared is a union across machines, so a shared-only file is usually a real entry local is missing, not something to delete. Real incident 2026-05-31: that loop silently deleted a legitreference_hermes_vps.md(created in another session) before it was caught in git. Delete only what Phase 3 explicitly removed.
Example (Task Management scope):
local_dir=~/.claude/projects/-Users-user-Task-Management/memory
shared_dir="$TM/.context/auto-memory/task-management"
# REMOVED = the entry files THIS cleanup deleted (user-confirmed in Phase 3).
# ONLY these may be deleted from shared. Edit per run.
REMOVED=(feedback_notion_rest_api.md feedback_dropbox_path_change.md) # example
# Force-copy the indices (overwrite, bypasses append-merge)
cp "$local_dir/MEMORY.md" "$shared_dir/MEMORY.md"
[ -f "$local_dir/MEMORY-ARCHIVE.md" ] && cp "$local_dir/MEMORY-ARCHIVE.md" "$shared_dir/MEMORY-ARCHIVE.md"
# 1. Delete from shared ONLY the explicitly-removed entries + tombstone them
# (the tombstone makes the deletion propagate: both sync scripts remove
# tombstoned files from local AND shared on every push/pull)
for name in "${REMOVED[@]}"; do
rm -f "$shared_dir/$name"
echo "$name # removed $(date +%Y-%m-%d) by /memory-cleanup" >> "$shared_dir/.tombstones"
done
# 2. Reconcile UP: a shared-only entry (not in REMOVED, not tombstoned) is a
# legit entry this machine is missing — pull it into local + flag it,
# never delete. A TOMBSTONED shared-only entry is a zombie: re-delete it.
for f in /*.md;
name=$( )
MEMORY.md|MEMORY-ARCHIVE.md) ;;
[ -f ] && grep -q ;
-f ; ;
[ ! -f ];
f /*.md;
name=$( )
MEMORY.md|MEMORY-ARCHIVE.md) ;;
[ ! -f ] || [ -nt ];
&& git add .context/auto-memory/task-management/ && git commit -m
Skip Phase 4 if: the consolidation only added entries (no deletions, no line removals from MEMORY.md). Append-merge handles additions correctly on its own.
Standard sections from the learn-tags rule:
| Section | Columns |
|---|---|
| Patterns | Pattern / Root cause / Prevention / Evidence (NEW — added by this skill) |
| Notation Registry | Variable / Convention / Anti-pattern |
| Estimand Registry | What we estimate / Identification / Key assumptions |
| Citations | One-liner corrections |
| Key Decisions | Decision / Rationale / Date |
| Anti-Patterns | What went wrong / Correction |
| Code Pitfalls | Bug / Impact / Fix |
The Task Management MEMORY.md at the project root:
$TM/MEMORY.md
Also check the auto-memory directory (path varies by machine — glob for it):
~/.claude/projects/-Users-user-*Task-Management/memory/MEMORY.md
/system-audit — Run consolidation as part of periodic maintenance/skill-extract — Creates the entries that this skill consolidates[LEARN] tags (rule) — The tagging system that feeds MEMORY.md/session-close — May surface entries worth recording before consolidation