[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-6464714d-4599-431c-9b8a-8c4ca1518f67":3,"$f7oZuRBmWVBmzndpTUW4yArbgNp8tyeI40uXV87Q8HMY":42},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":33},"6464714d-4599-431c-9b8a-8c4ca1518f67","hierarchical-agent-memory","范围化的CLAUDE.md内存系统，减少上下文令牌消耗。创建目录级上下文文件，通过仪表板跟踪节省情况，并将代理路由到正确的子上下文。","cat_coding_backend","mod_coding","sickn33,coding","---\nname: hierarchical-agent-memory\ndescription: \"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.\"\nrisk: safe\nsource: \"https:\u002F\u002Fgithub.com\u002Fkromahlusenii-ops\u002Fham\"\ndate_added: \"2026-02-27\"\n---\n\n# Hierarchical Agent Memory (HAM)\n\nScoped 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\u002F` layer stores decisions, patterns, and an inbox for unconfirmed inferences.\n\n## When to Use This Skill\n\n- Use when you want to reduce input token costs across Claude Code sessions\n- Use when your project has 3+ directories and the agent keeps re-reading the same files\n- Use when you want directory-scoped context instead of one monolithic CLAUDE.md\n- Use when you want a dashboard to visualize token savings, session history, and context health\n- Use when setting up a new project and want structured agent memory from day one\n\n## How It Works\n\n### Step 1: Setup (\"go ham\")\n\nAuto-detects your project platform and maturity, then generates the memory structure:\n\n```\nproject\u002F\n├── CLAUDE.md              # Root context (~200 tokens)\n├── .memory\u002F\n│   ├── decisions.md       # Architecture Decision Records\n│   ├── patterns.md        # Reusable patterns\n│   ├── inbox.md           # Inferred items awaiting confirmation\n│   └── audit-log.md       # Audit history\n└── src\u002F\n    ├── api\u002FCLAUDE.md      # Scoped context for api\u002F\n    ├── components\u002FCLAUDE.md\n    └── lib\u002FCLAUDE.md\n```\n\n### Step 2: Context Routing\n\nThe root CLAUDE.md includes a routing section that tells the agent exactly which sub-context to load:\n\n```markdown\n## Context Routing\n\n→ api: src\u002Fapi\u002FCLAUDE.md\n→ components: src\u002Fcomponents\u002FCLAUDE.md\n→ lib: src\u002Flib\u002FCLAUDE.md\n```\n\nThe agent reads root, then immediately loads the relevant subdirectory context — no guessing.\n\n### Step 3: Dashboard (\"ham dashboard\")\n\nLaunches a web dashboard at localhost:7777 that visualizes:\n- Token savings (HAM-on vs HAM-off sessions)\n- Daily token and cost trends\n- Per-directory session breakdown\n- Context file health (missing\u002Fstale\u002Finherited CLAUDE.md coverage)\n- Routing compliance (how often the agent follows the routing map)\n- Carbon\u002Fenergy estimates\n\n## Commands\n\n| Trigger | What it does |\n|---|---|\n| `go ham` | Set up HAM — auto-detect platform, generate CLAUDE.md files |\n| `ham savings` | Show token and cost savings report |\n| `ham dashboard` | Launch the interactive web dashboard |\n| `ham audit` | Health check on memory files |\n| `ham insights` | Generate actionable insights from session data |\n| `ham route` | Add\u002Fupdate Context Routing section in root CLAUDE.md |\n| `ham carbon` | Show energy and carbon efficiency data |\n\n## Examples\n\n### Example 1: First-time setup\n\n```\nUser: go ham\n\nAgent: HAM setup complete. Created 8 files.\n  - CLAUDE.md (root)\n  - .memory\u002Fdecisions.md\n  - .memory\u002Fpatterns.md\n  - .memory\u002Finbox.md\n  - src\u002Fapi\u002FCLAUDE.md\n  - src\u002Fcomponents\u002FCLAUDE.md\n  - src\u002Flib\u002FCLAUDE.md\n  - src\u002Futils\u002FCLAUDE.md\n\nBaseline captured in .memory\u002Fbaseline.json\nRun \"HAM savings\" to see your token and cost savings.\n```\n\n### Example 2: Checking savings\n\n```\nUser: ham savings\n\nAgent:\n  Before HAM: ~7,500 tokens\u002Fprompt\n  After HAM:    ~450 tokens\u002Fprompt\n  Savings:    7,050 tokens (94%)\n\n  Monthly projection (1,500 prompts):\n    Sonnet: ~$31.73 saved\n    Opus:   ~$158.63 saved\n```\n\n## Best Practices\n\n- Keep root CLAUDE.md under 60 lines \u002F 250 tokens\n- Keep subdirectory CLAUDE.md files under 75 lines each\n- Run `ham audit` every 2 weeks to catch stale or missing context files\n- Use `ham route` after adding new directories to keep routing current\n- Review `.memory\u002Finbox.md` periodically — confirm or reject inferred items\n\n## Limitations\n\n- Token estimates use ~4 chars = 1 token approximation, not a real tokenizer\n- Baseline savings comparisons are estimates based on typical agent behavior\n- Dashboard requires Node.js 18+ and reads session data from `~\u002F.claude\u002Fprojects\u002F`\n- Context routing detection relies on CLAUDE.md read order in session JSONL files\n- Does not auto-update subdirectory CLAUDE.md content — you maintain those manually or via `ham audit`\n- Carbon estimates use regional grid averages, not real-time energy data\n\n## Related Skills\n\n- `agent-memory-systems` — general agent memory architecture patterns\n- `agent-memory-mcp` — MCP-based memory integration\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,76,1448,"2026-05-16 13:21:46",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":25,"skillCount":32,"createdAt":26},"后端开发","backend","mdi-server","API、数据库、服务端架构",296,[34],{"id":35,"skillId":4,"version":36,"fileName":37,"fileSize":38,"filePath":39,"fileHash":40,"manifest":41,"createdAt":19},"64edc6ab-d725-4892-b486-1deaf12b3f85","1.0.0","hierarchical-agent-memory.zip",2128,"uploads\u002Fskills\u002F6464714d-4599-431c-9b8a-8c4ca1518f67\u002Fhierarchical-agent-memory.zip","d0abd8fa31f48443829ab35984f87b5603aadcf96783a33b08b0ddf17c0cf1a7","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":4662}]",{"code":43,"message":44,"data":45},200,"success",{"items":46,"stats":47,"page":50},[],{"averageRating":48,"totalRatings":48,"ratingCounts":49},0,[48,48,48,48,48],{"limit":51,"offset":48,"hasMore":52,"nextOffset":51,"ratedOnly":16},15,false]