Skip to content

Memory

This page mirrors implementation notes maintained in CLAUDE.md. Update both when changing this subsystem.

memory.md is a long-term user profile that Opus maintains. It's small (under 300 words, bullet-point), updated periodically from the rolling digest history, and injected into the suggestion prompt so Cue's three suggestions know who you are over time.

Data flow

graph LR
    Digests[(digests<br/>SQLite rolling timeseries)]
    MemoryMd[(memory.md<br/>plain text)]
    Opus[Claude Opus]
    Suggest[cue.suggest<br/>hotkey path]

    Digests -->|every N digests| Opus
    MemoryMd -->|current_memory| Opus
    Opus -->|rewritten profile| Scrub[pii.scrub]
    Scrub --> MemoryMd
    MemoryMd -->|memory dump| Suggest

cue.memory._compute_memory():

  1. Loads the current memory.md (empty on first run).
  2. Pulls the most recent N digest summaries from SQLite.
  3. Calls Opus with prompts.MEMORY_TEMPLATE.format(current_memory=..., digests=...).
  4. Scrubs the returned text via cue.pii.scrub().
  5. Writes atomically back to memory.md.

The prompt

The full template is rendered on the Prompts page. Highlights:

  • Append-style update, not replacement. Existing patterns fade if recent digests don't support them, but they're not removed immediately.
  • Captures: frequently used apps/tools, typical work patterns, recurring preferences, notable habits.
  • Output: under 300 words, bullet-point format, in Korean, profile text only (no explanations).

When it runs

The memory updater runs on the streaming recorder's digest cadence — every N digests, configurable via streaming.memory_every_digests. Defaults assume the user has at least a few digests of accumulated narrative before Opus is asked to rewrite.

Boot-time backfill

If _meta.scrub_version (in SQLite) is older than the current pii_recognizers.CURRENT_SCRUB_VERSION, memory.maybe_backfill_memory() re-scrubs memory.md in place at startup. Same idea for the SQL digests.summary rows via store.backfill_scrub(). Versioned so it runs exactly once per scrub-version bump.

RAG injection point

The hotkey path appends memory.md to the suggestion prompt under the SUGGEST_MEMORY_LABEL ("사용자 프로필 (장기 메모리):") heading. Opus sees the same profile every hotkey press until the next digest tick rewrites it.

Privacy posture

  • The memory text is post-scrub — no PII reaches Opus on rewrite, no PII reaches Opus on the suggestion path.
  • Image bytes are never written to memory.md.
  • memory.md is in the data root with the same permissions as the rest of Cue's data (POSIX 0o700 dir / 0o600 file on Unix).

See also

  • cue.memory — module reference (a full cue.memory reference page is on the deferred list).
  • PromptsMEMORY_TEMPLATE rendered.
  • Digest pipeline — what feeds the memory updater.