From hipocampus
Builds 5-level compaction tree (daily/weekly/monthly/root) for memory logs with LLM summaries above thresholds, fixed/tentative nodes, and trigger conditions. Runs at session start or via scheduler.
npx claudepluginhub kevin-hs-sohn/hipocampus --plugin hipocampusThis skill uses the workspace's default tool permissions.
5-level hierarchical index over raw memory logs. Compaction nodes are **search indices** — originals are never deleted.
Implements 3-tier agent memory system with 5-level compaction tree for Claude Code. Manages session start protocols, compaction triggers, checkpoints, and memory files.
Guides manual context compaction at phase boundaries in CTF and pentest sessions to preserve exploit state, payloads, and findings from auto-compaction.
Provides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Share bugs, ideas, or general feedback.
5-level hierarchical index over raw memory logs. Compaction nodes are search indices — originals are never deleted.
memory/
ROOT.md <- root node (topic index, ~3K tokens, Layer 1)
2026-03-15.md <- raw daily log (permanent, append-only)
daily/2026-03-15.md <- daily compaction node
weekly/2026-W11.md <- weekly compaction node
monthly/2026-03.md <- monthly compaction node
Compaction chain: Raw → Daily → Weekly → Monthly → Root
Tree traversal (search): Root → Monthly → Weekly → Daily → Raw
Every compaction node has a status:
# Indicated in YAML frontmatter
---
type: weekly
status: tentative
period: 2026-W11
---
Key: tentative nodes are created immediately — ROOT.md is usable from day one.
Called from hipocampus:core Session Start step 7, or directly by an external scheduler (e.g., OpenClaw heartbeat). Check trigger conditions below.
| Level | Tentative Create/Update | Fixed Transition |
|---|---|---|
| Raw → Daily | On each new raw addition | Date changes |
| Daily → Weekly | On daily add/change | ISO week ended + 7 days elapsed |
| Weekly → Monthly | On weekly add/change | Month ended + 7 days elapsed |
| Monthly → Root | On monthly add/change | Never (root accumulates forever) |
Below threshold: copy/concat verbatim (no information loss). Above threshold: generate LLM keyword-dense summary.
| Level | Threshold | Above | Below |
|---|---|---|---|
| Raw → Daily | ~200 lines | LLM keyword-dense summary | Copy raw verbatim |
| Daily → Weekly | ~300 lines combined | LLM keyword-dense summary | Concat dailies |
| Weekly → Monthly | ~500 lines combined | LLM keyword-dense summary | Concat weeklies |
| Monthly → Root | Always | Recursive recompaction | (N/A) |
Entries in daily logs are tagged: ## Topic [type]. Four types exist:
| Type | Compaction behavior |
|---|---|
user | Always preserve core content. Never compress to Historical Summary. |
feedback | Always preserve rule + why + how-to-apply structure. Never compress to Historical Summary. |
project | Completed → compress to Historical Summary. Active → keep in Active Context. |
reference | Preserve pointer + 1-line description. Mark [?] if >30 days unverified. |
Backward compat: Untagged entries (no [type] in heading) → treat as [project].
At every compaction level, extract topic keywords from content and write to frontmatter topics field:
## Topic [type]) for keywordstopics: [hipocampus [project], terse-responses [feedback]]When generating LLM summaries, strip:
→ filepath:linesCRITICAL — STRICT CHAIN ORDER: Steps 2→3→4→5 MUST execute in sequence. NEVER skip a level.
Each step feeds the next. Root reads from monthly. Monthly reads from weekly. Weekly reads from daily. If you skip a level, the chain breaks and data is lost or corrupted.
Raw → [Step 2] → Daily → [Step 3] → Weekly → [Step 4] → Monthly → [Step 5] → Root
↑ ↑ ↑ ↑
reads raw reads daily reads weekly reads monthly
writes daily/ writes weekly/ writes monthly/ writes ROOT.md
NEVER:
Before starting the compaction chain, preserve current working state:
WORKING.mdmemory/YYYY-MM-DD.md):
## Working State Snapshot [project]
- context: pre-compaction automatic snapshot
- state: [copy WORKING.md content]
Scan memory/ for raw files. Group by date, ISO week, and month. Check each group against trigger conditions.
Input: raw files (memory/YYYY-MM-DD.md)
Output: daily nodes (memory/daily/YYYY-MM-DD.md)
For each date where raw exists and daily needs create/update:
memory/YYYY-MM-DD.mdmemory/daily/YYYY-MM-DD.md---
type: daily
status: tentative
period: YYYY-MM-DD
source-files: [memory/YYYY-MM-DD.md]
topics: [keyword1, keyword2, keyword3]
---
## Topics
## Key Decisions
## Tasks Completed
## Lessons Learned
## Open Items
status: fixedSecret scanning: The mechanical compaction (hipocampus compact) automatically redacts secrets in compaction nodes using regex patterns. When generating LLM summaries for above-threshold nodes, also avoid reproducing any API keys, tokens, passwords, or credentials from the source material. If you encounter a secret in the source, write [REDACTED] in its place.
CHECKPOINT: Verify memory/daily/ has the updated file before proceeding to Step 3.
Input: daily nodes (memory/daily/YYYY-MM-DD.md) — NEVER raw files
Output: weekly nodes (memory/weekly/YYYY-WNN.md)
STOP-CHECK: Did Step 2 produce or update a daily node? If not, skip Steps 3-5 entirely — there's nothing new to propagate.
For each ISO week where dailies exist and weekly needs create/update:
memory/daily/, NOT from memory/)memory/weekly/YYYY-WNN.md with frontmatterstatus: fixedCHECKPOINT: Verify memory/weekly/ has the updated file before proceeding to Step 4.
Input: weekly nodes (memory/weekly/YYYY-WNN.md) — NEVER daily or raw files
Output: monthly nodes (memory/monthly/YYYY-MM.md)
STOP-CHECK: Did Step 3 produce or update a weekly node? If not, skip Steps 4-5 — there's nothing new to propagate.
For each month where weeklies exist and monthly needs create/update:
memory/weekly/, NOT from memory/daily/)memory/monthly/YYYY-MM.md with frontmatterstatus: fixedCHECKPOINT: Verify memory/monthly/ has the updated file before proceeding to Step 5.
Input: monthly nodes (memory/monthly/YYYY-MM.md) — NEVER weekly, daily, or raw files
Output: memory/ROOT.md
STOP-CHECK: Did Step 4 produce or update a monthly node? If not, DO NOT touch ROOT.md.
When a monthly node is created or updated:
memory/ROOT.md (if exists)memory/monthly/, NOT from any other directory)root = recompact(existing_root + monthly_changes)
memory/ROOT.mdcompaction.rootMaxTokens in config, default 3000 tokens / ~100 lines): self-compress — compress Historical Summary first, keep Active Context and Topics Index intact---
type: root
status: tentative
last-updated: YYYY-MM-DD
---
## Active Context (recent ~7 days)
- topic: current state, what's happening now
## Recent Patterns
- pattern: cross-cutting insight that emerged recently
## Historical Summary
- YYYY-MM~MM: high-level summary of that period
- YYYY-MM: key events
## Topics Index
- topic-keyword [type, Nd]: sub-keywords, references → knowledge/file.md
- topic-keyword [type]: sub-keywords
Age calculation: For each topic, find the most recent source-file date that mentions it. Compute days since that date. Write as Nd (e.g., 2d, 30d).
Type-specific root rules:
user/feedback topics: always in Topics Index, never in Historical Summary onlyproject topics: active → Active Context + Topics Index; completed >90d → Historical Summary only (remove from Topics Index if root exceeds size cap)reference topics: mark [?] if >30 days since last mentionOpenClaw only: Sync ROOT.md content into the "Compaction Root" section of MEMORY.md:
## Compaction Root section## Compaction Root and the next ## heading (or EOF) with the Active Context, Recent Patterns, and Topics Index sections from ROOT.mdAfter writing any compaction files:
qmd update
If vector search is enabled (search.vector: true in hipocampus.config.json):
qmd embed
If memory/agents/compaction/AGENT.md exists, read it before starting compaction. Use learned patterns to inform decisions (e.g., typical raw log size, common threshold behavior).
After compaction completes, if you observed a new pattern worth remembering:
memory/agents/compaction/AGENT.mdIf no new patterns were observed, skip the update.