[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ASNKNVKP7YBJPVBGGY9EA6":3,"skill-same:01M7ASNKNVKP7YBJPVBGGY9EA6":66},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7ASNKNVKP7YBJPVBGGY9EA6","reflect",null,"Query Claude Code conversation history and session data using SQL. Use when analyzing past conversations, token usage, tool patterns, agent activity, or extracting insights from session logs. Triggers on requests about session history, conversation analysis, usage statistics, periodic reviews over a week\u002Fmonth\u002Fquarter, or cc-query.","ozzycodes2\u002Fclaudellum","ozzycodes2","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F21285094?v=4","01M7ASJ57KTP519F96S4QGM7C5","Osniel Quintana","01M7ASJ589JS8S075AA92Y08S4",1,"MIT","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Fsession-improv\u002Fskills\u002Freflect\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: reflect\ndescription: Query Claude Code conversation history and session data using SQL. Use when analyzing past conversations, token usage, tool patterns, agent activity, or extracting insights from session logs. Triggers on requests about session history, conversation analysis, usage statistics, periodic reviews over a week\u002Fmonth\u002Fquarter, or cc-query.\ncontext: fork\nallowed-tools: Bash, Read\n---\n\n# Querying Session Data\n\nUse `${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query` to analyze Claude Code sessions with SQL (DuckDB).\n\n## Reviewing a span of time — REQUIRED slots\n\nApplies whenever the request names a period rather than one session: \"the last\n30 days\", \"this week\", \"this quarter\".\n\n**Read [period-review.md](period-review.md) before querying.** It carries the\ntested queries, the per-finding schema, the guards, and the traps that have\nproduced wrong conclusions here before. The slots below are the index.\n\nFour layers. Thirteen slots. Fill them all, or report a layer as *not\napplicable* and say why.\n\n**A — Measure** (transcripts, SQL)\nA1 window and volume, date range first · A2 where the work went · A3 tool\npatterns **with output chars**, ranked by cost not call count · A4 skill\nutilization from `~\u002F.claude.json` `skillUsage`, naming those **never invoked** ·\nA5 plugin and MCP utilization against `enabledPlugins` · A6 navigation mix,\n`LSP` vs. `Grep`\u002F`Glob` vs. text search through Bash.\n\n**B — Interpret** (causal; `Why` is mandatory in each)\nB1 worked · B2 friction, including *what to try instead* · B3 learned ·\nB4 corrections and interrupts, precise and upper-bound counts labeled\nseparately, recurring ones quoted verbatim.\n\n**C — Audit the instruction surface** (files on disk, `git blame`)\nC1 findings in `CLAUDE.md`, `AGENTS.md`, `SKILL.md`, rule files, commands,\nhooks — unenforced instructions, recency traps, contradictions, volatile\nspecifics, fossils. Each with `file:line` and quoted evidence. Never read\n`settings*.json` or `.mcp.json` whole; they can hold secrets — `jq` named keys.\n\n**D — Actions**\nD1 prioritized actions, ordered by confidence, each with observation, why it\nmatters, confidence, action, and quantified cost only where the data supports\nit · D2 measurement limits, stated **before** any recommendation rests on them.\n\nPropose; never apply an edit to an instruction file without explicit consent.\nAn empty finding is a valid outcome. Check whether a recommendation is already\nconfigured before making it.\n\n## Query Planning (Read This First)\n\n**Each bash call costs ~1-2 seconds** (DuckDB init + JSONL parsing). 20 separate queries wastes 20-40 seconds on overhead alone.\n\n**Before running any query:**\n1. List all questions you need answered\n2. Combine into 1-2 heredoc batches\n3. Store results mentally — never re-run the same query\n\n**Standard pattern:**\n```bash\ncat \u003C\u003C 'EOF' | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query\n-- Query 1\nSELECT ...;\n-- Query 2\nSELECT ...;\n-- Query 3\nSELECT ...;\nEOF\n```\n\n## Quick Start\n\n```bash\n${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query                    # All projects\n${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query ~\u002Fcode\u002Fmyproject   # Specific project\n```\n\n**IMPORTANT**: Always use heredoc (not echo). Enables batching:\n```bash\ncat \u003C\u003C 'EOF' | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query\nSELECT count(*) FROM messages;\nEOF\n```\n\n## Use Cases\n\n**Analyzing a specific session**: See [session-analysis.md](session-analysis.md) for templates and output format.\n\n**Reviewing a span of time**: the REQUIRED slots are at the top of this file;\nqueries and traps in [period-review.md](period-review.md).\n\n## Reference\n\n**Schema details**: Run `echo '.schema' | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query` if you need the full schema.\n\n**JSON queries**: See [json-queries.md](json-queries.md) for working with the `message` JSON field.\n\n**Advanced patterns**: See [advanced-queries.md](advanced-queries.md) for complex analysis query ideas.\n\n## Views\n\n### Base Views\n\n| View                 | Description                                    | Has `message` JSON |\n| -------------------- | ---------------------------------------------- | ------------------ |\n| `messages`           | All messages (user, assistant, system)         | ✓                  |\n| `user_messages`      | User messages with tool results, todos         | ✓                  |\n| `assistant_messages` | Assistant messages with API response data      | ✓                  |\n| `system_messages`    | System messages (hooks, retries, tool output)  | ✗ (has `content`)  |\n| `human_messages`     | Only human-typed messages (no tool results)    | ✗ (has `content`)  |\n| `raw_messages`       | Raw JSON (uuid + full JSON string)             | ✗ (has `raw`)      |\n\n### Convenience Views (pre-extracted, no JSON needed)\n\n| View              | Key Fields                                      |\n| ----------------- | ----------------------------------------------- |\n| `tool_uses`       | `tool_name`, `tool_id`, `tool_input` (JSON)     |\n| `tool_results`    | `tool_use_id`, `is_error`, `result_content`, `duration_ms` |\n| `token_usage`     | `input_tokens`, `output_tokens`, `cache_read_tokens`, `model` |\n| `bash_commands`   | `command`, `description`, `timeout`             |\n| `file_operations` | `tool_name`, `file_path`, `pattern`             |\n\n## Key Fields\n\n**Common**: `uuid`, `timestamp`, `sessionId`, `message` (JSON), `type`, `cwd`, `version`\n\n**Derived**: `isAgent`, `agentId`, `project`, `file`, `rownum`\n\n**User-specific**: `toolUseResult`, `sourceToolAssistantUUID`, `todos`, `isMeta`\n\n**human_messages only**: `content` (VARCHAR) — extracted text, not JSON\n\n## Example Queries\n\n### Recent human messages (what did we work on)\n```sql\nSELECT timestamp, left(content, 100) as message\nFROM human_messages\nORDER BY timestamp DESC LIMIT 10;\n```\n\n### Recent sessions\n```sql\nSELECT sessionId, min(timestamp) as started, max(timestamp) as ended, count(*) as msgs\nFROM messages\nGROUP BY sessionId ORDER BY started DESC LIMIT 5;\n```\n\n### Message counts\n```sql\nSELECT type, count(*) as cnt FROM messages GROUP BY type ORDER BY cnt DESC;\n```\n\n### Token usage\n```sql\n-- Using convenience view (recommended)\nSELECT sum(input_tokens) as input, sum(output_tokens) as output, sum(cache_read_tokens) as cached\nFROM token_usage;\n\n-- Or with raw JSON\nSELECT sum(CAST(message->'usage'->>'input_tokens' AS BIGINT)) as input,\n       sum(CAST(message->'usage'->>'output_tokens' AS BIGINT)) as output,\n       sum(CAST(message->'usage'->>'cache_read_input_tokens' AS BIGINT)) as cache_hits\nFROM assistant_messages;\n```\n\n### Most used tools\n```sql\n-- Using convenience view (recommended)\nSELECT tool_name, count(*) as uses FROM tool_uses GROUP BY tool_name ORDER BY uses DESC LIMIT 10;\n\n-- Or with raw JSON (json_extract_string required for mixed message types)\nSELECT json_extract_string(message, '$.content[0].name') as tool, count(*) as uses\nFROM messages WHERE type = 'assistant'\n  AND json_extract_string(message, '$.content[0].type') = 'tool_use'\nGROUP BY tool ORDER BY uses DESC LIMIT 10;\n```\n\n### Agent vs main session\n```sql\nSELECT isAgent, count(*) as messages, count(DISTINCT agentId) as agents\nFROM messages\nGROUP BY isAgent;\n```\n\n### Project comparison\n```sql\nSELECT project, count(*) as messages\nFROM messages\nGROUP BY project\nORDER BY messages DESC;\n```\n\n### Tool durations\n```sql\n-- Using convenience view (recommended)\nSELECT tool_use_id, duration_ms, left(result_content, 50) as preview\nFROM tool_results WHERE duration_ms IS NOT NULL ORDER BY duration_ms DESC LIMIT 10;\n\n-- Or with raw JSON\nSELECT CAST(toolUseResult->>'durationMs' AS INTEGER) as duration_ms,\n       left(message->'content'->0->>'content', 50) as result_preview\nFROM user_messages WHERE toolUseResult IS NOT NULL ORDER BY duration_ms DESC LIMIT 10;\n```\n\n## Critical Notes\n\n**Use convenience views for tool analysis**: The `tool_uses`, `tool_results`, `bash_commands`, `file_operations`, and `token_usage` views pre-extract common fields so you don't need JSON functions:\n```sql\nSELECT tool_name, count(*) FROM tool_uses GROUP BY tool_name;  -- Simple!\n```\n\n**Column names are camelCase**: Use `sessionId`, `agentId`, `toolUseResult` (NOT `session_id`, `agent_id`)\n\n**Arrow operators fail on mixed data**: On base views (`assistant_messages`, `messages`), arrow operators like `message->'content'->0->>'name'` cause \"Conversion Error\" because rows have different JSON structures. Use `json_extract_string()` or convenience views:\n```sql\n-- FAILS: message->'content'->0->>'name'\n-- WORKS: json_extract_string(message, '$.content[0].name')\n-- BEST:  SELECT tool_name FROM tool_uses\n```\n\n## JSON Access\n\n- `json_extract_string(message, '$.field')` — **preferred**, handles mixed types\n- `message->'field'` returns JSON (use only when all rows have same structure)\n- `message->>'field'` returns string (same caveat)\n- `message->'content'->0` array access (0-indexed)\n- `UNNEST(CAST(json_array AS JSON[]))` expands arrays\n- **Precedence gotcha**: Use parentheses with `IS NULL`: `(message->'usage') IS NOT NULL`\n\n## Efficiency Guidelines\n\n**Target: 1-2 tool calls per analysis.** Each bash call = ~1-2 seconds overhead.\n\n| Calls | Overhead | Verdict |\n|-------|----------|---------|\n| 1-2   | 2-4s     | Good    |\n| 5-10  | 10-20s   | Wasteful |\n| 20+   | 40s+     | Unacceptable |\n\n### Two-Call Pattern for Unknown Sessions\n\n**Call 1: Discovery** — Find what you're looking for:\n```bash\ncat \u003C\u003C 'EOF' | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query\n-- Recent sessions\nSELECT sessionId, project, min(timestamp) as started, max(timestamp) as ended, count(*) as msgs\nFROM messages GROUP BY sessionId, project ORDER BY started DESC LIMIT 10;\nEOF\n```\n\n**Call 2: Deep Analysis** — Query the specific session(s):\n```bash\ncat \u003C\u003C 'EOF' | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query\n-- Replace SESSION_ID with ID from Call 1\nSELECT count(*) as msgs, count(DISTINCT agentId) as agents FROM messages WHERE sessionId = 'SESSION_ID';\nSELECT tool_name, count(*) FROM tool_uses WHERE sessionId = 'SESSION_ID' GROUP BY tool_name ORDER BY count(*) DESC;\nSELECT timestamp, left(content, 300) FROM human_messages WHERE sessionId = 'SESSION_ID' ORDER BY timestamp;\nEOF\n```\n\n### Combine keyword searches with OR\n```sql\n-- BAD: 5 separate queries for each keyword\n-- GOOD: One query with all patterns\nSELECT timestamp, left(content, 300) FROM human_messages\nWHERE lower(content) LIKE '%fix%'\n   OR lower(content) LIKE '%wrong%'\n   OR lower(content) LIKE '%instead%'\n   OR lower(content) LIKE '%prefer%'\n   OR lower(content) LIKE '%should%'\nORDER BY timestamp DESC;\n```\n\n### Use CTEs for repeated filters\n```sql\nWITH clean_messages AS (\n  SELECT * FROM human_messages\n  WHERE content NOT LIKE '%\u003Clocal-command%'\n    AND content NOT LIKE '%\u003Ccommand-name%'\n    AND length(content) > 20\n)\nSELECT timestamp, content FROM clean_messages\nWHERE lower(content) LIKE '%error%';\n```\n\n### Never Re-Query\nOnce you have a result, remember it. Don't re-run the same query to \"verify\" or \"check\".\n\n## Common Analysis Patterns\n\n### Cross-Project Overview (Single Call)\n```bash\ncat \u003C\u003C 'EOF' | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query\n-- Project activity\nSELECT project, count(*) as msgs, count(DISTINCT sessionId) as sessions,\n       max(timestamp) as last_activity FROM messages GROUP BY project ORDER BY last_activity DESC LIMIT 10;\n-- Tool patterns across all projects\nSELECT tool_name, count(*) as uses FROM tool_uses GROUP BY tool_name ORDER BY uses DESC LIMIT 15;\n-- Error-prone commands\nSELECT left(command, 80) as cmd, count(*) as errors\nFROM bash_commands bc JOIN tool_results tr ON bc.tool_id = tr.tool_use_id\nWHERE tr.is_error GROUP BY cmd ORDER BY errors DESC LIMIT 10;\nEOF\n```\n\n### Find user corrections\u002Fpreferences (for CLAUDE.md insights)\n```sql\nSELECT timestamp, left(content, 400) as content\nFROM human_messages\nWHERE content NOT LIKE '%\u003Clocal-command%'\n  AND content NOT LIKE '%\u003Ccommand-name%'\n  AND length(content) > 20\n  AND (\n    lower(content) LIKE '%instead%'\n    OR lower(content) LIKE '%wrong%'\n    OR lower(content) LIKE '%fix%'\n    OR lower(content) LIKE '%prefer%'\n    OR lower(content) LIKE '%should%'\n    OR lower(content) LIKE '%don''t%'\n    OR lower(content) LIKE '%please%'\n  )\nORDER BY timestamp DESC;\n```\n\n### Weekly Summary (Single Call)\n\nDate arithmetic is unavailable: the `-` operator is unbound for `DATE`,\n`TIMESTAMP` and `TIMESTAMPTZ` in this build, so `now() - INTERVAL '7 days'`\nand `current_date - 7` both fail with a binder error. Compute the cutoff in\nthe shell and interpolate it as a literal.\n\n```bash\nSINCE=$(date -v-7d +%F 2>\u002Fdev\u002Fnull || date -d '7 days ago' +%F)\ncat \u003C\u003C EOF | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query\n-- Sessions this week\nSELECT date_trunc('day', timestamp) as day, count(DISTINCT sessionId) as sessions, count(*) as msgs\nFROM messages WHERE timestamp >= '$SINCE' GROUP BY day ORDER BY day;\n-- What we worked on\nSELECT left(content, 200) as topic FROM human_messages\nWHERE timestamp >= '$SINCE' AND length(content) > 30\n  AND content NOT LIKE '%\u003Clocal-command%' ORDER BY timestamp DESC LIMIT 20;\n-- Token consumption\nSELECT sum(input_tokens) as input, sum(output_tokens) as output FROM token_usage WHERE timestamp >= '$SINCE';\nEOF\n```\n\nNote the unquoted `EOF` — `\u003C\u003C 'EOF'` would pass `$SINCE` through literally.\n","# Querying Session Data\n\nUse `${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query` to analyze Claude Code sessions with SQL (DuckDB).\n\n## Reviewing a span of time — REQUIRED slots\n\nApplies whenever the request names a period rather than one session: \"the last\n30 days\", \"this week\", \"this quarter\".\n\n**Read [period-review.md](period-review.md) before querying.** It carries the\ntested queries, the per-finding schema, the guards, and the traps that have\nproduced wrong conclusions here before. The slots below are the index.\n\nFour layers. Thirteen slots. Fill them all, or report a layer as *not\napplicable* and say why.\n\n**A — Measure** (transcripts, SQL)\nA1 window and volume, date range first · A2 where the work went · A3 tool\npatterns **with output chars**, ranked by cost not call count · A4 skill\nutilization from `~\u002F.claude.json` `skillUsage`, naming those **never invoked** ·\nA5 plugin and MCP utilization against `enabledPlugins` · A6 navigation mix,\n`LSP` vs. `Grep`\u002F`Glob` vs. text search through Bash.\n\n**B — Interpret** (causal; `Why` is mandatory in each)\nB1 worked · B2 friction, including *what to try instead* · B3 learned ·\nB4 corrections and interrupts, precise and upper-bound counts labeled\nseparately, recurring ones quoted verbatim.\n\n**C — Audit the instruction surface** (files on disk, `git blame`)\nC1 findings in `CLAUDE.md`, `AGENTS.md`, `SKILL.md`, rule files, commands,\nhooks — unenforced instructions, recency traps, contradictions, volatile\nspecifics, fossils. Each with `file:line` and quoted evidence. Never read\n`settings*.json` or `.mcp.json` whole; they can hold secrets — `jq` named keys.\n\n**D — Actions**\nD1 prioritized actions, ordered by confidence, each with observation, why it\nmatters, confidence, action, and quantified cost only where the data supports\nit · D2 measurement limits, stated **before** any recommendation rests on them.\n\nPropose; never apply an edit to an instruction file without explicit consent.\nAn empty finding is a valid outcome. Check whether a recommendation is already\nconfigured before making it.\n\n## Query Planning (Read This First)\n\n**Each bash call costs ~1-2 seconds** (DuckDB init + JSONL parsing). 20 separate queries wastes 20-40 seconds on overhead alone.\n\n**Before running any query:**\n1. List all questions you need answered\n2. Combine into 1-2 heredoc batches\n3. Store results mentally — never re-run the same query\n\n**Standard pattern:**\n```bash\ncat \u003C\u003C 'EOF' | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query\n-- Query 1\nSELECT ...;\n-- Query 2\nSELECT ...;\n-- Query 3\nSELECT ...;\nEOF\n```\n\n## Quick Start\n\n```bash\n${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query                    # All projects\n${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query ~\u002Fcode\u002Fmyproject   # Specific project\n```\n\n**IMPORTANT**: Always use heredoc (not echo). Enables batching:\n```bash\ncat \u003C\u003C 'EOF' | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query\nSELECT count(*) FROM messages;\nEOF\n```\n\n## Use Cases\n\n**Analyzing a specific session**: See [session-analysis.md](session-analysis.md) for templates and output format.\n\n**Reviewing a span of time**: the REQUIRED slots are at the top of this file;\nqueries and traps in [period-review.md](period-review.md).\n\n## Reference\n\n**Schema details**: Run `echo '.schema' | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query` if you need the full schema.\n\n**JSON queries**: See [json-queries.md](json-queries.md) for working with the `message` JSON field.\n\n**Advanced patterns**: See [advanced-queries.md](advanced-queries.md) for complex analysis query ideas.\n\n## Views\n\n### Base Views\n\n| View                 | Description                                    | Has `message` JSON |\n| -------------------- | ---------------------------------------------- | ------------------ |\n| `messages`           | All messages (user, assistant, system)         | ✓                  |\n| `user_messages`      | User messages with tool results, todos         | ✓                  |\n| `assistant_messages` | Assistant messages with API response data      | ✓                  |\n| `system_messages`    | System messages (hooks, retries, tool output)  | ✗ (has `content`)  |\n| `human_messages`     | Only human-typed messages (no tool results)    | ✗ (has `content`)  |\n| `raw_messages`       | Raw JSON (uuid + full JSON string)             | ✗ (has `raw`)      |\n\n### Convenience Views (pre-extracted, no JSON needed)\n\n| View              | Key Fields                                      |\n| ----------------- | ----------------------------------------------- |\n| `tool_uses`       | `tool_name`, `tool_id`, `tool_input` (JSON)     |\n| `tool_results`    | `tool_use_id`, `is_error`, `result_content`, `duration_ms` |\n| `token_usage`     | `input_tokens`, `output_tokens`, `cache_read_tokens`, `model` |\n| `bash_commands`   | `command`, `description`, `timeout`             |\n| `file_operations` | `tool_name`, `file_path`, `pattern`             |\n\n## Key Fields\n\n**Common**: `uuid`, `timestamp`, `sessionId`, `message` (JSON), `type`, `cwd`, `version`\n\n**Derived**: `isAgent`, `agentId`, `project`, `file`, `rownum`\n\n**User-specific**: `toolUseResult`, `sourceToolAssistantUUID`, `todos`, `isMeta`\n\n**human_messages only**: `content` (VARCHAR) — extracted text, not JSON\n\n## Example Queries\n\n### Recent human messages (what did we work on)\n```sql\nSELECT timestamp, left(content, 100) as message\nFROM human_messages\nORDER BY timestamp DESC LIMIT 10;\n```\n\n### Recent sessions\n```sql\nSELECT sessionId, min(timestamp) as started, max(timestamp) as ended, count(*) as msgs\nFROM messages\nGROUP BY sessionId ORDER BY started DESC LIMIT 5;\n```\n\n### Message counts\n```sql\nSELECT type, count(*) as cnt FROM messages GROUP BY type ORDER BY cnt DESC;\n```\n\n### Token usage\n```sql\n-- Using convenience view (recommended)\nSELECT sum(input_tokens) as input, sum(output_tokens) as output, sum(cache_read_tokens) as cached\nFROM token_usage;\n\n-- Or with raw JSON\nSELECT sum(CAST(message->'usage'->>'input_tokens' AS BIGINT)) as input,\n       sum(CAST(message->'usage'->>'output_tokens' AS BIGINT)) as output,\n       sum(CAST(message->'usage'->>'cache_read_input_tokens' AS BIGINT)) as cache_hits\nFROM assistant_messages;\n```\n\n### Most used tools\n```sql\n-- Using convenience view (recommended)\nSELECT tool_name, count(*) as uses FROM tool_uses GROUP BY tool_name ORDER BY uses DESC LIMIT 10;\n\n-- Or with raw JSON (json_extract_string required for mixed message types)\nSELECT json_extract_string(message, '$.content[0].name') as tool, count(*) as uses\nFROM messages WHERE type = 'assistant'\n  AND json_extract_string(message, '$.content[0].type') = 'tool_use'\nGROUP BY tool ORDER BY uses DESC LIMIT 10;\n```\n\n### Agent vs main session\n```sql\nSELECT isAgent, count(*) as messages, count(DISTINCT agentId) as agents\nFROM messages\nGROUP BY isAgent;\n```\n\n### Project comparison\n```sql\nSELECT project, count(*) as messages\nFROM messages\nGROUP BY project\nORDER BY messages DESC;\n```\n\n### Tool durations\n```sql\n-- Using convenience view (recommended)\nSELECT tool_use_id, duration_ms, left(result_content, 50) as preview\nFROM tool_results WHERE duration_ms IS NOT NULL ORDER BY duration_ms DESC LIMIT 10;\n\n-- Or with raw JSON\nSELECT CAST(toolUseResult->>'durationMs' AS INTEGER) as duration_ms,\n       left(message->'content'->0->>'content', 50) as result_preview\nFROM user_messages WHERE toolUseResult IS NOT NULL ORDER BY duration_ms DESC LIMIT 10;\n```\n\n## Critical Notes\n\n**Use convenience views for tool analysis**: The `tool_uses`, `tool_results`, `bash_commands`, `file_operations`, and `token_usage` views pre-extract common fields so you don't need JSON functions:\n```sql\nSELECT tool_name, count(*) FROM tool_uses GROUP BY tool_name;  -- Simple!\n```\n\n**Column names are camelCase**: Use `sessionId`, `agentId`, `toolUseResult` (NOT `session_id`, `agent_id`)\n\n**Arrow operators fail on mixed data**: On base views (`assistant_messages`, `messages`), arrow operators like `message->'content'->0->>'name'` cause \"Conversion Error\" because rows have different JSON structures. Use `json_extract_string()` or convenience views:\n```sql\n-- FAILS: message->'content'->0->>'name'\n-- WORKS: json_extract_string(message, '$.content[0].name')\n-- BEST:  SELECT tool_name FROM tool_uses\n```\n\n## JSON Access\n\n- `json_extract_string(message, '$.field')` — **preferred**, handles mixed types\n- `message->'field'` returns JSON (use only when all rows have same structure)\n- `message->>'field'` returns string (same caveat)\n- `message->'content'->0` array access (0-indexed)\n- `UNNEST(CAST(json_array AS JSON[]))` expands arrays\n- **Precedence gotcha**: Use parentheses with `IS NULL`: `(message->'usage') IS NOT NULL`\n\n## Efficiency Guidelines\n\n**Target: 1-2 tool calls per analysis.** Each bash call = ~1-2 seconds overhead.\n\n| Calls | Overhead | Verdict |\n|-------|----------|---------|\n| 1-2   | 2-4s     | Good    |\n| 5-10  | 10-20s   | Wasteful |\n| 20+   | 40s+     | Unacceptable |\n\n### Two-Call Pattern for Unknown Sessions\n\n**Call 1: Discovery** — Find what you're looking for:\n```bash\ncat \u003C\u003C 'EOF' | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query\n-- Recent sessions\nSELECT sessionId, project, min(timestamp) as started, max(timestamp) as ended, count(*) as msgs\nFROM messages GROUP BY sessionId, project ORDER BY started DESC LIMIT 10;\nEOF\n```\n\n**Call 2: Deep Analysis** — Query the specific session(s):\n```bash\ncat \u003C\u003C 'EOF' | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query\n-- Replace SESSION_ID with ID from Call 1\nSELECT count(*) as msgs, count(DISTINCT agentId) as agents FROM messages WHERE sessionId = 'SESSION_ID';\nSELECT tool_name, count(*) FROM tool_uses WHERE sessionId = 'SESSION_ID' GROUP BY tool_name ORDER BY count(*) DESC;\nSELECT timestamp, left(content, 300) FROM human_messages WHERE sessionId = 'SESSION_ID' ORDER BY timestamp;\nEOF\n```\n\n### Combine keyword searches with OR\n```sql\n-- BAD: 5 separate queries for each keyword\n-- GOOD: One query with all patterns\nSELECT timestamp, left(content, 300) FROM human_messages\nWHERE lower(content) LIKE '%fix%'\n   OR lower(content) LIKE '%wrong%'\n   OR lower(content) LIKE '%instead%'\n   OR lower(content) LIKE '%prefer%'\n   OR lower(content) LIKE '%should%'\nORDER BY timestamp DESC;\n```\n\n### Use CTEs for repeated filters\n```sql\nWITH clean_messages AS (\n  SELECT * FROM human_messages\n  WHERE content NOT LIKE '%\u003Clocal-command%'\n    AND content NOT LIKE '%\u003Ccommand-name%'\n    AND length(content) > 20\n)\nSELECT timestamp, content FROM clean_messages\nWHERE lower(content) LIKE '%error%';\n```\n\n### Never Re-Query\nOnce you have a result, remember it. Don't re-run the same query to \"verify\" or \"check\".\n\n## Common Analysis Patterns\n\n### Cross-Project Overview (Single Call)\n```bash\ncat \u003C\u003C 'EOF' | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query\n-- Project activity\nSELECT project, count(*) as msgs, count(DISTINCT sessionId) as sessions,\n       max(timestamp) as last_activity FROM messages GROUP BY project ORDER BY last_activity DESC LIMIT 10;\n-- Tool patterns across all projects\nSELECT tool_name, count(*) as uses FROM tool_uses GROUP BY tool_name ORDER BY uses DESC LIMIT 15;\n-- Error-prone commands\nSELECT left(command, 80) as cmd, count(*) as errors\nFROM bash_commands bc JOIN tool_results tr ON bc.tool_id = tr.tool_use_id\nWHERE tr.is_error GROUP BY cmd ORDER BY errors DESC LIMIT 10;\nEOF\n```\n\n### Find user corrections\u002Fpreferences (for CLAUDE.md insights)\n```sql\nSELECT timestamp, left(content, 400) as content\nFROM human_messages\nWHERE content NOT LIKE '%\u003Clocal-command%'\n  AND content NOT LIKE '%\u003Ccommand-name%'\n  AND length(content) > 20\n  AND (\n    lower(content) LIKE '%instead%'\n    OR lower(content) LIKE '%wrong%'\n    OR lower(content) LIKE '%fix%'\n    OR lower(content) LIKE '%prefer%'\n    OR lower(content) LIKE '%should%'\n    OR lower(content) LIKE '%don''t%'\n    OR lower(content) LIKE '%please%'\n  )\nORDER BY timestamp DESC;\n```\n\n### Weekly Summary (Single Call)\n\nDate arithmetic is unavailable: the `-` operator is unbound for `DATE`,\n`TIMESTAMP` and `TIMESTAMPTZ` in this build, so `now() - INTERVAL '7 days'`\nand `current_date - 7` both fail with a binder error. Compute the cutoff in\nthe shell and interpolate it as a literal.\n\n```bash\nSINCE=$(date -v-7d +%F 2>\u002Fdev\u002Fnull || date -d '7 days ago' +%F)\ncat \u003C\u003C EOF | ${CLAUDE_PLUGIN_ROOT}\u002Fbin\u002Fcc-query\n-- Sessions this week\nSELECT date_trunc('day', timestamp) as day, count(DISTINCT sessionId) as sessions, count(*) as msgs\nFROM messages WHERE timestamp >= '$SINCE' GROUP BY day ORDER BY day;\n-- What we worked on\nSELECT left(content, 200) as topic FROM human_messages\nWHERE timestamp >= '$SINCE' AND length(content) > 30\n  AND content NOT LIKE '%\u003Clocal-command%' ORDER BY timestamp DESC LIMIT 20;\n-- Token consumption\nSELECT sum(input_tokens) as input, sum(output_tokens) as output FROM token_usage WHERE timestamp >= '$SINCE';\nEOF\n```\n\nNote the unquoted `EOF` — `\u003C\u003C 'EOF'` would pass `$SINCE` through literally.\n",{"name":5,"context":24,"description":7,"allowed-tools":25},"fork","Bash, Read","main","a3f19bcc313571bff79dca391a83f9c4d38bb335","session-improv\u002Fskills\u002Freflect",0,"https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum","https:\u002F\u002Fgithub.com\u002Fozzycodes2","Software Engineer | Engineering Manager | AI whisperer | ☕Enjoyer","2026-11-14 04:50:11",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add ozzycodes2\u002Fclaudellum --skill reflect",{"tool":40,"command":41},"bunx","bunx skills add ozzycodes2\u002Fclaudellum --skill reflect",{"tool":43,"command":44},"pnpm","pnpm dlx skills add ozzycodes2\u002Fclaudellum --skill reflect","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Fsession-improv\u002Fskills\u002Freflect\u002FSKILL.md",true,[48,54,58,62],{"path":49,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":52,"sourceHtmlUrl":53},"advanced-queries.md","REFERENCE","参考文档",4315,"https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Fsession-improv\u002Fskills\u002Freflect\u002Fadvanced-queries.md",{"path":55,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":56,"sourceHtmlUrl":57},"json-queries.md",3166,"https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Fsession-improv\u002Fskills\u002Freflect\u002Fjson-queries.md",{"path":59,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":60,"sourceHtmlUrl":61},"period-review.md",10444,"https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Fsession-improv\u002Fskills\u002Freflect\u002Fperiod-review.md",{"path":63,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":64,"sourceHtmlUrl":65},"session-analysis.md",2624,"https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Fsession-improv\u002Fskills\u002Freflect\u002Fsession-analysis.md",[67,74,81,88,95,102],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7ASQB3CTKMKDNAXD9DCF1YC","writing-design-docs","Use when the user wants to write a problem-statement design doc, says \"let's plan a feature properly\" \u002F \"write a design doc\" \u002F \"I'm thinking about how to do X\" for a non-trivial X, or before committing to a non-obvious technical direction","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Ftechnical-writing\u002Fskills\u002Fwriting-design-docs\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7ASQ6JD4QRV5ZKK2QME401Y","write-doc","Use when the user asks to write or draft a README, ADR, runbook, tutorial, how-to, explanation, or reference doc, or a caller passes \"type ADR\" or \"type README\". Picks the type, fills a template, adds diagrams. RFCs and design docs belong to writing-design-docs.","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Ftechnical-writing\u002Fskills\u002Fwrite-doc\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7ASQ1VWNVP1RE7M5D4G2QMG","review-doc","Use when the user asks to review, critique, score, grade, or \"how good is this doc\" for a Markdown doc or pasted text. Read-only. Scores it on the 20 Practical Prose dimensions and emits a findings table. Does not edit; fix-doc applies the findings next.","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Ftechnical-writing\u002Fskills\u002Freview-doc\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7ASPWST208JZNR7HF7J6KMV","fix-doc","Use when the user asks to fix, edit for prose quality, polish, tighten, humanize, or de-slop a Markdown doc or pasted text, or says \"make this read less AI\". Applies review-doc findings, generates flagged diagrams, lists substantive issues for the author, then runs the AI-tell pass last. Modifies the target.","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Ftechnical-writing\u002Fskills\u002Ffix-doc\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":19},"01M7ASPS6Y9ZGK9KCDHNPDR75A","create-slides","Use when the user asks for a slide deck, presentation, talk, or slides from a document, report, PR, notes, or topic. Builds one self-contained Machinify-branded HTML deck in a minimalist style, with headline-plus-visual slides, speaker notes, and every diagram drawn by architecture-design:create-diagram.","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Ftechnical-writing\u002Fskills\u002Fcreate-slides\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":19},"01M7ASPAKFY045KHR92Y4QFTWV","start-session","Open a Claude Code working session in a fresh, isolated git worktree, so the user can start a task with a single \u002Fstart-session \u003Cname>. Use at the START of a session when the user says \"start session\", \"start a worktree\", \"spin up a worktree for ABC-123\", \"begin work on \u003Cticket>\", or passes a name\u002Fticket to work under. Creates and ENTERS a worktree via the EnterWorktree tool (never `git worktree add`) under .claude\u002Fworktrees\u002F, named exactly after the argument, on a local branch `worktree-\u003Cargument>`. Reports what the worktree inherited (`.worktreeinclude` copies, symlinked node_modules) and whether its `.env` still points at the main checkout's stack. If the argument is a JIRA key (e.g. ABC-123, PROJ-1505), also loads that story with the Atlassian CLI (`acli`) when available and summarizes the implementation ask. Also renames the session to the argument (the same effect as `\u002Frename \u003CNAME>`) so it's easy to find in `\u002Fresume`. Then stops and waits — it sets up the workspace and context, it does not implement.","https:\u002F\u002Fgithub.com\u002Fozzycodes2\u002Fclaudellum\u002Fblob\u002Fmain\u002Fsession-mgmt\u002Fskills\u002Fstart-session\u002FSKILL.md",[],[]]