Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/koersliven/lore/lore-compactnpx skills add koersliven/Lore --skill lore-compactgit clone --depth 1 https://github.com/koersliven/LoreWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/koersliven/lore/lore-compact)<a href="https://agentmods.dev/skills/koersliven/lore/lore-compact"><img src="https://agentmods.dev/badge/skills/koersliven/lore/lore-compact.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00020 | $0.00931 |
| Opus 5 | $0.00010 | $0.00465 |
| Sonnet 5 | $0.00004 | $0.00186 |
| Haiku 4.5 | $0.00002 | $0.00093 |
Grade A, and why
lore-compact scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 117 lines — stays where its author put it; the contents beside it link to each section on GitHub.
/compact — Knowledge Window Compression
类比 Claude Code 的上下文 compaction,在知识窗口过大时自动压缩,保持 snapshot 精炼。
When to Trigger
- Stop hook detects buffer has reached compact threshold (8+ entries)
- User explicitly invokes this skill
- Before /digest when buffer has 5+ entries (optional optimization)
Purpose
将 buffer 中的多条原始知识压缩为精炼的摘要,减少 snapshot 膨胀,同时保留完整追溯。
核心思想:不是简单 flush,而是先"消化"——合并同类、去除冗余、提取本质。
Process
Step 1: Read Buffer
读取 .ai-context/buffer.md 中的所有原始知识条目。
Step 2: Group by Theme
按主题分组。判断标准:
- 涉及同一文件 → 同组
- 涉及同一概念(如"超时"、"缓存") → 同组
- 同一类型的知识(多个 DECISION 关于同一设计) → 同组
Step 3: Merge and Dedupe
对每组执行:
合并规则:
- 多条关于同一文件的 DECISION → 合并为一条,保留最新原因
- 多条关于同一约束的重复描述 → 保留最完整的一条
- 互相矛盾的条目 → 标记
[CONFLICT],保留双方
去重规则:
- 完全相同的条目 → 只保留一条
- 后一条是前一条的子集 → 只保留前一条
Step 4: Summarize
将合并后的条目压缩为精炼形式:
原始:
[round: 3] [DECISION] 支付超时改为 5s
- Detail: 上游 SLA 从 3s 升级为 5s
[round: 5] [DECISION] 支付超时不能超过 8s
- Detail: 超过会触发回退
压缩后:
[DECISION] 支付超时设为 5s(上游 SLA 升级),上限 8s(防止回退)
- 来源: round 3, 5
- 关联: PaymentService.java
Step 5: Write Outputs
写入 increment(详细版):
- 包含所有原始条目的完整记录
- 用于追溯
写入 snapshot 更新(精炼版):
- 只写入压缩后的摘要
- 更新 snapshot 中受影响的章节
Step 6: Clear Buffer
清空 .ai-context/buffer.md。
Step 7: Git Add
git add .ai-context/increments/
git add .ai-context/snapshot.md
git add .ai-context/buffer.md
Output
静默执行。完成后简要报告:
+ Compact complete:
- 12 raw entries → 4 summarized entries
- 2 groups merged, 1 conflict flagged
- Increment: 2026-04-24_compact-session.md
- Snapshot updated: Key Decisions, Constraints
Difference from /digest
| /digest | /compact | |
|---|---|---|
| 触发时机 | soft 阈值 (5) | compact 阈值 (8) |
| 动作 | 直接写入 increment | 先合并压缩,再写入 |
| snapshot 更新 | 否(等 /evolve) | 是(轻量更新) |
| 目的 | 防止丢失 | 防止膨胀 |
典型流程:
buffer 积累 → 达到 5 条 → /digest → increments
buffer 继续积累 → 达到 8 条 → /compact → snapshot 轻量更新 + increments
buffer 继续积累 → 达到 15 条 → 强制 /compact + /digest
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 4d ago First seen · 117 lines · 20 tokens per session scan A 514c956a18e1
lore-compact is a skill published in the GitHub repository koersliven/Lore (5 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 20 tokens to every session and 931 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
context-end
Close a workspace session by reviewing a proposed summary, recording approved outcomes, updating state and decisions, and checking repository safety. Use only when the user explicitly asks to end, close, or hand off the current session.
context-update
Save a brief mid-session checkpoint to this workspace and update current state only when a priority or open thread changed. Use only when the user explicitly asks to checkpoint or save current progress.
faf-expert
Expert in .faf (Foundational AI-context Format) files for persistent project context. Use when working with .faf files, project DNA, CLAUDE.md bi-sync, faf-cli commands, MCP server configuration, or AI-readiness scoring (0-100%). Updated for v2.8.0 Tool Visibility System.
import
Import a self-contained NeatContext context bundle shared by another person, or reconcile a newer copy of a context already on this machine, leaving the source bundle unchanged. Use only when the user explicitly invokes this skill or asks to import a NeatContext bundle.
save
Save durable decisions, findings, plans, and implementation knowledge from the visible Codex conversation into a new or existing NeatContext context. Use only when the user explicitly invokes this skill or asks to preserve the current conversation as reusable context.
create
Create a fresh NeatContext context from a user-defined behavioral profile and an existing local knowledge folder. Use only when the user explicitly invokes this skill or asks to create a new context rather than save the current conversation.