| Layer | What |
|---|---|
| Messages | Every prompt, response, tool call — full fidelity, no truncation |
| Tool operations | Every Read, Write, Edit, Bash — tool name, target file, cwd |
| Delegations | Which agents spawned which, in what order |
| Classification | Message type, role, and threading — so Claude can filter by what you said vs what it said |
| File identity | Permanent ID for every file — survives renames, moves, repo migrations |
| Repo identity | Git root commit hash — survives repo moves |
~/.claude/projects/**/*.jsonl
↓
[worker] watches for new sessions every 2s, indexes changes automatically
↓
[MCP] exposes database as read-only SQL
The worker scans session files every 2 seconds. When a file grows, it parses the new content, embeds, and writes to the database. Crash-safe: idempotent inserts, startup backfill recovers missed sessions.
The worker runs a full enrichment cycle every 30 minutes:
| Layer | What it produces |
|---|---|
| Session importance | Which sessions matter most, which connect the most ideas |
| File graph | File co-edit relationships across sessions |
| Agent tracking | Which agents spawned which, in what order |
| Fingerprints | Session summaries — key decisions, tool patterns |
| Project attribution | Maps sessions to repos automatically |
All enrichment is safe to wipe. Recomputed automatically.
Views compose raw tables into a flat surface Claude queries directly. When Claude reads the schema, it sees:
| View | What it shows |
|---|---|
chunks | Every chunk (messages + file bodies). Type is a column. Default for semantic search. |
messages | Message-specific columns — tool ops, delegations, file identity. |
sessions | Every session with project, importance scores, session clusters, fingerprints. |
Claude writes WHERE is_hub = 1 like it's a column that always existed. The views handle the joins and noise filtering.
Views are plain .sql files at ~/.flex/views/claude_code/. Edit them to change what Claude sees. Your copy takes precedence over defaults. Run flex sync to install.
Flex tracks files through renames, moves, and repo migrations using permanent IDs. When you ask "what's the history of auth.py?", Claude finds every session that touched it — even if the file was renamed three times.
Four identity layers:
| Layer | What it tracks | Survives |
|---|---|---|
| File | Permanent ID per file | Renames, moves, repo migrations |
| Repo | Git root commit hash | Repo moves, worktree deletion |
| Content | SHA-256 of file content | Path changes, branch switches |
| URL | Permanent ID per URL | Normalization differences |
Identity is resolved at capture time and persists forever. A heal cycle runs every 24 hours to backfill any gaps.
# every session that touched a file, across all renames
$ flex search "@file path=src/auth.py"
# or just ask Claude
"Use flex: what's the history of auth.py?"
Named queries that ship with Flex. Discovered automatically when Claude reads the schema — it uses them when they fit.
@orient read the database — schema, queries, presets
@health pipeline freshness, embedding coverage
@digest multi-day activity summary
@sprints work periods detected by 6h gaps
@story session narrative — timeline, artifacts, agents
@file every session that touched a file, across renames
@genealogy concept lineage — key sessions, key excerpts
@delegation-tree recursive agent tree
@bridges sessions that connect different areas of work