# Sql Report Query Builder

> Build report-safe SQL from business requests with grain control, join discipline, filter logic, and validation notes.

- **Type:** Skill
- **Install:** `agentstack add skill-nicholashidalgo-claude-skillforge-sql-report-query-builder`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [nicholashidalgo](https://agentstack.voostack.com/s/nicholashidalgo)
- **Installs:** 0
- **Category:** [Databases](https://agentstack.voostack.com/c/databases)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [nicholashidalgo](https://github.com/nicholashidalgo)
- **Source:** https://github.com/nicholashidalgo/claude-skillforge/tree/main/data-engineering/sql-report-query-builder

## Install

```sh
agentstack add skill-nicholashidalgo-claude-skillforge-sql-report-query-builder
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

## Runtime Configuration
```yaml
version: "1.0.0"
gotcha_pack: "sql-data-gotcha-pack"
gotcha_pack_version: "1.0.0"
gotcha_enforcement: "block_on_high"
```

# Purpose
Turn a business request into production-grade SQL for reporting or analysis.

## Process
1. Identify business objective.
2. Define the intended grain before writing SQL.
3. List source tables, required joins, filters, and date logic.
4. Flag join-risk before generating the query.
5. Separate ad hoc SQL from report-safe SQL when relevant.
6. Add a validation checklist after the SQL.

## Required checks
- Base grain is explicit
- Join cardinality is assessed
- Aggregation level matches requested output
- Null handling is deliberate
- Date filters use business-safe logic
- Filter placement does not silently change row inclusion
- Naming is readable and consistent

## Output format
1. Assumptions and grain
2. SQL
3. Validation checklist
4. Risks or open questions

## Gotcha Enforcement

Before finalizing any SQL output, verify each rule below. A HIGH violation
must be corrected before responding. A MEDIUM violation must be flagged with
an explanation in the risks section.

| ID   | Sev    | Check                                                                           |
|------|--------|---------------------------------------------------------------------------------|
| G001 | HIGH   | No `SELECT *` in any CTE or final SELECT                                        |
| G002 | HIGH   | Every join has a stated cardinality; if unknown, provide the verification query |
| G003 | HIGH   | Every AVG, SUM, or COUNT documents its NULL behavior explicitly                 |
| G004 | HIGH   | No WHERE filter on a right-side column after a LEFT JOIN                        |
| G005 | HIGH   | Every dimension join includes an active/current filter or documents why not     |
| G006 | HIGH   | All measures in one SELECT are at the same grain; mixed grains use separate CTEs|
| G007 | HIGH   | Validation queries use a different access path than the report SQL              |
| G010 | MEDIUM | Cardinality of every join key is confirmed or a check query is provided         |
| G011 | MEDIUM | Any DISTINCT is accompanied by a root-cause note, not just applied silently     |

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [nicholashidalgo](https://github.com/nicholashidalgo)
- **Source:** [nicholashidalgo/claude-skillforge](https://github.com/nicholashidalgo/claude-skillforge)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-nicholashidalgo-claude-skillforge-sql-report-query-builder
- Seller: https://agentstack.voostack.com/s/nicholashidalgo
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
