跳到正文
Skillpedia
智能体48k · #4809

hierarchical-agent-memory

它能做什么

这个工具用来帮你整理程序的“记忆”。它会为项目的每个部分生成信息“速查表”,这样程序就不必每次都重新通读全部内容,从而节省时间和资源。

适用场景

  • ✓当你的项目很大、文件夹很多时。
  • ✓当你希望程序在每个任务上使用更少的“记忆”(tokens)时。
  • ✓当你想查看一份关于节省了多少时间和费用的摘要时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/hierarchical-agent-memory/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/hierarchical-agent-memory/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“帮我为项目设置记忆。”

每周 5 个新技能,1 分钟读完。

工作原理

它会为项目中的每个文件夹生成“上下文”文件。一个主文件保存项目的总体信息,其他文件则保存每个部分的具体细节。仪表盘会显示你节省了多少。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Hierarchical Agent Memory (HAM)

Scoped memory system that gives AI coding agents a cheat sheet for each directory instead of re-reading your entire project every prompt. Root CLAUDE.md holds global context (200 tokens), subdirectory CLAUDE.md files hold scoped context (250 tokens each), and a .memory/ layer stores decisions, patterns, and an inbox for unconfirmed inferences.

When to Use This Skill

  • Use when you want to reduce input token costs across Claude Code sessions
  • Use when your project has 3+ directories and the agent keeps re-reading the same files
  • Use when you want directory-scoped context instead of one monolithic CLAUDE.md
  • Use when you want a dashboard to visualize token savings, session history, and context health
  • Use when setting up a new project and want structured agent memory from day one

How It Works

Step 1: Setup ("go ham")

Auto-detects your project platform and maturity, then generates the memory structure:

project/
├── CLAUDE.md              # Root context (~200 tokens)
├── .memory/
│   ├── decisions.md       # Architecture Decision Records
│   ├── patterns.md        # Reusable patterns
│   ├── inbox.md           # Inferred items awaiting confirmation
│   └── audit-log.md       # Audit history
└── src/
    ├── api/CLAUDE.md      # Scoped context for api/
    ├── components/CLAUDE.md
    └── lib/CLAUDE.md

Step 2: Context Routing

The root CLAUDE.md includes a routing section that tells the agent exactly which sub-context to load:

## Context Routing

→ api: src/api/CLAUDE.md
→ components: src/components/CLAUDE.md
→ lib: src/lib/CLAUDE.md

The agent reads root, then immediately loads the relevant subdirectory context — no guessing.

Step 3: Dashboard ("ham dashboard")

Launches a web dashboard at localhost:7777 that visualizes:

  • Token savings (HAM-on vs HAM-off sessions)
  • Daily token and cost trends
  • Per-directory session breakdown
  • Context file health (missing/stale/inherited CLAUDE.md coverage)
  • Routing compliance (how often the agent follows the routing map)
  • Carbon/energy estimates

Commands

Trigger What it does
go ham Set up HAM — auto-detect platform, generate CLAUDE.md files
ham savings Show token and cost savings report
ham dashboard Launch the interactive web dashboard
ham audit Health check on memory files
ham insights Generate actionable insights from session data
ham route Add/update Context Routing section in root CLAUDE.md
ham carbon Show energy and carbon efficiency data

Examples

Example 1: First-time setup

User: go ham

Agent: HAM setup complete. Created 8 files.
  - CLAUDE.md (root)
  - .memory/decisions.md
  - .memory/patterns.md
  - .memory/inbox.md
  - src/api/CLAUDE.md
  - src/components/CLAUDE.md
  - src/lib/CLAUDE.md
  - src/utils/CLAUDE.md

Baseline captured in .memory/baseline.json
Run "HAM savings" to see your token and cost savings.

Example 2: Checking savings

User: ham savings

Agent:
  Before HAM: ~7,500 tokens/prompt
  After HAM:    ~450 tokens/prompt
  Savings:    7,050 tokens (94%)

  Monthly projection (1,500 prompts):
    Sonnet: ~$31.73 saved
    Opus:   ~$158.63 saved

Best Practices

  • Keep root CLAUDE.md under 60 lines / 250 tokens
  • Keep subdirectory CLAUDE.md files under 75 lines each
  • Run ham audit every 2 weeks to catch stale or missing context files
  • Use ham route after adding new directories to keep routing current
  • Review .memory/inbox.md periodically — confirm or reject inferred items

Limitations

  • Token estimates use ~4 chars = 1 token approximation, not a real tokenizer
  • Baseline savings comparisons are estimates based on typical agent behavior
  • Dashboard requires Node.js 18+ and reads session data from ~/.claude/projects/
  • Context routing detection relies on CLAUDE.md read order in session JSONL files
  • Does not auto-update subdirectory CLAUDE.md content — you maintain those manually or via ham audit
  • Carbon estimates use regional grid averages, not real-time energy data

Related Skills

  • agent-memory-systems — general agent memory architecture patterns
  • agent-memory-mcp — MCP-based memory integration
常见问题

什么是 tokens?

Tokens 是程序能够理解的小段文本单位。用的 tokens 越多,费用就越高。

CLAUDE.md 是什么?

这是一个文件,程序会把项目的重要信息存在里面,比如说明、指令或描述。

仪表盘会显示实时信息吗?

仪表盘显示的是基于使用情况和已保存数据的估算值,帮助你直观地了解进度和费用。

详情

作者的原始描述

Scoped CLAUDE.md memory system that reduces context token spend. Creates directory-level context files, tracks savings via dashboard, and routes agents to the right sub-context.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4809
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能