memory-system

Tiered, low-token project memory protocol for .toh/memory/ โ€” 7 files across 3 tiers (Tier 1 active.md + summary.md always read, ~800 tokens; Tier 2 architecture/components for build work and changelog

SKILL.md

GitHub

๐Ÿง  Memory System Skill

Purpose: Tiered, low-token memory โ€” load only what the task needs, save what matters Version: 2.0.0 For: Toh Framework v2.0.0+ Updated: 2026-07-14


Overview

Automatic memory that keeps AI in context across sessions with zero user effort. v2 replaces the old "read all files every time" mandate with tiered loading: Tier 1 is always read (~800 tokens), Tier 2 is read only for the relevant task type, Tier 3 only when explicitly referenced.

Key principles

  • โœ… Zero config โ€” no setup required
  • โœ… Tiered โ€” Tier 1 always; Tier 2/3 on demand (no more ~3,000 tokens every time)
  • โœ… Auto save โ€” saves after task completion, never asks the user
  • โœ… Delegated agents don't re-read โ€” they receive context from the orchestrator
  • โœ… IDE & model agnostic

๐Ÿ“š The Tiered Model (use this everywhere)

There are 7 memory files across 3 tiers. Read by tier, not all at once.

Tier Files When to read Budget
Tier 1 active.md + summary.md ALWAYS, at every session start ~800 tokens
Tier 2 architecture.md + components.md Build / code work (creating pages, components, logic) ~600 tokens
Tier 2 changelog.md Debug work (to see previous attempts) ~400 tokens
Tier 3 decisions.md + agents-log.md Only when explicitly referenced / asked about on demand

This replaces the old "read ALL files (MANDATORY)" rule. Never bulk-read all 7. Read Tier 1 always, add the Tier 2 files that match the task type, and touch Tier 3 only when needed.

Delegated agents: an agent invoked by the orchestrator receives context from the orchestrator and does NOT re-read memory itself. This avoids every agent re-reading the same files.


๐Ÿ“ Directory Structure

.toh/
โ”œโ”€โ”€ config.json              # Toh configuration
โ””โ”€โ”€ memory/
    โ”œโ”€โ”€ active.md            # ๐Ÿ”ฅ Tier 1 โ€” current task (~300 tokens)
    โ”œโ”€โ”€ summary.md           # ๐Ÿ“‹ Tier 1 โ€” project shape (~500 tokens)
    โ”œโ”€โ”€ architecture.md      # ๐Ÿ—๏ธ Tier 2 โ€” structure (build/code work)
    โ”œโ”€โ”€ components.md        # ๐Ÿ“ฆ Tier 2 โ€” component registry (build/code work)
    โ”œโ”€โ”€ changelog.md         # ๐Ÿ“ Tier 2 โ€” change/attempt log (debug work)
    โ”œโ”€โ”€ decisions.md         # ๐Ÿง  Tier 3 โ€” key decisions (when referenced)
    โ”œโ”€โ”€ agents-log.md        # ๐Ÿค– Tier 3 โ€” agent activity (when referenced)
    โ””โ”€โ”€ archive/             # ๐Ÿ“ฆ Historical โ€” load only when asked

agents-log.md stays a separate file โ€” it is NOT merged into changelog.md.


๐Ÿ”„ Read Protocol (session start)

STEP 1 โ€” Ensure memory exists
        .toh/memory/ exists? โ†’ continue ยท missing? โ†’ create from templates

STEP 2 โ€” Read Tier 1 (ALWAYS, in parallel)
        โ”œโ”€โ”€ active.md    โ†’ what we're working on
        โ””โ”€โ”€ summary.md   โ†’ what this project is
        Budget: ~800 tokens.

STEP 3 โ€” Add Tier 2 by task type
        โ”œโ”€โ”€ Build / code (create page, component, logic)
        โ”‚     โ†’ also read architecture.md + components.md
        โ””โ”€โ”€ Debug (fix a bug)
              โ†’ also read changelog.md (see prior attempts)

STEP 4 โ€” Tier 3 only if referenced
        User asks "why did we decide X?"  โ†’ read decisions.md
        User asks about past agent runs    โ†’ read agents-log.md

STEP 5 โ€” Acknowledge briefly
        "Memory loaded ๐Ÿ“š โ€” working on [X]. Just completed [Y]. Ready to continue."

Do not read archive/ during normal work โ€” only when the user asks about past work or runs a history command.


๐Ÿ’พ Save Protocol (after completing work)

STEP 1 โ€” active.md            โ†’ ALWAYS update (current focus, in-progress, next steps)
STEP 2 โ€” summary.md           โ†’ update when the PROJECT SHAPE changes
                                 (feature completed, tech/stack change, new major area)
STEP 3 โ€” architecture.md      โ†’ update if structure changed (new route/module/service, data flow)
STEP 4 โ€” components.md         โ†’ update if components/hooks/stores/utils changed
STEP 5 โ€” changelog.md         โ†’ append what changed / what was attempted (esp. debug work)
STEP 6 โ€” decisions.md         โ†’ add row only if a real decision was made
STEP 7 โ€” agents-log.md        โ†’ append if agents were delegated
STEP 8 โ€” Confirm: "โœ… Memory saved"

Write rules: always update active.md; update summary.md when the project shape changes; update the rest only when relevant to what actually happened. Keep entries concise (1-2 lines). If active.md grows past ~50 lines, roll older content into archive/YYYY-MM-DD.md.


๐Ÿ—‚๏ธ File Reference

File Tier Holds Update when
active.md 1 Current focus, in-progress, next steps Always
summary.md 1 Project name, stack, completed features Project shape changes
architecture.md 2 Entry points, modules, data flow, services Structure changes
components.md 2 Pages, components, hooks, stores, utils registry Components change
changelog.md 2 Chronological change & debug-attempt log Every notable change
decisions.md 3 Date ยท Decision ยท Reason table A real decision is made
agents-log.md 3 Which agent did what, when Agents are delegated

๐Ÿ“ Templates

active.md (Tier 1)

# ๐Ÿ”ฅ Active Task
## Current Focus
[Awaiting user instructions]
## In Progress
- (none)
## Next Steps
- (awaiting)
---
*Last updated: YYYY-MM-DD*

summary.md (Tier 1)

# ๐Ÿ“‹ Project Summary
## Overview
- Name: [Project]
- Stack: Next.js 16, Tailwind, shadcn/ui, Zustand, Supabase
## Completed Features
- (none yet)
---
*Last updated: YYYY-MM-DD*

changelog.md (Tier 2 โ€” debug)

# ๐Ÿ“ Changelog
| Date | Change / Attempt | Result |
|------|------------------|--------|
| YYYY-MM-DD | [what changed or was tried] | [worked / failed because โ€ฆ] |
---
*Last updated: YYYY-MM-DD*

agents-log.md (Tier 3)

# ๐Ÿค– Agents Log
| Date | Agent | Task | Outcome |
|------|-------|------|---------|
| YYYY-MM-DD | [agent] | [task] | [result] |
---
*Last updated: YYYY-MM-DD*

architecture.md, components.md, and decisions.md keep their existing table structures (entry points/modules, component registry, decision log).


โš ๏ธ Anti-Patterns

โŒ Don't โœ… Do
Bulk-read all 7 files every time Read Tier 1 always; Tier 2/3 by need
Make delegated agents re-read memory Pass context from the orchestrator
Read archive/ during normal work Only when the user asks about the past
Forget to save Always update active.md after a task
Ask the user whether to save Save automatically
Merge agents-log into changelog Keep the 7 files distinct

๐Ÿ”— Integration

Every command applies this protocol: read Tier 1 at start, add Tier 2 for the task type, save active.md (+ relevant files) at the end. Delegated agents receive context and skip the re-read.


Memory System v2.0.0 โ€” tiered loading, ~800-token Tier 1, 7 files across 3 tiers