Agent skill

Hipocampus Compaction

by kevin-hs-sohn in kevin-hs-sohn/hipocampus

Build 5-level compaction tree (daily/weekly/monthly/root) with smart thresholds and fixed/tentative lifecycle.

MITAuto-check passedAgent Workflows

Install Hipocampus Compaction

skills CLI
$ npx skills add kevin-hs-sohn/hipocampus --skill hipocampus-compaction -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install kevin-hs-sohn/hipocampus hipocampus-compaction --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/kevin-hs-sohn/hipocampus.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/compaction .claude/skills/hipocampus-compaction && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
hipocampus-compaction
GitHub stars
210
Token cost
~3.2k tokens
SKILL.md length
1,421 words
Files
1
Skills in repo
8
Repo updated
First seen
Licence
MIT

At a glance

Build 5-level compaction tree (daily/weekly/monthly/root) with smart thresholds and fixed/tentative lifecycle.

  • Works in 8 steps: Pre-Compaction Snapshot → Discover Candidates → Daily Compaction (max 1 per cycle) → …
  • Via external scheduler
  • SKILL.md covers Hierarchy, Fixed vs Tentative Nodes, When to Run and Trigger Conditions, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Hipocampus Compaction is an agent skill from kevin-hs-sohn/hipocampus. Build 5-level compaction tree (daily/weekly/monthly/root) with smart thresholds and fixed/tentative lifecycle. Run at session start when triggers are met, or via external scheduler.

Its SKILL.md is about 3.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Agent Workflows. The repository describes itself as: Drop-in memory harness for AI agents — 3-tier memory, compaction tree, hybrid search. One command to set up. Works with Claude Code and OpenClaw. The licence is MIT.

When your agent uses it

  • Via external scheduler

Example prompts

  • “/hipocampus-compaction”

Workflow steps

8 steps, taken from the step headings in SKILL.md.

  1. Pre-Compaction Snapshot
  2. Discover Candidates
  3. Daily Compaction (max 1 per cycle)
  4. Weekly Compaction (max 1 per cycle)
  5. Monthly Compaction (max 1 per cycle)
  6. Root Compaction
  7. OpenClaw ROOT.md Sync
  8. Re-index

What it can do on your machine

Read from SKILL.md and the folder at commit df88ca1. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are markdown, bash and yaml).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Hipocampus Compaction loads about 3.2k tokens when it runs. Until then it costs about 51 tokens; SKILL.md has 1,421 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~51
When it runs · the whole SKILL.md, loaded when a task matches
~3.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from kevin-hs-sohn/hipocampus at commit df88ca1, republished under its MIT licence (© kevin-hs-sohn). 1,421 words, ~3,167 tokens.

