Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/coleam00/claude-memory-compiler/llms.txt

Use this file to discover all available pages before exploring further.

compile.py is the core of the system — the “LLM compiler” that reads your daily conversation logs (the raw source material in daily/) and produces organized, cross-referenced knowledge articles in knowledge/. Each compilation run calls the Claude Agent SDK with file-access tools, letting Claude read your logs and write concept articles, connection articles, and index entries directly to disk. You can run it manually at any time or let the end-of-day automation handle it.

CLI commands

# Compile only new or changed daily logs
uv run python scripts/compile.py

Incremental compilation

By default, compile.py skips daily logs that have not changed since their last compilation. It tracks each log’s state in scripts/state.json using SHA-256 hashes:
def file_hash(path: Path) -> str:
    """SHA-256 hash of a file (first 16 hex chars)."""
    return hashlib.sha256(path.read_bytes()).hexdigest()[:16]
Before compiling, the script compares the current hash of each daily log against the stored hash:
prev = state.get("ingested", {}).get(rel, {})
if not prev or prev.get("hash") != file_hash(log_path):
    to_compile.append(log_path)
If the hashes match, the log is skipped entirely. If they differ (because you had more sessions that day and flush.py appended new entries), the log is recompiled. After a successful compilation, state.json is updated with the new hash, a timestamp, and the API cost.

End-of-day auto-compilation

You do not need to remember to run compile.py. After 6 PM local time, flush.py checks whether today’s daily log has changed since its last compilation and, if so, spawns compile.py as another detached background process:
COMPILE_AFTER_HOUR = 18  # 6 PM local time

def maybe_trigger_compilation() -> None:
    """If it's past the compile hour and today's log hasn't been compiled, run compile.py."""
    now = datetime.now(timezone.utc).astimezone()
    if now.hour < COMPILE_AFTER_HOUR:
        return
    # ... hash comparison against state.json ...
    logging.info("End-of-day compilation triggered (after %d:00)", COMPILE_AFTER_HOUR)
This means compilation happens automatically once a day — no cron job, no scheduler, no manual trigger required. The first session you close after 6 PM triggers compilation of that day’s log.

What the compiler produces

Each compilation run may create or update several files. Claude reads the entire AGENTS.md schema, the current knowledge/index.md, all existing articles, and the target daily log, then decides what to write:
  • New concept articles in knowledge/concepts/ — one .md file per atomic piece of knowledge (decisions, patterns, gotchas, lessons learned). A single daily log typically produces 3–10 concept articles.
  • Connection articles in knowledge/connections/ — created when the log reveals a non-obvious relationship between two or more existing concepts.
  • Updated concept articles — existing articles are enriched with new information from the log rather than duplicated; the source list in the frontmatter is extended.
  • knowledge/index.md updates — new rows are added to the master catalog table for each new or updated article.
  • knowledge/log.md appends — a timestamped entry is added recording what was compiled, which articles were created or updated, and from which source log.
The Claude Agent SDK is configured with permission_mode="acceptEdits" so all file writes are accepted automatically without prompts.
Use --dry-run before running a full --all recompile. It prints the list of files that would be processed without making any API calls or incurring any cost. This is useful for verifying your daily log paths are correct and for estimating how many logs are queued.

Build docs developers (and LLMs) love