Skip to content

feat: Add sql-query-explainer kit#150

Open
Saadonweb wants to merge 8 commits intoLamatic:mainfrom
Saadonweb:new-main
Open

feat: Add sql-query-explainer kit#150
Saadonweb wants to merge 8 commits intoLamatic:mainfrom
Saadonweb:new-main

Conversation

@Saadonweb
Copy link
Copy Markdown

PR Checklist

1. Select Contribution Type

  • Kit (kits/<category>/<kit-name>/)
  • Bundle (bundles/<bundle-name>/)
  • Template (templates/<template-name>/)

2. General Requirements

  • PR is for one project only (no unrelated changes)
  • No secrets, API keys, or real credentials are committed
  • Folder name uses kebab-case and matches the flow ID
  • All changes are documented in README.md (purpose, setup, usage)

3. File Structure (Check what applies)

  • config.json present with valid metadata (name, description, tags, steps, author, env keys)
  • All flows in flows/<flow-name>/ (where applicable) include:
    • config.json (Lamatic flow export)
    • inputs.json
    • meta.json
    • README.md
  • .env.example with placeholder values only (kits only)
  • No hand‑edited flow config.json node graphs (changes via Lamatic Studio export)

4. Validation

  • npm install && npm run dev works locally (kits: UI runs; bundles/templates: flows are valid)
  • PR title is clear (e.g., [kit] Add <name> for <use case>)
  • GitHub Actions workflows pass (all checks are green)
  • All CodeRabbit or other PR review comments are addressed and resolved
  • No unrelated files or projects are modified

This configuration defines the SQL Query Explainer workflow, detailing its purpose, version, author, tags, steps, and relevant links.
This document outlines the SQL Query Explainer AgentKit template, detailing its purpose, operational flow, and use cases for understanding SQL queries without execution.
This README provides an overview of the SQL Query Explainer workflow, detailing its purpose, output structure, use cases, prerequisites, and usage instructions.
This file implements a SQL Query Explainer flow that accepts a raw SQL query and returns a structured JSON explanation, including a summary, clause breakdown, performance concerns, and optimization suggestions.
Add structured explanation format for SQL query analysis.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Walkthrough

This pull request introduces a new SQL Query Explainer kit—a complete template containing flow definitions, configuration files, system and user prompts, and documentation. The kit enables SQL analysis through an LLM-powered workflow without executing queries or requiring database connections.

Changes

Cohort / File(s) Summary
Documentation
kits/sql-query-explainer/README.md, kits/sql-query-explainer/agent.md
Introduces comprehensive documentation describing the SQL Query Explainer's purpose, node chain architecture, expected response fields (summary, dialect hint, clauses, performance concerns, optimization suggestions), usage prerequisites, and operational guidance on applicable use cases.
Configuration & Setup
kits/sql-query-explainer/lamatic.config.ts, kits/sql-query-explainer/.gitignore
Establishes template metadata (name, description, version, author, tags) and deployment/github URLs; configures environment file and dependency exclusions (node_modules/, .env, .DS_Store, log files).
Flow Definition
kits/sql-query-explainer/flows/sql-query-explainer.ts
Defines the primary flow logic with API trigger node accepting query string input, routing through an LLMNode, and returning generatedResponse as explanation field; includes metadata, sample test input, and edge wiring configuration.
Model & Prompt Configuration
kits/sql-query-explainer/model-configs/sql-query-explainer_explain-query.ts, kits/sql-query-explainer/prompts/sql-query-explainer_explain-query_system.md, kits/sql-query-explainer/prompts/sql-query-explainer_explain-query_user.md
Establishes model configuration with generative model references and memory/message settings; specifies system prompt enforcing strict JSON-only responses with required fields and error-handling guidance; provides user prompt template injecting SQL query input.

Suggested reviewers

  • amanintech
  • d-pamneja
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description includes the checklist template but lacks evidence of checkboxes being marked or explanatory details about what was actually implemented. Complete the checklist by marking applicable items, provide a summary of which requirements were met, and clarify the specific implementation details of the SQL Query Explainer kit.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a new SQL Query Explainer kit to the repository.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

PR Validation Results

New Contributions Detected

  • Kit: kits/sql-query-explainer/prompts
  • Kit: kits/sql-query-explainer/model-configs
  • Kit: kits/sql-query-explainer/lamatic.config.ts
  • Kit: kits/sql-query-explainer/README.md
  • Kit: kits/sql-query-explainer/.gitignore
  • Kit: kits/sql-query-explainer/flows
  • Kit: kits/sql-query-explainer/agent.md

Check Results

Check Status
No edits to existing projects ✅ Pass
Required root files present ❌ Fail
Flow folder structure valid ✅ Pass
No changes outside contribution dirs ✅ Pass

