hierarchical-agent-memory
Lets your agent manage memory efficiently, saving tokens. It creates context files and directs the agent to the right information.
What it does
This tool helps organize a computer program's memory. It creates information 'cheat sheets' for each part of the project instead of making the program re-read everything. This saves time and resources.
When to use it
- ✓When you have a large project with many folders.
- ✓When you want the program to use less 'memory' (tokens) for each task.
- ✓When you want to see a summary of how much time and money is being saved.
Example of what to ask your AI
“Set up memory for my project.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
It creates 'context' files for each folder in your project. A main file holds general information, and others hold specific details for each part. A dashboard shows how much you are saving.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill hierarchical-agent-memoryOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/hierarchical-agent-memory/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from 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 auditevery 2 weeks to catch stale or missing context files - Use
ham routeafter adding new directories to keep routing current - Review
.memory/inbox.mdperiodically — 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 patternsagent-memory-mcp— MCP-based memory integration
FAQ
What are 'tokens'?
Tokens are like small pieces of text that the computer program understands. The more tokens it uses, the more it costs.
What is CLAUDE.md?
It's a file where the program stores important project information, like instructions or descriptions.
Does the dashboard show real-time information?
The dashboard shows estimates based on usage and saved data. It helps visualize progress and costs.
Details
Original description by the author
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.
Popularity
- GitHub stars
- 48k
- Ranking position
- #3195
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
agent-architecture-audit
Makes your agent check if everything is working correctly. It finds and fixes problems in AI systems, ensuring they perform as expected.
affaan-m/ECC
agent-eval
Helps your agent compare different AI coding tools. It measures which one is faster, cheaper, and more reliable for specific tasks.
affaan-m/ECC
agent-harness-construction
Makes your agent better understand how to perform tasks. It optimizes the tools and instructions the agent uses to increase its chances of success.
affaan-m/ECC