agentleFS
koteitankoteitan/my-skills/skills/sessiondb/SKILL.md

sessiondb

Skill1 starsChanged 3 months agoMITView on GitHub

Index Claude Code session JSONL logs into a SQLite + FTS5 database with Japanese-aware tokenization, and search them

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Do not invoke for lookups inside the current session — use Read/Grep.

    line 18
  2. Very specific:

    If bin/sessiondb is not installed, fall back to invoking sqlite3 directly:

    line 40

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

sessiondb

Full-text search over past Claude Code sessions stored as JSONL in ~/.claude/projects/.

When to invoke

  • User wants to find a past session by topic or keyword ("あの話どこでしたっけ", "find the session about X").
  • User asks to (re)build or update the session index.
  • User asks aggregate stats about session history that would be slow with grep.

Do not invoke for lookups inside the current session — use Read/Grep.

Database location

~/.claude/sessiondb/sessions.db (override with env var SESSIONDB_PATH).

CLI

sessiondb index                       # incremental rebuild
sessiondb index --full                # drop and rebuild from scratch
sessiondb search "<query>" --format=jsonl [--project P] [--role R] [--limit N]
sessiondb search                      # query 省略 = セッション一覧 (新しい順)
sessiondb stats                       # content totals (sum of source JSONL bytes)
sessiondb size [--format=json]        # on-disk DB usage (.db + WAL/SHM + page stats)
sessiondb show <session_id> [--line L] [--context K]

重要: エージェントが呼ぶときは必ず --format=jsonl を付ける。CLI の 既定は --format=table (人間向け TSV) なので、明示しないと下記の JSON Lines 形式は得られない。

If bin/sessiondb is not installed, fall back to invoking sqlite3 directly:

SELECT m.session_id,
       snippet(messages_fts, 0, '<b>', '</b>', '…', 32) AS snippet,
       bm25(messages_fts) AS score,
       m.ts, m.role, m.source_path, m.line_no
  FROM messages_fts JOIN messages m ON m.id = messages_fts.rowid
  WHERE messages_fts MATCH :query
  ORDER BY score LIMIT 20;

Response format (search)

JSON Lines, one hit per line, followed by a summary line:

{"session_id":"…","project":"…","ts":"…","role":"…","snippet":"…","score":-4.21,"source_path":"…","line_no":142,"resume":"claude --resume …"}
{"_summary":{"hits":17,"shown":10,"query":"…","ms":34}}

--format=table (CLI 既定) is TSV for human reading; do not parse from agent.

Build / schema / ingest details

See how-to-create-db.md. Read it only when you need to implement, modify, or debug the indexer; not on every search.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.