Errors

  • ❌ Missing config.json in kits/sql-query-explainer/prompts
  • ❌ Missing README.md in kits/sql-query-explainer/prompts
  • ❌ Missing flows/ directory in kits/sql-query-explainer/prompts
  • ❌ Missing config.json in kits/sql-query-explainer/model-configs
  • ❌ Missing README.md in kits/sql-query-explainer/model-configs
  • ❌ Missing flows/ directory in kits/sql-query-explainer/model-configs
  • ❌ Missing config.json in kits/sql-query-explainer/lamatic.config.ts
  • ❌ Missing README.md in kits/sql-query-explainer/lamatic.config.ts
  • ❌ Missing flows/ directory in kits/sql-query-explainer/lamatic.config.ts
  • ❌ Missing config.json in kits/sql-query-explainer/README.md
  • ❌ Missing README.md in kits/sql-query-explainer/README.md
  • ❌ Missing flows/ directory in kits/sql-query-explainer/README.md
  • ❌ Missing config.json in kits/sql-query-explainer/.gitignore
  • ❌ Missing README.md in kits/sql-query-explainer/.gitignore
  • ❌ Missing flows/ directory in kits/sql-query-explainer/.gitignore
  • ❌ Missing config.json in kits/sql-query-explainer/flows
  • ❌ Missing README.md in kits/sql-query-explainer/flows
  • ❌ Missing flows/ directory in kits/sql-query-explainer/flows
  • ❌ Missing config.json in kits/sql-query-explainer/agent.md
  • ❌ Missing README.md in kits/sql-query-explainer/agent.md
  • ❌ Missing flows/ directory in kits/sql-query-explainer/agent.md

🛑 Please fix the errors above before this PR can be merged.

Refer to CONTRIBUTING.md and CLAUDE.md for the expected folder structure.

@Saadonweb
Copy link
Copy Markdown
Author

Submitting as part of the Lamatic mission-possible challenge.

This kit adds a SQL Query Explainer agent — accepts any SQL query, returns a structured JSON explanation with summary, clause-by-clause breakdown, performance concerns, and optimisation suggestions.

Please apply the mission-possible label.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@kits/sql-query-explainer/prompts/sql-query-explainer_explain-query_user.md`:
- Around line 1-3: The prompt injects raw user SQL via
{{triggerNode_1.output.query}} without delimiters; wrap the interpolated value
in an explicit fenced block or clear delimiter (e.g., triple backticks or
labeled sql fence) so the model treats it strictly as data rather than
instructions—update the template in sql-query-explainer_explain-query_user.md to
place {{triggerNode_1.output.query}} inside that fenced block (or equivalent
delimiter) and ensure any leading/trailing whitespace is preserved but outside
text of the prompt.

In `@kits/sql-query-explainer/README.md`:
- Around line 42-52: Add an "Environment variables" section to the README.md
(near the "Prerequisites" and "Usage" sections) that explicitly documents
required env vars for this kit: either list each variable name, its purpose, and
example/default value if any, or state "No environment variables required" if
none are needed; update the README headings to include "Environment variables"
so contributors know where to look.
- Around line 11-23: The README currently implies the API returns a parsed
object but the code forwards generatedResponse directly into the explanation
field, so the API actually emits JSON text; update the README wording and
example to clearly state that explanation is a JSON string (text) that clients
must JSON.parse, and change the example block to show the field as JSON text (or
show parsing example) so consumers know to parse the explanation value
generatedResponse into an object before reading summary, clauses,
performance_concerns, optimisation_suggestions, dialect_hint, and
example_output_description.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 22c2965f-73eb-43ca-bd09-7a2b3862cd9b

📥 Commits

Reviewing files that changed from the base of the PR and between 37ed8fb and 185dbfe.

📒 Files selected for processing (8)
  • kits/sql-query-explainer/.gitignore
  • kits/sql-query-explainer/README.md
  • kits/sql-query-explainer/agent.md
  • kits/sql-query-explainer/flows/sql-query-explainer.ts
  • kits/sql-query-explainer/lamatic.config.ts
  • kits/sql-query-explainer/model-configs/sql-query-explainer_explain-query.ts
  • kits/sql-query-explainer/prompts/sql-query-explainer_explain-query_system.md
  • kits/sql-query-explainer/prompts/sql-query-explainer_explain-query_user.md

Comment on lines +1 to +3
SQL Query:

{{triggerNode_1.output.query}}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Mission risk: delimit the SQL before interpolation.

Raw interpolation here mixes user data with prompt instructions, which makes prompt-injection and instruction-smuggling easier. Wrap the query in an explicit fenced block or another delimiter so the model treats it as data.

Suggested fix
 SQL Query:
 
-{{triggerNode_1.output.query}}
+```sql
+{{triggerNode_1.output.query}}
+```
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
SQL Query:
{{triggerNode_1.output.query}}
SQL Query:
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 1-1: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@kits/sql-query-explainer/prompts/sql-query-explainer_explain-query_user.md`
around lines 1 - 3, The prompt injects raw user SQL via
{{triggerNode_1.output.query}} without delimiters; wrap the interpolated value
in an explicit fenced block or clear delimiter (e.g., triple backticks or
labeled sql fence) so the model treats it strictly as data rather than
instructions—update the template in sql-query-explainer_explain-query_user.md to
place {{triggerNode_1.output.query}} inside that fenced block (or equivalent
delimiter) and ensure any leading/trailing whitespace is preserved but outside
text of the prompt.