Download SKILL.mdSave it as .claude/skills/hipocampus-compaction/SKILL.md (or your agent's skills folder).
name
hipocampus-compaction
description
Build 5-level compaction tree (daily/weekly/monthly/root) with smart thresholds and fixed/tentative lifecycle. Run at session start when triggers are met, or via external scheduler.

Memory Compaction Tree

5-level hierarchical index over raw memory logs. Compaction nodes are search indices — originals are never deleted.

Hierarchy

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

Fixed vs Tentative Nodes

Every compaction node has a status:

  • tentative — period is still ongoing, regenerated when new data arrives
  • fixed — period ended, never updated again
yaml
# Indicated in YAML frontmatter
---
type: weekly
status: tentative
period: 2026-W11
---

Key: tentative nodes are created immediately — ROOT.md is usable from day one.

When to Run

Called from hipocampus:core Session Start step 7, or directly by an external scheduler (e.g., OpenClaw heartbeat). Check trigger conditions below.

Trigger Conditions

LevelTentative Create/UpdateFixed Transition
Raw → DailyOn each new raw additionDate changes
Daily → WeeklyOn daily add/changeISO week ended + 7 days elapsed
Weekly → MonthlyOn weekly add/changeMonth ended + 7 days elapsed
Monthly → RootOn monthly add/changeNever (root accumulates forever)

Smart Thresholds

Below threshold: copy/concat verbatim (no information loss). Above threshold: generate LLM keyword-dense summary.

LevelThresholdAboveBelow
Raw → Daily~200 linesLLM keyword-dense summaryCopy raw verbatim
Daily → Weekly~300 lines combinedLLM keyword-dense summaryConcat dailies
Weekly → Monthly~500 lines combinedLLM keyword-dense summaryConcat weeklies
Monthly → RootAlwaysRecursive recompaction(N/A)

Type-Aware Compaction

Memory Types

Entries in daily logs are tagged: ## Topic [type]. Four types exist:

TypeCompaction behavior
userAlways preserve core content. Never compress to Historical Summary.
feedbackAlways preserve rule + why + how-to-apply structure. Never compress to Historical Summary.
projectCompleted → compress to Historical Summary. Active → keep in Active Context.
referencePreserve pointer + 1-line description. Mark [?] if >30 days unverified.

Backward compat: Untagged entries (no [type] in heading) → treat as [project].

Topics Keyword Extraction

At every compaction level, extract topic keywords from content and write to frontmatter topics field:

  • Scan headings (## Topic [type]) for keywords
  • Scan Key Decisions for decision keywords
  • Include type tag: topics: [hipocampus [project], terse-responses [feedback]]
Exclusion Filtering

When generating LLM summaries, strip:

  • Code blocks (triple backtick) → replace with → filepath:lines
  • Stack traces → 1-line error message
  • Entries containing "임시", "테스트 중", "나중에 삭제", "temporary", "test run", "delete later" → remove entirely

Algorithm

CRITICAL — 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:

  • Modify ROOT.md based on daily or weekly data (root reads ONLY from monthly)
  • Modify monthly based on daily data (monthly reads ONLY from weekly)
  • Skip Step 2 or 3 because "there's nothing new" — always verify by checking files
  • Touch ROOT.md directly without going through the full chain
Step 0: Pre-Compaction Snapshot

Before starting the compaction chain, preserve current working state:

  1. Read WORKING.md
  2. If it contains active task content (not just the empty template):
    • Append a snapshot to today's daily log (memory/YYYY-MM-DD.md):
      ## Working State Snapshot [project]
      - context: pre-compaction automatic snapshot
      - state: [copy WORKING.md content]
    • This ensures in-progress work is captured before any context compression
  3. If WORKING.md is empty or contains only the template, skip this step
Step 1: Discover Candidates

Scan memory/ for raw files. Group by date, ISO week, and month. Check each group against trigger conditions.

Step 2: Daily Compaction (max 1 per cycle)

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:

  1. Read raw file memory/YYYY-MM-DD.md
  2. Count lines — compare against ~200 line threshold
  3. Below threshold: copy raw verbatim to memory/daily/YYYY-MM-DD.md
  4. Above threshold: generate keyword-dense summary
  5. Write with frontmatter:
markdown
---
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
  1. If date has changed (raw is from a past date): set status: fixed

Secret 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.

Step 3: Weekly Compaction (max 1 per cycle)

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:

  1. Read all daily compaction files for that week (from memory/daily/, NOT from memory/)
  2. Count combined lines — compare against ~300 line threshold
  3. Below threshold: concat all dailies
  4. Above threshold: generate keyword-dense weekly summary
  5. Write to memory/weekly/YYYY-WNN.md with frontmatter
  6. If ISO week ended + 7 days elapsed: set status: fixed

CHECKPOINT: Verify memory/weekly/ has the updated file before proceeding to Step 4.

Step 4: Monthly Compaction (max 1 per cycle)

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:

  1. Read all weekly compaction files for that month (from memory/weekly/, NOT from memory/daily/)
  2. Count combined lines — compare against ~500 line threshold
  3. Below threshold: concat all weeklies
  4. Above threshold: generate keyword-dense monthly summary
  5. Write to memory/monthly/YYYY-MM.md with frontmatter
  6. If month ended + 7 days elapsed: set status: fixed

CHECKPOINT: Verify memory/monthly/ has the updated file before proceeding to Step 5.

Show full SKILL.md (530 more words)Show less
Step 5: Root Compaction

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:

  1. Read existing memory/ROOT.md (if exists)
  2. Read the new/updated monthly node (from memory/monthly/, NOT from any other directory)
  3. Recursive compaction: root = recompact(existing_root + monthly_changes)
    • Active Context: replace with current week's highlights — what's in progress, immediate priorities
    • Recent Patterns: update with newly emerged cross-cutting insights
    • Historical Summary: append/compress older context — merge periods, keep brief summaries
    • Topics Index: merge new topics, update existing entries with new sub-keywords and references
  4. Write to memory/ROOT.md
  5. If root exceeds size cap (compaction.rootMaxTokens in config, default 3000 tokens / ~100 lines): self-compress — compress Historical Summary first, keep Active Context and Topics Index intact
markdown
---
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 only
  • project 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 mention
Step 6: OpenClaw ROOT.md Sync

OpenClaw only: Sync ROOT.md content into the "Compaction Root" section of MEMORY.md:

  • Read MEMORY.md, find ## Compaction Root section
  • Replace everything between ## Compaction Root and the next ## heading (or EOF) with the Active Context, Recent Patterns, and Topics Index sections from ROOT.md
  • This keeps the auto-loaded MEMORY.md in sync with the canonical ROOT.md
Step 7: Re-index

After writing any compaction files:

bash
qmd update

If vector search is enabled (search.vector: true in hipocampus.config.json):

bash
qmd embed

Guards

  • CHAIN ORDER IS MANDATORY: Daily→Weekly→Monthly→Root. Never skip a level. Never read from a wrong source directory.
  • Each level reads ONLY from its immediate predecessor: Root←Monthly←Weekly←Daily←Raw
  • Raw files: never delete (permanent leaf nodes)
  • Max 1 daily + 1 weekly + 1 monthly + 1 root per compaction cycle
  • No empty summaries (minimum 50 bytes)
  • Skip failed file reads — never abort entire compaction
  • qmd update failure: warning only, not fatal
  • Root self-compresses when exceeding size cap (shrink older topics first)
  • Keyword-dense format only — no prose, no narrative. Optimized for BM25 recall.
  • If you feel tempted to "just update ROOT.md quickly" — STOP. Run the full chain.

Agent Memory (Optional)

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:

  • Append to memory/agents/compaction/AGENT.md
  • Keep under ~30 lines
  • Example patterns: "this project averages ~80 raw lines/day — daily threshold rarely hit", "weekly nodes frequently need LLM summary (>300 lines)"

If no new patterns were observed, skip the update.

Edge Cases

  • Empty days: No daily compaction node is generated for days without raw logs. Weekly naturally skips those days.
  • First day: Create the full tentative tree immediately (daily → weekly → monthly → root). ROOT.md is usable from day one.
  • Lifecycle example:
    • Day 1: raw created → daily(tentative) → weekly(tentative) → monthly(tentative) → ROOT
    • Day 2: daily(tentative) updated, weekly(tentative) updated, monthly(tentative) updated, ROOT updated
    • Week ends + 7 days: weekly → fixed, new weekly(tentative) starts
    • Month ends + 7 days: monthly → fixed, new monthly(tentative) starts

© kevin-hs-sohn, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/compaction of kevin-hs-sohn/hipocampus.

Open the folder on GitHubat commit df88ca1

Compare with similar skills

Hipocampus Compaction next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Hipocampus Compaction compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Hipocampus Compaction this skillkevin-hs-sohn/hipocampus210—~3.2kAutomated safety check: PassMIT
Claude Code Agent Developmentanthropics/claude-plugins-official38k7 repos~2.8kAutomated safety check: PassApache-2.0
Copilot Session Failure Analysisdotnet/maui23k—~3.4kAutomated safety check: PassMIT
Mem0 CLI Memory Commandsmem0ai/mem067k—~2kAutomated safety check: NotesApache-2.0
Create Agentvectorize-io/hindsight48k—~1.1kAutomated safety check: PassMIT
Google Antigravity SDKgoogle-antigravity/antigravity-sdk-python3.7k—~2.1kAutomated safety check: NotesApache-2.0

Similar skills

  • Claude Code Agent Development

    anthropics/claude-plugins-official

    Official

    Explains how to write agents for Claude Code plugins: the markdown file with YAML frontmatter, trigger descriptions, model and color settings, and system prompt design.

    38k GitHub starsUsed in 7 repos~2.8k tokens
    Agent WorkflowsAuto-check passed
  • Mines local Copilot CLI session logs for dotnet/maui to rank costly or failing runs, tag recurring failure modes, propose repo edits and emit guard evals.

    23k GitHub stars~3.4k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Adds, searches, lists, updates and deletes memories on the Mem0 platform from the terminal with the mem0 command, including a JSON mode built for agents.

    67k GitHub stars~2k tokensUpdated 2 days ago
    Agent WorkflowsAuto-check: notes
  • Create Agent

    vectorize-io/hindsight

    Create a new Hindsight-powered subagent with long-term memory.

    48k GitHub stars~1.1k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Google Antigravity SDK

    google-antigravity/antigravity-sdk-python

    Design, implement, and debug autonomous AI agents and multi-agent systems using the Google Antigravity (AGY) SDK.

    3.7k GitHub stars~2.1k tokensUpdated 3 days ago
    Agent WorkflowsAuto-check: notes
  • Yao Meta Skill

    yaojingang/yao-meta-skill

    Create, improve, or evaluate an existing skill from workflows, prompts, SOPs, scripts.

    2.7k GitHub stars~768 tokensUpdated 1 mo ago
    Agent WorkflowsAuto-check passed

More from kevin-hs-sohn/hipocampus

All 8 skills in this repo
  • Hipocampus Core

    kevin-hs-sohn/hipocampus

    3-tier agent memory system with 5-level compaction tree. An agent skill from kevin-hs-sohn/hipocampus.

    210 GitHub stars~1.8k tokensUpdated 4 mo ago
    Auto-check passed
  • Hipocampus Core

    kevin-hs-sohn/hipocampus

    3-tier agent memory system with 5-level compaction tree. An agent skill from kevin-hs-sohn/hipocampus.

    210 GitHub stars~2.6k tokensUpdated 4 mo ago
    Auto-check passed
  • Hipocampus Core

    kevin-hs-sohn/hipocampus

    3-tier agent memory system with 5-level compaction tree. An agent skill from kevin-hs-sohn/hipocampus.

    210 GitHub stars~1.5k tokensUpdated 4 mo ago
    Auto-check passed
  • Hipocampus Core

    kevin-hs-sohn/hipocampus

    3-tier agent memory system with 5-level compaction tree. An agent skill from kevin-hs-sohn/hipocampus.

    210 GitHub stars~1.7k tokensUpdated 4 mo ago
    Auto-check passed
  • Hipocampus Recall

    kevin-hs-sohn/hipocampus

    Memory recall guide. An agent skill from kevin-hs-sohn/hipocampus.

    210 GitHub stars~719 tokensUpdated 4 mo ago
    Auto-check passed
  • Hipocampus Search

    kevin-hs-sohn/hipocampus

    Search memory using qmd (BM25 + optional vector) and compaction tree traversal.

    210 GitHub stars~956 tokensUpdated 4 mo ago
    Auto-check passed

Questions about Hipocampus Compaction

What does Hipocampus Compaction do?

Build 5-level compaction tree (daily/weekly/monthly/root) with smart thresholds and fixed/tentative lifecycle. Hipocampus Compaction is an agent skill from kevin-hs-sohn/hipocampus. Build 5-level compaction tree (daily/weekly/monthly/root) with smart thresholds and fixed/tentative lifecycle.

When should I use Hipocampus Compaction?

Hipocampus Compaction fits situations like: via external scheduler.

How do I install Hipocampus Compaction in Claude Code?

Run `npx skills add kevin-hs-sohn/hipocampus --skill hipocampus-compaction -a claude-code`. Or copy the skill folder (skills/compaction in kevin-hs-sohn/hipocampus) into .claude/skills/hipocampus-compaction in your project. Claude Code loads it when a task matches its description.

How do I install Hipocampus Compaction in Codex?

Run `npx skills add kevin-hs-sohn/hipocampus --skill hipocampus-compaction -a codex`. Or copy the skill folder (skills/compaction in kevin-hs-sohn/hipocampus) into .agents/skills/hipocampus-compaction in your project. Codex loads it when a task matches its description.

Can I use Hipocampus Compaction in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add kevin-hs-sohn/hipocampus --skill hipocampus-compaction -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/hipocampus-compaction, .gemini/skills/hipocampus-compaction, .github/skills/hipocampus-compaction and .opencode/skills/hipocampus-compaction in your project.

What does Hipocampus Compaction need to run?

SKILL.md names no scripts, command-line tools or credentials: Hipocampus Compaction is instructions for the agent only.

Does Hipocampus Compaction access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Hipocampus Compaction safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Hipocampus Compaction use?

Hipocampus Compaction is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Hipocampus Compaction use?

About 3.2k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Hipocampus Compaction?

Skills that share tags, products or a category with Hipocampus Compaction: Claude Code Agent Development (anthropics/claude-plugins-official, 38k stars), Copilot Session Failure Analysis (dotnet/maui, 23k stars), Mem0 CLI Memory Commands (mem0ai/mem0, 67k stars) and Create Agent (vectorize-io/hindsight, 48k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Hipocampus Compaction?

kevin-hs-sohn (a GitHub user) maintains it in kevin-hs-sohn/hipocampus, which has 210 GitHub stars. The repository holds 8 skills in this directory. The repository was last updated on June 8, 2026.

Source: kevin-hs-sohn/hipocampus on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.