agentleFS
CreativeActtechCreativeActtech/llm-skills/skills/example-skill/database-performance-auditor/SKILL.md

database-performance-auditor

Skill2 starsChanged 7 months agoMITView on GitHub

Audit SQL queries for performance anti-patterns and indexing needs. Use when users share slow queries, query plans (EXPLAIN), or schema DDLs and need optimization advice.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Check for: SELECT *, non-SARGABLE WHERE clauses (e.g., WHERE YEAR(date)), Cartesian products, and N+1 patterns.

    line 27
  2. Distinctive:

    Verify that refactored SQL produces the same result set as the original.

    line 36
  3. Distinctive:

    IF the schema (table structure) is missing:

    line 57

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Database Performance Auditor

Provides expert-level analysis of SQL queries to reduce execution time, resource consumption, and locking contention in enterprise databases.

🎯 When to Use

  • User shares a SQL query and reports "It's slow."
  • User provides a DESCRIBE or EXPLAIN output for analysis.
  • User needs to refactor legacy SQL for modern performance (e.g., CTEs).
  • Do NOT use for basic SQL syntax training or data visualization.
  • Do NOT use for NoSQL databases (MongoDB/DynamoDB) unless specifically requested.

🧠 Core Workflow

Step 1 — Ingest & Dialect Detection Detect SQL flavor (PostgreSQL, MySQL, T-SQL, Oracle). Identify primary tables.

Step 2 — Profile Anti-Patterns Check for: SELECT *, non-SARGABLE WHERE clauses (e.g., WHERE YEAR(date)), Cartesian products, and N+1 patterns.

Step 3 — Indexing & Refactoring Rules

  1. SARGability — Rewrite functions in WHERE to allow index seeks.
  2. Join Optimization — Ensure joins are on indexed keys.
  3. Modernization — Suggest Window Functions or CTEs to replace subqueries.

Step 4 — Validation Verify that refactored SQL produces the same result set as the original.

Step 5 — Return Output Provide a structured Findings Report (JSON) and the Optimized SQL.

📋 Output Format

Section 1 — Performance Report

{
  "dialect": "string",
  "critical_bottlenecks": [
    { "issue": "Full Table Scan", "impact": "High", "fix": "Add index on [column]" }
  ],
  "estimated_improvement": "e.g., 50% reduction in IO",
  "warnings": ["Potential lock contention on table X"]
}
Section 2 — Optimized SQL
Provide the rewritten query with # OPTIMIZED: comments.

⚠️ Fallback Behavior

IF the schema (table structure) is missing:

  • WARN that optimization is limited without knowing existing indexes.
  • SUGGEST: "Please provide the CREATE TABLE statement for better accuracy."

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.