skills/query-budget-enforcer/SKILL.md
Defines and enforces query resource limits. Detects which queries scan too many rows, inflate memory usage, or exceed execution budgets.
npx skillsauth add fatih-developer/fth-skills query-budget-enforcerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill acts as the financial and operational conscience of the database. It reviews queries not just for speed, but for computational cost, lock duration, and hardware limits.
Core assumption: In cloud data warehouses (Snowflake, BigQuery), bad queries cost actual money. In OLTP (PostgreSQL), bad queries crash the server.
SELECT * without WHERE for BigQuery or lack of LIMIT).SELECT * without partition filters (WHERE date = ...)?Rows Removed by Filter: 99990) to return 10 rows, it violates the efficiency budget.Access Exclusive Lock or lengthy SELECT ... FOR UPDATE that blocks concurrent transactions?work_mem and spill to temporary disk?Review the query and provide a Pass/Fail budget assessment.
Required Outputs (Must write BOTH to docs/database-report/):
docs/database-report/query-budget-report.md)### 💳 Query Budget Assessment: FAILED ❌
**Query Analyzed:**
`SELECT * FROM events WHERE event_type = 'click';`
**Violations Detected:**
1. **[BigQuery] Partition Ignored:** The table is partitioned by `event_date`, but no date filter was provided. This will scan the entire 50TB table.
2. **[OLTP] Over-fetching:** `SELECT *` pulls down 140 columns when the application likely only needs 3.
### 💡 Remediation (How to get under budget)
Rewrite the query to respect system limits:
```sql
-- ✅ Budget-friendly rewrite
-- Added mandatory partition filter limit and explicit columns
SELECT user_id, event_payload, created_at
FROM events
WHERE event_type = 'click'
AND event_date >= CURRENT_DATE - INTERVAL '7 days';
2. **Machine-Readable JSON (`docs/database-report/query-budget-output.json`)**
```json
{
"skill": "query-budget-enforcer",
"assessment": "FAILED",
"violations": [
{"type": "Partition Ignored", "engine": "BigQuery", "severity": "High"},
{"type": "Over-fetching", "engine": "OLTP", "severity": "Medium"}
],
"suggested_sql": "SELECT user_id, event_payload..."
}
SELECT * but loves denormalization. PostgreSQL hates denormalization but SELECT * is less deadly if properly indexed. Adjust budgets based on the target engine.statement_timeout (PostgreSQL) or Maximum Bytes Billed (BigQuery) to definitively enforce budgets at the infrastructure layer.tools
Create, optimize, critique, and programmatically structure prompts for AI systems. Use this skill whenever the user is designing or improving a static prompt, system prompt, coding prompt, agent prompt, workflow prompt, MCP-oriented prompt package, or an algorithmic prompt optimization pipeline. Also use it when the user asks to turn vague AI behavior into a precise instruction set, tool policy, agent spec, evaluation metric, or prompt architecture.
testing
Assumption-first architecture review skill to stress-test project plans and expose hidden risks.
testing
Enforce and manage DESIGN.md specifications, extract design systems from URLs, and combine design reasoning with token roles to prevent drift.
testing
Forces the agent to act with a Claude-like product mindset, prioritizing user journey, UX states, and visual quality before coding.