MetaClaw sql-best-practices
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.
install
source · Clone the upstream repo
git clone https://github.com/aiming-lab/MetaClaw
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/aiming-lab/MetaClaw "$T" && mkdir -p ~/.claude/skills && cp -r "$T/memory_data/skills/sql-best-practices" ~/.claude/skills/aiming-lab-metaclaw-sql-best-practices && rm -rf "$T"
manifest:
memory_data/skills/sql-best-practices/SKILL.mdsource content
SQL Best Practices
Query quality:
- Use
— neverSELECT col1, col2
in production code.SELECT * - Use CTEs (
) for readability instead of deeply nested subqueries.WITH - Filter early: apply
beforeWHERE
when possible to reduce data scanned.JOIN - Use
/EXPLAIN
to inspect query plans for slow queries.EXPLAIN ANALYZE
Safety:
- Always use parameterized queries from application code — never string interpolation.
- Wrap destructive operations (
,DELETE
,UPDATE
) in a transaction.DROP - Test on a staging/dev environment before running on production.
Naming:
snake_case for tables/columns, descriptive names, consistent pluralization.