home / skills / dasien / claudemultiagenttemplate / sql-development
This skill helps you design efficient database schemas, write optimized SQL, and manage data operations following best practices.
npx playbooks add skill dasien/claudemultiagenttemplate --skill sql-developmentReview the files below or copy the command above to add this skill to your agents.
---
name: "SQL Development"
description: "Design efficient database schemas, write optimized queries with proper indexes, and manage data operations following best practices"
category: "database"
required_tools: ["Read", "Write", "Edit", "Bash"]
---
# SQL Development
## Purpose
Design efficient database schemas, write optimized SQL queries, and manage data operations following database best practices and performance patterns.
## When to Use
- Designing database schemas
- Writing data queries
- Optimizing slow queries
- Creating database migrations
- Managing data relationships
## Key Capabilities
1. **Schema Design** - Create normalized, efficient table structures
2. **Query Optimization** - Write performant SELECT, INSERT, UPDATE, DELETE
3. **Index Strategy** - Design indexes for query performance
## Approach
1. Design schema following normalization principles
2. Define primary keys, foreign keys, and constraints
3. Write queries using proper JOINs and WHERE clauses
4. Create indexes for frequently queried columns
5. Use EXPLAIN to analyze query performance
6. Test with realistic data volumes
## Example
**Context**: Task management database
````sql
-- Schema Design
CREATE TABLE tasks (
id VARCHAR(50) PRIMARY KEY,
title VARCHAR(255) NOT NULL,
assigned_agent VARCHAR(100) NOT NULL,
status VARCHAR(20) NOT NULL,
priority VARCHAR(20) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
started_at TIMESTAMP NULL,
completed_at TIMESTAMP NULL,
INDEX idx_status (status),
INDEX idx_agent_status (assigned_agent, status),
INDEX idx_created (created_at)
);
-- Optimized Query
SELECT t.id, t.title, t.status, a.name as agent_name
FROM tasks t
JOIN agents a ON t.assigned_agent = a.agent_file
WHERE t.status IN ('pending', 'active')
AND t.priority = 'high'
ORDER BY t.created_at DESC
LIMIT 10;
````
## Best Practices
- ✅ Use indexes on frequently queried columns
- ✅ Avoid SELECT * - specify needed columns
- ✅ Use prepared statements to prevent SQL injection
- ✅ Normalize data to reduce redundancy
- ❌ Avoid: N+1 query problems
- ❌ Avoid: Missing WHERE clause on large tables
This skill helps design efficient database schemas, write optimized SQL queries, and manage data operations following database best practices. It focuses on schema normalization, index strategy, and performant CRUD patterns. The goal is reliable, maintainable, and high-performance data access for production systems.
I inspect application data models and query patterns, propose normalized schemas, and recommend primary/foreign keys and constraints. I analyze slow queries with EXPLAIN, suggest index strategies, and rewrite queries to reduce scans and avoid N+1 issues. I also provide migration guidance and testing approaches using realistic data volumes.
How do I choose between normalization and denormalization?
Normalize to reduce redundancy and maintain integrity; denormalize selectively for read performance when queries are proven bottlenecks and careful update strategies exist.
When should I add a composite index?
Add a composite index when queries commonly filter or sort by the same combination of columns; order the index columns to match the most selective predicates first.