Agent skill
mysql-aurora-patterns
MySQL and Aurora-specific database patterns including InnoDB conventions, utf8mb4 charset, Aurora read replicas, RDS Proxy, and failover retry logic. Use when working with MySQL or Aurora databases. Do NOT use for PostgreSQL -- use postgresql-patterns instead. Do NOT use for generic database principles -- use database-patterns instead.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/mysql-aurora-patterns
SKILL.md
MySQL/Aurora Patterns
MySQL and Aurora-specific optimization patterns. For DB-agnostic patterns (transactions, N+1, caching principles, EXPLAIN ANALYZE, zero-downtime migrations), see database-patterns skill.
MySQL Schema Conventions
Data Type and Engine Defaults
CREATE TABLE users (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
is_active TINYINT(1) DEFAULT 1,
balance DECIMAL(10,2)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Key Points:
- InnoDB engine required (transactions, foreign keys, row-level locking)
- utf8mb4 charset required (full Unicode including emoji)
- AUTO_INCREMENT for sequential primary keys
- TINYINT(1) for boolean columns (MySQL has no native BOOLEAN type)
Aurora Specific
Read Replicas
- Use reader endpoint for read-heavy queries
- Use writer endpoint for writes only
- Design application to tolerate replication lag on read replicas
Connection Management
- Use connection pooling (RDS Proxy recommended for Aurora)
- Keep transactions short for failover resilience
- Implement retry logic for failover scenarios
Failover Retry Pattern
Aurora failover typically completes within 30 seconds. Applications should:
- Detect connection errors during failover
- Retry with exponential backoff
- Re-resolve DNS for the cluster endpoint (Aurora updates DNS on failover)
- Avoid caching resolved IP addresses
MySQL Security
Least Privilege User Creation
-- Read-only application user
CREATE USER 'app_readonly'@'%' IDENTIFIED BY 'password';
GRANT SELECT ON mydb.products TO 'app_readonly'@'%';
-- Read-write application user
CREATE USER 'app_writer'@'%' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE ON mydb.orders TO 'app_writer'@'%';
-- No DELETE permission unless explicitly needed
MySQL Non-Blocking DDL
Index Creation
-- Non-blocking index creation on MySQL/Aurora
ALTER TABLE orders ADD INDEX idx_customer_id (customer_id), ALGORITHM=INPLACE, LOCK=NONE;
Column Operations
-- Non-blocking column addition
ALTER TABLE orders ADD COLUMN tracking_number VARCHAR(100), ALGORITHM=INPLACE, LOCK=NONE;
Caveat: Not all DDL operations support ALGORITHM=INPLACE. Check MySQL documentation for the specific operation. Operations that require table rebuild (e.g., changing column type) may need ALGORITHM=COPY.
Anti-Patterns
MySQL-Specific Anti-Patterns
- Missing
utf8mb4charset (causes data loss for emoji and some CJK characters) - Using MyISAM or other engines instead of InnoDB
- Not using
ALGORITHM=INPLACE, LOCK=NONEfor online DDL when available - Caching Aurora cluster endpoint DNS resolution (breaks failover)
Review Checklist
- utf8mb4 charset used
- InnoDB engine used
- Non-blocking DDL uses ALGORITHM=INPLACE, LOCK=NONE
- Aurora read replicas used for read-heavy queries
- RDS Proxy or connection pooling configured for Aurora
For DB-agnostic review items, see database-patterns skill.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?