Agent Skills
› aiming-lab/MetaClaw
› sql-best-practices
sql-best-practices
GitHub提供编写高质量、安全且高性能 SQL 查询的最佳实践指南,涵盖性能优化、参数化防注入及命名规范。
Trigger Scenarios
编写 SQL 查询语句
进行数据库模式修改
优化慢速 SQL 查询
Install
npx skills add aiming-lab/MetaClaw --skill sql-best-practices -g -y
SKILL.md
Frontmatter
{
"name": "sql-best-practices",
"category": "data_analysis",
"description": "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."
}
SQL Best Practices
Query quality:
- Use
SELECT col1, col2— neverSELECT *in production code. - Use CTEs (
WITH) for readability instead of deeply nested subqueries. - Filter early: apply
WHEREbeforeJOINwhen possible to reduce data scanned. - Use
EXPLAIN/EXPLAIN ANALYZEto 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.
Version History
- 922caf3 Current 2026-07-25 11:08


