From claude-warehouse
Run raw SQL queries against the Claude Code DuckDB warehouse. Use when you need precise, structured lookups across sessions, messages, tool calls, hook events, or research history that go beyond simple text search.
How this skill is triggered — by the user, by Claude, or both
Slash command
/claude-warehouse:queryThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Run arbitrary SQL against the local DuckDB warehouse containing all Claude Code session data.
Run arbitrary SQL against the local DuckDB warehouse containing all Claude Code session data.
${CLAUDE_PLUGIN_ROOT}/scripts/query.py sql "$ARGUMENTS"
sessions — One row per session
session_id (PK), project_path, project_name, git_branch, version, cwdcreated_at (TIMESTAMP), modified_at (TIMESTAMP), message_counttotal_input_tokens, total_output_tokens, total_cache_read, total_cache_writetools_used (JSON array), models_used (JSON array)first_prompt, file_pathis_subagent, parent_session_idmessages — Individual turns from session JSONL
session_id, uuid (PK with session_id), parent_uuid, type, timestamp (TIMESTAMP)is_sidechain, role, model, stop_reasoninput_tokens, output_tokens, cache_read_tokens, cache_write_tokenscontent_types (JSON), tool_name, tool_input_summary, text_contentcreated_at column — use timestamp or JOIN to sessionstool_calls — Extracted tool invocations
session_id, message_uuid (FK → messages.uuid), tool_name, tool_input, timestamp (TIMESTAMP), idxcreated_at column — use timestamp or JOIN to sessionshook_events — Hook event logs
id, event_type, session_id, timestamp, cwd, tool_name, tool_input, file_pathresearch_history — Research/review artifacts
file_path, category, agent, timestamp, description, contentembeddings — Vector embeddings for semantic search
source_type ('message'|'session'|'research'), source_id, chunk_idx, text_preview, embedding (FLOAT[384])session_id:uuid for messages, session_id for sessions, file_path for researchdeleted_sessions — Metadata from removed sessions
session_id, project_path, project_name, git_branch, created_at, modified_at, message_count, first_prompt, summarysessions.session_id ←→ messages.session_id
sessions.session_id ←→ tool_calls.session_id
messages.uuid ←→ tool_calls.message_uuid (NOT message_id)
Ambiguous columns: tool_name exists in BOTH messages and tool_calls — always qualify with table alias (e.g., tc.tool_name).
Token usage last 7 days:
SELECT project_name, COUNT(*) sessions, SUM(total_input_tokens + total_output_tokens) total FROM sessions WHERE created_at >= current_date - INTERVAL '7 days' GROUP BY 1 ORDER BY total DESC
Most used tools:
SELECT tool_name, COUNT(*) calls FROM tool_calls WHERE timestamp >= current_date - INTERVAL '7 days' GROUP BY 1 ORDER BY 2 DESC LIMIT 20
Sessions for a project:
SELECT session_id, created_at, message_count, first_prompt FROM sessions WHERE project_name ILIKE '%kafka%' ORDER BY created_at DESC LIMIT 10
npx claudepluginhub sderosiaux/claude-plugins --plugin claude-warehouseQuery Claude Code session history for IDs, durations, tokens consumed, tool usage patterns, errors, permissions, and search past conversations by keyword or project. Use for usage introspection like 'tokens today' or 'find setup X'.
Queries Claude Code and Codex CLI history joined with Git commits using SQL to analyze productivity patterns, session insights, commit correlations, and tool usage.
Reads and searches OpenCode session logs from the SQLite DB. Use to review past session activity, assess AI work, diagnose session wipes, recover after migration resets.