Skip to content
Wallace Ricardo edited this page Jun 3, 2026 · 2 revisions

FTS5 Search

claude-code-graphql uses SQLite's FTS5 extension for full-text search across all hook data.

Search is one of the most useful session-intelligence features: it lets you find past prompts, commands, tool outputs, file paths, database table names, endpoint paths, errors, ticket IDs, and feature names across Claude Code history.

What gets indexed

Three columns are indexed per hook:

Column Content
prompt User prompt text (UserPromptSubmit events)
tool_input JSON input sent to the tool
tool_response JSON response from the tool (stdout, stderr, file content, etc.)

The hook_id column is stored but not indexed (UNINDEXED), used to join results back to the hooks table.

How sync works

An AFTER INSERT trigger on the hooks table keeps the FTS5 index up to date automatically. On server startup, any existing hooks not yet indexed are backfilled.

Match field detection

Search results include a matchField indicating which column matched:

  • prompt — the match was in the user's message text
  • toolInput — the match was in a tool's input (command, file path, pattern, etc.)
  • toolResponse — the match was in a tool's output (stdout, file content, grep results, etc.)

This is determined by running per-column snippet() calls and checking which one contains highlight markers.

Snippet format

Snippets include >>> and <<< markers around matched terms:

"...ran >>>go build<<< and got compilation errors..."

Session-intelligence examples

Find sessions where a feature came up:

{
  search(query: "webhook", limit: 10) {
    matchField
    snippet
    hook { sessionId recordedAt eventType toolName cwd }
  }
}

Find work in a specific repo:

{
  search(query: "TrackDrive", cwd: "/path/to/project", limit: 10) {
    matchField
    snippet
    hook { sessionId recordedAt toolName }
  }
}

Find commands or errors:

{
  search(query: "go build" , limit: 10) {
    snippet
    hook { sessionId toolName recordedAt }
  }
}

Limitations

  • FTS5 tokenization: partial word matches may not work (search build, not buil)
  • Searches are case-insensitive
  • Very long tool responses (source code files) are indexed in full — use specific queries to avoid noise

Clone this wiki locally