Comment on lines +11 to +23
The API response contains an `explanation` field with a JSON object:

```json
{
"summary": "Plain-English description of what the query does.",
"dialect_hint": "PostgreSQL",
"clauses": [
{ "clause": "SELECT", "explanation": "Retrieves user ID, name, and order count." }
],
"performance_concerns": ["LEFT JOIN on large table without index on user_id."],
"optimisation_suggestions": ["Add index on orders.user_id."],
"example_output_description": "Up to 20 rows with user ID, name, order count sorted descending."
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Mission clarity: describe the response as JSON text, not a parsed object.

The flow forwards generatedResponse directly into explanation, so the API emits JSON text unless another step parses it. Update the wording/example so consumers know they need to parse the field.

Suggested wording tweak
- The API response contains an `explanation` field with a JSON object:
+ The API response contains an `explanation` field containing JSON text for the explanation object:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
The API response contains an `explanation` field with a JSON object:
```json
{
"summary": "Plain-English description of what the query does.",
"dialect_hint": "PostgreSQL",
"clauses": [
{ "clause": "SELECT", "explanation": "Retrieves user ID, name, and order count." }
],
"performance_concerns": ["LEFT JOIN on large table without index on user_id."],
"optimisation_suggestions": ["Add index on orders.user_id."],
"example_output_description": "Up to 20 rows with user ID, name, order count sorted descending."
}
The API response contains an `explanation` field containing JSON text for the explanation object:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@kits/sql-query-explainer/README.md` around lines 11 - 23, The README
currently implies the API returns a parsed object but the code forwards
generatedResponse directly into the explanation field, so the API actually emits
JSON text; update the README wording and example to clearly state that
explanation is a JSON string (text) that clients must JSON.parse, and change the
example block to show the field as JSON text (or show parsing example) so
consumers know to parse the explanation value generatedResponse into an object
before reading summary, clauses, performance_concerns, optimisation_suggestions,
dialect_hint, and example_output_description.

Comment on lines +42 to +52
## Prerequisites

- A Lamatic.ai account ([lamatic.ai](https://lamatic.ai))
- An LLM provider connected in your Lamatic workspace

## Usage

1. Import this template into your Lamatic workspace
2. Connect your LLM provider credentials
3. Deploy the flow
4. Send a POST request with a `query` field containing your SQL
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Mission requirement: add an environment-variables section.

The README currently covers setup and usage, but it never states whether the kit needs any env vars or explicitly that none are required. That leaves the kit documentation incomplete for contributors. As per coding guidelines, kits/**/README.md: Every kit must have a README.md that documents setup, environment variables, and usage.

Suggested addition
 ## Prerequisites
 
 - A Lamatic.ai account
 - An LLM provider connected in your Lamatic workspace
+
+## Environment Variables
+
+- None required. This kit uses the connected LLM provider configured in Lamatic.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Prerequisites
- A Lamatic.ai account ([lamatic.ai](https://lamatic.ai))
- An LLM provider connected in your Lamatic workspace
## Usage
1. Import this template into your Lamatic workspace
2. Connect your LLM provider credentials
3. Deploy the flow
4. Send a POST request with a `query` field containing your SQL
## Prerequisites
- A Lamatic.ai account ([lamatic.ai](https://lamatic.ai))
- An LLM provider connected in your Lamatic workspace
## Environment Variables
- None required. This kit uses the connected LLM provider configured in Lamatic.
## Usage
1. Import this template into your Lamatic workspace
2. Connect your LLM provider credentials
3. Deploy the flow
4. Send a POST request with a `query` field containing your SQL
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@kits/sql-query-explainer/README.md` around lines 42 - 52, Add an "Environment
variables" section to the README.md (near the "Prerequisites" and "Usage"
sections) that explicitly documents required env vars for this kit: either list
each variable name, its purpose, and example/default value if any, or state "No
environment variables required" if none are needed; update the README headings
to include "Environment variables" so contributors know where to look.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

Hi @Saadonweb! 👋

Before this PR can be reviewed by maintainers, please resolve all comments and requested changes from the CodeRabbit automated review.

Steps to follow:

  1. Read through all CodeRabbit comments carefully
  2. Address each issue raised (or reply explaining why you disagree)
  3. Push your fixes as new commits
  4. Once all issues are resolved, comment here so we can re-review

This helps keep the review process efficient for everyone. Thank you! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants