{"id":49172503,"url":"https://github.com/technicalpickles/cq","last_synced_at":"2026-06-04T11:01:17.922Z","repository":{"id":351794530,"uuid":"1210400604","full_name":"technicalpickles/cq","owner":"technicalpickles","description":"Query AI agent session transcripts with SQL. Built on DuckDB.","archived":false,"fork":false,"pushed_at":"2026-04-22T21:18:03.000Z","size":304,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-09T03:07:38.799Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/technicalpickles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-14T11:33:01.000Z","updated_at":"2026-04-29T04:51:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/technicalpickles/cq","commit_stats":null,"previous_names":["technicalpickles/cq"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/technicalpickles/cq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalpickles%2Fcq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalpickles%2Fcq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalpickles%2Fcq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalpickles%2Fcq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/technicalpickles","download_url":"https://codeload.github.com/technicalpickles/cq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalpickles%2Fcq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33901305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-04T02:00:06.755Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-22T20:00:44.288Z","updated_at":"2026-06-04T11:01:17.878Z","avatar_url":"https://github.com/technicalpickles.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# cq\n\n**INT. TERMINAL**\n\nHundreds of Claude Code sessions. Thousands of tool calls.\nYou've never looked at the logs.\n\n```\n$ cq tools\nRead             ██████████████████████████████  1847\nBash             ████████████████████████████    1623\nEdit             ███████████████                  982\nWrite            █████                            341\nGrep             ████                             298\n```\n\n*1600 Bash calls. What am I even running?*\n\n**TIGHT ON** the commands.\n\n```\n$ cq tools Bash --fields command --limit 5\nc82e9d4c  Bash  cargo test\nc82e9d4c  Bash  git diff --stat\nbfc27bd2  Bash  docker compose up -d\nbfc27bd2  Bash  git commit -m \"fix: resolve session timeout\"\na1f3e890  Bash  psql -c \"SELECT count(*) FROM users\"\n```\n\n*Wait, I set up a git commit skill for that. Is it even firing? The commits would still go through Bash either way...*\n\n**CUT TO** Claude, investigating a hunch.\n\n```\n$ cq sql \"\nWITH commit_sessions AS (\n  SELECT DISTINCT session_id FROM tool_calls\n  WHERE name = 'Bash'\n    AND json_extract_string(input, '$.command') LIKE '%git commit%'\n),\nskill_sessions AS (\n  SELECT DISTINCT session_id FROM tool_calls\n  WHERE name = 'Skill'\n    AND json_extract_string(input, '$.skill') LIKE '%commit%'\n)\nSELECT\n  (SELECT count(*) FROM commit_sessions) as total_sessions,\n  (SELECT count(*) FROM skill_sessions) as used_skill,\n  (SELECT count(*) FROM commit_sessions)\n    - (SELECT count(*) FROM skill_sessions) as bypassed\n\" --since 7d\n```\n\n```\ntotal_sessions  used_skill  bypassed\n──────────────  ──────────  ────────\n           168          16       152\n```\n\n**152 sessions. The skill was right there. Nobody called it.**\n\n---\n\n**TITLE CARD:** SQL for your Claude Code sessions.\n\ncq indexes Claude Code's JSONL session transcripts into a local [DuckDB](https://duckdb.org/) cache at `~/.cache/cq/` and gives you SQL views to query against. Incremental sync keeps it fresh on each run, so you only pay the full-parse cost once. Built-in commands handle the common stuff, and `cq sql` lets you run whatever you want.\n\n## Install\n\nRequires [Rust](https://rustup.rs/).\n\n```bash\ncargo install --git https://github.com/technicalpickles/cq\n```\n\n## Quick start\n\n```bash\ncq sessions                              # your recent sessions\ncq tools                                 # tool usage, ranked\ncq messages --grep \"docker\" --since 7d   # search your history\ncq sql \"SELECT count(*) FROM messages\"   # run anything\n```\n\nRun `cq schema --examples` for a query cookbook.\n\n## Common flags\n\n| Flag | Short | Description |\n|------|-------|-------------|\n| `--project \u003cname\u003e` | `-p` | Scope to a project (substring match) |\n| `--session \u003cid\u003e` | `-s` | Scope to a session (UUID prefix match) |\n| `--since \u003cduration\u003e` | | Time filter: `7d`, `24h`, `30m` |\n| `--all` | | Show all projects (disable auto-scoping) |\n| `--json` | | JSON output instead of tables |\n| `--table` | | Aligned table with headers |\n| `--no-color` | | Disable colored output |\n| `--limit \u003cn\u003e` | | Max results (default: 50, 0 for unlimited) |\n| `--offset \u003cn\u003e` | | Skip first N results |\n| `-A N` | | Show N messages after each match (messages, tools) |\n| `-B N` | | Show N messages before each match (messages, tools) |\n| `-C N` | | Shorthand for `-A N -B N` (messages, tools) |\n\n## Views\n\nFour SQL views, all queryable with `cq sql`:\n\n- **sessions** - one row per session with timestamps, message counts, tool counts (main-loop only), plus a `subagent_count`\n- **messages** - one row per conversation turn (user or assistant)\n- **tool_calls** - one row per tool invocation, with input as queryable JSON\n- **tool_results** - one row per tool response, with an error flag\n\nSubagent activity is indexed too: `messages`, `tool_calls`, and `tool_results` carry `is_sidechain`, `agent_id`, `agent_type`, and `workflow_id` so you can include, exclude, or focus subagents. `cq sessions` stays main-loop-only.\n\nRun `cq schema` for full column details.\n\n## Use cases\n\nFor deeper examples of what you can dig up, see [docs/use-cases.md](docs/use-cases.md). Skill activation gaps, silent failures that look fine from the outside, context budget analysis across tool calls.\n\n## Use with Claude Code\n\ncq ships a Claude Code plugin that teaches Claude when and how to query your session history. Install it from the [`pickled-claude-plugins`](https://github.com/technicalpickles/pickled-claude-plugins) marketplace and Claude will reach for cq automatically when you ask about past sessions.\n\nSee [`claude-plugin/README.md`](claude-plugin/README.md) for details.\n\n## For agents\n\n`cq schema` and `cq schema --examples` are designed to be consumed by AI agents building their own queries. Pair with `--json` for machine-readable output.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnicalpickles%2Fcq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechnicalpickles%2Fcq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnicalpickles%2Fcq/lists"}