| I built *CCQL*, a CLI tool that lets you run SQL queries directly against your Claude Code data (history, transcripts, prompts, sessions, etc.). If you use Claude Code regularly, you quickly accumulate a large amount of interaction data. CCQL makes that data queryable with SQL so you can analyze how you actually use the agent. *Examples* ```bash
# What tools does Claude use most?
ccql "SELECT tool_name, COUNT() AS uses
FROM transcripts
GROUP BY tool_name
ORDER BY uses DESC
LIMIT 10" # Find prompts mentioning a topic
ccql "SELECT display, timestamp
FROM history
WHERE display LIKE '%authentication%'" # Cross-session analysis
ccql "SELECT _session_id, COUNT()
FROM transcripts
GROUP BY _session_id"
``` *Built-in commands* ```bash
ccql prompts --session ses_123
ccql duplicates --threshold 0.8
ccql search "error"
``` *Interesting technical bit*
Claude Code stores its data in a structured local format. CCQL loads that data into an embedded SQL engine (GlueSQL) with a clean, read-first model, so you can safely explore usage patterns without mutating anything. *Features* * SQL queries across history, transcripts, prompts, sessions, and todos
* Fuzzy duplicate detection (find repeated or near-duplicate prompts)
* Full-text search with regex
* Safe writes with automatic backups
* Output formats: table, JSON, JSONL *Install* ```bash
# macOS
brew install douglance/tap/ccql # npm (any platform)
npx @douglance/ccql "SELECT * FROM history LIMIT 10" # Cargo
cargo install ccql
``` Built in Rust using GlueSQL. MIT licensed. GitHub: [https://github.com/douglance/ccql](https://github.com/douglance/ccql) I’ve been using this to understand my own Claude usage patterns—what prompts I repeat, which tools get called most, and how conversations evolve across sessions. Curious what queries others would find useful. |