← Back to list

memory-summarize
by whiteboardev
⭐ 0🍴 0📅 Jan 15, 2026
SKILL.md
name: memory-summarize description: Compress memories into structured summaries using low-cost AI models (Claude Haiku, GPT-4o-mini). Triggers when memory count exceeds 50 or token estimate exceeds 40000. Outputs structured JSON with compression metrics. license: Apache-2.0 compatibility: Requires BrAIny API at localhost:3000, Bun runtime metadata: author: brainy version: "1.1" category: memory-management subagent: summarizer allowed-tools: Bash(bun:*)
Memory Summarization
Compresses multiple memories into structured summaries. Reduces context size while preserving critical information.
Execution Path
┌─────────────────────────────────────────────────────────┐
│ EXECUTION DECISION │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌──────────┐ ┌───────────────────┐ │
│ │ START │────▶│ SUBAGENT AVAILABLE?│ │
│ └──────────┘ └─────────┬─────────┘ │
│ │ │
│ ┌──────────────┴──────────────┐ │
│ ▼ ▼ │
│ ┌────────────┐ ┌────────────┐ │
│ │ YES │ │ NO │ │
│ └─────┬──────┘ └─────┬──────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌─────────────────────┐ ┌─────────────────────┐ │
│ │ Task(summarizer, │ │ Bash(bun scripts/ │ │
│ │ prompt: "...") │ │ create-summary.ts)│ │
│ └─────────────────────┘ └─────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────┘
Path A: Subagent Available (Preferred)
Use the summarizer subagent for lower token cost:
Task(
subagent_type: "summarizer",
description: "Summarize memories",
prompt: "Check stats and create coding_session summary for project 3afb861a-b783-45a6-bba2-4b6d96468aeb"
)
Path B: Script Fallback
If subagent unavailable, execute scripts directly:
bun .opencode/skills/memory-summarize/scripts/check-memory-stats.ts PROJECT_ID
bun .opencode/skills/memory-summarize/scripts/create-summary.ts PROJECT_ID TYPE
State Machine
┌─────────────────────────────────────────────────────────────────────┐
│ SUMMARIZATION WORKFLOW │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────┐ ┌──────────────┐ ┌─────────────────────────┐ │
│ │ START │────▶│ CHECK_STATS │────▶│ EVALUATE_THRESHOLDS │ │
│ └──────────┘ └──────────────┘ └─────────────────────────┘ │
│ │ │
│ ┌────────────────────────┼────────────┐ │
│ ▼ ▼ │ │
│ ┌────────────┐ ┌────────────┐ │ │
│ │ SKIP │ │ SUMMARIZE │ │ │
│ │ (below │ │ (above │ │ │
│ │ threshold) │ │ threshold) │ │ │
│ └────────────┘ └─────┬──────┘ │ │
│ │ │ │ │
│ │ ┌──────▼──────┐ │ │
│ │ │ SELECT_TYPE │ │ │
│ │ └──────┬──────┘ │ │
│ │ │ │ │
│ │ ┌─────────────────┼─────────────┐│ │
│ │ ▼ ▼ ▼│ │
│ │ ┌────────┐ ┌────────────┐ ┌──────┴┐ │
│ │ │coding_ │ │conversation│ │custom │ │
│ │ │session │ │ │ │ │ │
│ │ └───┬────┘ └─────┬──────┘ └───┬───┘ │
│ │ └───────────────┼────────────┘ │
│ │ ▼ │
│ │ ┌─────────────┐ │
│ │ │ CREATE_ │ │
│ │ │ SUMMARY │ │
│ │ └──────┬──────┘ │
│ │ │ │
│ │ ┌──────▼──────┐ │
│ │ │ VERIFY_ │ │
│ │ │ COMPRESSION │ │
│ │ └──────┬──────┘ │
│ │ │ │
│ │ ┌───────────┴───────────┐ │
│ │ ▼ ▼ │
│ │ ┌────────────┐ ┌────────────┐ │
│ │ │ SUCCESS │ │ FAILURE │ │
│ │ │ ratio > 2.0│ │ ratio < 2.0│ │
│ │ └─────┬──────┘ └─────┬──────┘ │
│ │ │ │ │
│ │ ▼ ▼ │
│ │ ┌──────────┐ ┌──────────┐ │
│ └─▶│ END │◀─────────│ RETRY │ │
│ └──────────┘ └──────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────┘
States
| State | Entry Condition | Action | Exit Condition |
|---|---|---|---|
| CHECK_STATS | Start | Run check-memory-stats.ts | Stats retrieved |
| EVALUATE_THRESHOLDS | Stats available | Compare against thresholds | Decision made |
| SKIP | count < 50 AND tokens < 40000 | Log "below threshold" | End |
| SELECT_TYPE | Above threshold | Determine summary type | Type selected |
| CREATE_SUMMARY | Type selected | Run create-summary.ts | API response |
| VERIFY_COMPRESSION | Summary created | Check ratio > 2.0 | Verified |
| SUCCESS | ratio >= 2.0 | Output summary ID | End |
| FAILURE | ratio < 2.0 | Log warning | Retry or End |
Thresholds
| Metric | Threshold | Action |
|---|---|---|
| Memory count | >= 50 | Summarize |
| Token estimate | >= 40000 | Summarize |
| Compression ratio | < 2.0 | Warning |
Summary Types
coding_session
Input: Development memories (file changes, errors, debugging)
Output sections:
objective: string (one sentence)progress: string[] (action → result)filesTouched: {path, operation, changes}[]currentState: stringcriticalDetails: string[]
conversation
Input: Dialogue memories (discussions, decisions)
Output sections:
topics: string[]decisions: string[]actionItems: string[]context: string[]openQuestions: string[]
custom
Input: Any memories with custom prompt
Output sections:
prompt: stringcontent: stringkeyPoints: string[]
Commands
Check Statistics
bun .opencode/skills/memory-summarize/scripts/check-memory-stats.ts PROJECT_ID [--show-compression]
Output:
Memory Count: 150
Estimated Tokens: 60000
⚠️ Memory count exceeds threshold (50)
Recommendation: Run summarization
Create Summary
bun .opencode/skills/memory-summarize/scripts/create-summary.ts PROJECT_ID TYPE [CUSTOM_PROMPT]
Parameters:
- PROJECT_ID: UUID (required)
- TYPE: coding_session | conversation | custom (default: coding_session)
- CUSTOM_PROMPT: string (required if TYPE=custom)
Output:
Summary ID: abc-123
Compression Ratio: 6.25x
Token Reduction: 84%
Original: 5000 tokens
Compressed: 800 tokens
Memories:
Summarized: 44
Retained: 6
Get Hybrid Context
bun .opencode/skills/memory-summarize/scripts/get-context.ts PROJECT_ID [QUERY]
Output:
{
"summaries": [...],
"recentMemories": [...],
"relevantMemories": [...]
}
Configuration
| Variable | Default | Description |
|---|---|---|
| BRAINY_API_URL | http://localhost:3000 | API endpoint |
| RETAIN_LAST_N | 6 | Memories to keep unsummarized |
| SUMMARIZATION_AUTO_TRIGGER_COUNT | 50 | Memory count threshold |
| SUMMARIZATION_AUTO_TRIGGER_TOKENS | 40000 | Token threshold |
Error Codes
| Error | Cause | Resolution |
|---|---|---|
| "No memories found" | Empty project | Create memories first |
| "All memories in retain window" | count <= RETAIN_LAST_N | Reduce RETAIN_LAST_N or add memories |
| "Project not found" | Invalid PROJECT_ID | Verify UUID |
| "API connection refused" | Server not running | Start BrAIny API |
Decision Tree
Is memory count >= 50?
├── YES → Summarize
└── NO → Is token estimate >= 40000?
├── YES → Summarize
└── NO → Skip (no action needed)
If Summarize:
├── Contains file changes, errors, code? → coding_session
├── Contains discussion, decisions? → conversation
└── User specified prompt? → custom
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon