home / skills / jcastillotx / vibe-skeleton-app / mysql-best-practices
This skill helps you apply MySQL best practices for query optimization, security, and schema design to build robust, scalable databases.
npx playbooks add skill jcastillotx/vibe-skeleton-app --skill mysql-best-practicesReview the files below or copy the command above to add this skill to your agents.
---
name: mysql-best-practices
description: MySQL database development standards. Triggers when working with MySQL databases, queries, schema design, or optimization.
trigger_patterns:
- mysql
- SELECT
- INSERT
- UPDATE
- CREATE TABLE
- ALTER TABLE
- INDEX
auto_load_with: []
---
# MySQL Best Practices
Comprehensive coding standards for MySQL database development, optimized for AI agents and LLMs.
## Overview
This skill provides 24 rules organized across 8 categories:
1. **Query Optimization (query-)** - EXPLAIN, N+1 prevention, pagination [CRITICAL]
2. **Security (security-)** - Prepared statements, least privilege, encryption [CRITICAL]
3. **Schema Design (schema-)** - Data types, normalization, constraints [HIGH]
4. **Indexing Strategy (index-)** - Composite indexes, covering indexes [HIGH]
5. **Transaction Management (txn-)** - ACID, isolation levels, deadlocks [MEDIUM-HIGH]
6. **Connection Management (conn-)** - Pooling, timeouts [MEDIUM]
7. **Backup & Recovery (backup-)** - Strategies, point-in-time recovery [MEDIUM]
8. **Replication (repl-)** - Master-slave, read replicas [LOW-MEDIUM]
## Usage
Reference this skill when:
- Designing database schemas
- Writing or optimizing SQL queries
- Implementing indexes
- Managing transactions
- Configuring connections
## Build
```bash
pnpm build # Compile rules to AGENTS.md
pnpm validate # Validate rule files
```
This skill codifies MySQL database development standards into clear, actionable rules for schema design, queries, indexing, transactions, security, and operations. It helps developers and AI agents follow proven practices that improve performance, reliability, and security. The guidance is organized into categories so you can apply the right rule at the right stage of development.
The skill inspects MySQL-related tasks and suggests specific standards and checks based on context: query patterns, schema definitions, index usage, transaction handling, connection settings, backup strategies, and replication setup. It flags common pitfalls (N+1 queries, missing indexes, unsafe concatenation), recommends fixes (prepared statements, composite indexes, EXPLAIN-driven optimization), and provides operational advice for backups and replication. Recommendations are concise and actionable for immediate implementation.
How do I choose between normalization and denormalization?
Normalize to reduce redundancy and ensure data integrity; denormalize selectively to speed read-heavy queries, but document trade-offs and add constraints or background jobs to maintain consistency.
When should I add a composite index?
Add a composite index when queries filter or sort on multiple columns together; order the columns in the index to match the most selective and most-used query patterns.