memory-tree

Restructure flat markdown memory files into a hierarchical domain tree.

23|2|Updated Mar 11, 2026
One-click install
npx skills add https://github.com/felixsim/bonsai-memory --skill memory-tree
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: memory-tree
Source: https://github.com/felixsim/bonsai-memory/tree/main
Command: npx skills add https://github.com/felixsim/bonsai-memory --skill memory-tree

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and assets (resource) components.

What problem does it solve?

This Skill solves the problem of linear memory growth in AI agents, where loading a massive, flat memory file on every boot wastes tokens and degrades reasoning performance.

Core Features & Use Cases

  • Hierarchical Memory: Restructures flat memory files into a pruned tree of domains and topic-specific leaves.
  • Automated Maintenance: Includes cron-ready scripts for reindexing, health monitoring, and stale entry cleanup.
  • Use Case: An agent managing a complex business project can use this to load only the relevant domain branch (e.g., 'Infrastructure') instead of the entire multi-month history, drastically reducing API costs and latency.

Quick Start

Ask your agent to restructure your memory using the bonsai-memory skill to immediately optimize your context window.

Frequently Asked Questions about memory-tree

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce token usage when my AI agent loads a large markdown memory file on boot?

Restructuring flat markdown memory files into a hierarchical domain-based tree reduces token usage by loading only relevant branches. This optimization minimizes API overhead and prevents linear memory growth from degrading agent reasoning performance.

What is the best way to organize persistent agent memory to avoid context window bloat?

Organizing persistent agent memory into a pruned tree of domains and topic-specific leaves prevents context window bloat. This hierarchical structure allows agents to load specific domain branches instead of the entire history, drastically reducing latency.

Can I automate the reindexing and cleanup of markdown memory files for my agent?

Yes, you can automate memory file maintenance using cron-ready shell scripts for reindexing, health monitoring, and stale entry cleanup. These lifecycle scripts maintain the hierarchical memory structure automatically without manual intervention.

How does deterministic keyword-based classification work for organizing agent memory?

Deterministic keyword-based classification assigns memory entries to specific domains and topic leaves based on predefined keywords. This automated classification maintains the hierarchical tree structure and ensures efficient context management for the agent.

Does this hierarchical memory optimization approach work for complex, long-term business projects?

Yes, hierarchical memory optimization is suited for complex business projects spanning multiple months. Agents can load only the relevant domain branch, such as Infrastructure, instead of the entire multi-month history, drastically reducing API costs and latency.

When should I restructure flat memory files into a hierarchical tree structure?

You should restructure flat memory files when linear memory growth starts wasting tokens on every boot and degrading reasoning performance. If your agent manages persistent memory and experiences high API overhead, hierarchical pruning is necessary.