mdrobeulislam1251-ux/t-ex-llm-runpack/sql-analytics
Claude Code and agent skill by mdrobeulislam1251-ux/t-ex-llm-runpack
- community
Checking that the SKILL.md file is still in the repository.
Use for analytical SQL — cohort retention, funnels, sessionization, dedup, running totals, period-over-period deltas — and the NULL/join/window traps that silently corrupt results. Dialect is probed first; patterns are portable SQL with Postgres flavor noted.
Install
npx vskill@latest install mdrobeulislam1251-ux/t-ex-llm-runpack/sql-analyticsSKILL.md
The same SKILL.md was published earlier as mdrobeulislam1251-ux/t-ex-llm-runpack/sql-analytics.
SQL Analytics
Correctness first: an analytical query that LOOKS right and returns plausible numbers is the most dangerous artifact in data work. Every pattern here ships with its verification check — run it before the numbers leave your hands.
Probe the dialect first
SELECT version(); (Postgres/MySQL) · SELECT @@version; (SQL Server) · SELECT sqlite_version(); · ClickHouse SELECT version();. Date functions, window-frame defaults, and division semantics differ — confirm before pasting patterns across engines.
Dedup — find, inspect, remove
Portable alternative: row_number() in a CTE, delete rn > 1 via the PK. Verify after: the find query returns 0 rows.
Sessionization (gap rule)
30 minutes is the web-analytics convention — state the gap you chose next to the numbers you report.
Cohort retention
Verify: each cohort's month_n = 0 row must equal that cohort's size. If it doesn't, the join or the cohort definition is wrong — stop.
Funnel (order-enforced steps)
The e.event_at > s_prev.t_prev join condition is the load-bearing part — it enforces step ORDER. Verify: counts must be monotonically non-increasing; a later step exceeding an earlier one means the ordering constraint is missing.
Period over period
NULLIF(..., 0) makes division-by-zero yield NULL instead of an error; 100.0 (not 100) forces float math — integer division silently floors to 0.
Running totals — the frame trap
With ORDER BY, the default window frame is RANGE, which lumps tied order keys together. Running totals want ROWS:
The silent-corruption traps
| Trap | Symptom | Fix | |
|---|---|---|---|
NOT IN (subquery) where the subquery can return NULL | Zero rows, no error | NOT EXISTS, or filter IS NOT NULL inside | |
| Join fanout | Metrics inflate after adding a join | Compare count(*) before/after; pre-aggregate the many-side. SELECT DISTINCT masks the symptom, never fixes it | |
count(col) vs count(*) | Counts mysteriously low | count(col) skips NULLs — use deliberately or not at all | |
avg(col) with NULLs | Average too high | Decide: coalesce(col, 0) or document the exclusion | |
BETWEEN on timestamps | Boundary rows counted twice across periods | Half-open: >= start AND < end | |
GROUP BY 1 ordinals in saved queries | Silent regroup when columns reorder | Column names in anything that persists | |
| Mixed time zones | Daily numbers disagree with the dashboard | One declared zone: date_trunc('day', ts AT TIME ZONE 'UTC') | |
| Integer division | Every ratio is 0 | Multiply by 100.0, NULLIF the denominator |
Reconciliation gates — before ANY numbers ship
- Parts = whole: segment counts sum to the unsegmented total.
- Funnel monotonic: each step ≤ the previous.
- Cohort diagonal: month-0 actives = cohort size.
- Spot-check 3 rows end-to-end by hand against raw data.
- One aggregate vs a known-true source (billing, the production dashboard).
All five pass → ship. Anything fails → the query is wrong until proven otherwise. Plausible ≠ verified.
Anti-patterns
SELECT DISTINCTto "fix" inflation (see fanout trap — diagnose the join).OFFSETbeyond ~10k rows for exports — keyset pagination instead (postgres-patterns).- Correlated subquery per row where one window pass does it.
- Magic date literals scattered through a query — one
paramsCTE at the top, referenced everywhere.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/tex-llm/skills/sql-analytics/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/mdrobeulislam1251-ux/t-ex-llm-runpack/sql-analytics)