Query, the SQL Grok Bot
SQL Grok Bot template. Writes a query that runs on your schema, names the assumption it had to make, and says what the result does not include. Read only unless you ask otherwise.
About this engineering Grok Bot template
Query is the SQL Grok Bot that writes queries which run, and states what it assumed above each one. Read only by default: it will not run a write, and it will never produce a delete or an update without a where clause, including when asked.
The instructions are a list of the things that silently make a query wrong. An inner join that drops rows. A join through a one to many that multiplies them so the sum is too high. A time zone that turns a daily count into a different daily count. Between on a timestamp instead of a half open interval. Nulls treated as zero. Soft deleted rows and test accounts nobody filtered. It says what one row of the result represents, in words, before the query, and what the number excludes after it.
Use Query when the answer is in the database and the risk is being confidently wrong. Track is the Grok Bot for designing the events so the data exists in the first place, and Board for turning the result into the screen somebody watches every day. Query states what one row of the result represents before it writes anything, which is the single habit that catches most wrong numbers before they reach a slide.
Mentioned above: Board Dashboard Bot, Track Analytics Bot. Or see every Engineering Grok Bot.
What to ask it
- Weekly active accounts for the last twelve weeks, in the user's time zone.
- Here is my schema. Write the retention query and name your assumptions.
- Why is this sum too high? I think the join is multiplying rows.
- Rewrite this nested subquery as CTEs I can read.
- What will this query scan, and is that acceptable?
How to install this Grok Bot template
- Copy the template. You get the name, the description and the instructions.
- In Grok Bot, choose New, then Create new agent.
- Open Bot actions, then Edit Profile, and paste the name and the description.
- Paste the instructions.
- Switch on Web browsing. It needs no routines.
Or skip all five: add Query SQL Bot to Grok Bot in one click, using Grok Bot's own share as template link.
Questions about this Grok Bot
Does this SQL Grok Bot need my schema?
It asks for it. Where it has to guess, the guesses go in a comment block at the top as lines you can correct in five seconds rather than buried inside the query.
Will it run destructive statements?
No. It is read only unless you explicitly ask for a write, and even then it returns the statement wrapped in a transaction with the select that shows what it would touch, and never runs it.
What does it tell me besides the query?
What one row represents, the time zone, the assumptions, what is excluded, and what the query will scan before you run it.
Which dialect does it write?
Whichever you are on. Tell it, or it will ask, because the boundary and date functions differ where it matters most.
Design templates for your tool
Query SQL Bot works alongside the vibe coding tool you already build in, and the same licence covers the design templates for it: Lovable templates, Bolt templates, Replit templates, Claude Code templates, ChatGPT Codex templates, Cursor templates, Windsurf templates, Framer templates, v0 templates and Cline templates.
Included in the BrowserMoon licence, alongside every design template and all 51 Grok Bot templates. One licence, unlimited projects, including work you sell.
More Engineering Grok Bot templates
View allDiff, the code review Grok Bot
Findings ranked by blast radius
Repro, the bug report Grok Bot
Reproduces it, writes the report, stops
Probe, the QA Grok Bot
The paths a human would miss, as a checklist that can fail
Page, the incident comms Grok Bot
What broke, who was hit, what you are doing
Browse Grok Bot templates