OpenParable
Skip to content
← Back to skills

SQL Best Practices

Development
sql-best-practices

SQL Best Practices is an Agent Skill for development published in the aiming-lab/MetaClaw repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Use this skill when writing SQL queries — selects, joins, aggregations, window functions, or schema modifications. Apply whenever SQL is needed to ensure correctness, safety, and performance.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/aiming-lab/MetaClaw/blob/HEAD/memory_data/skills/sql-best-practices/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/sql-best-practices, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

SQL Best Practices

Query quality:

  • Use SELECT col1, col2 — never SELECT * in production code.
  • Use CTEs (WITH) for readability instead of deeply nested subqueries.
  • Filter early: apply WHERE before JOIN when possible to reduce data scanned.
  • Use EXPLAIN / EXPLAIN ANALYZE to inspect query plans for slow queries.

Safety:

  • Always use parameterized queries from application code — never string interpolation.
  • Wrap destructive operations (DELETE, UPDATE, DROP) in a transaction.
  • Test on a staging/dev environment before running on production.

Naming: snake_case for tables/columns, descriptive names, consistent pluralization.