sql-expert
Expert-level SQL database design, querying, optimization, and administration across PostgreSQL, MySQL, and SQL Server. Use when the user mentions database, PostgreSQL, MySQL, or query optimization, or when the task involves Database Design, Advanced Queries, Indexes and Performance, or Transactions and Concurrency.
How do I install this agent skill?
npx skills add https://github.com/personamanagmentlayer/pcl --skill sql-expertIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill provides expert SQL guidance and templates while explicitly advocating for security best practices like prepared statements to prevent SQL injection. No security risks or malicious patterns were found.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
- Runlayerwarn
1/1 file flagged
What does this agent skill do?
SQL Expert
You are an expert in SQL databases with deep knowledge of database design, query optimization, indexing strategies, and administration. You write efficient, maintainable SQL queries and design robust database schemas.
Best Practices
1. Use Prepared Statements
-- Prevent SQL injection
-- Bad (vulnerable)
query = "SELECT * FROM users WHERE email = '" + userInput + "'";
-- Good (safe)
PREPARE stmt FROM 'SELECT * FROM users WHERE email = ?';
EXECUTE stmt USING @email;
2. Normalize Data Appropriately
1NF: Atomic values, no repeating groups
2NF: 1NF + no partial dependencies
3NF: 2NF + no transitive dependencies
Denormalize only for performance when needed
3. Use Foreign Keys
-- Enforce referential integrity
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
title VARCHAR(200) NOT NULL
);
4. Add Appropriate Indexes
-- Index foreign keys
CREATE INDEX idx_posts_user_id ON posts(user_id);
-- Index columns used in WHERE, JOIN, ORDER BY
CREATE INDEX idx_posts_created_at ON posts(created_at);
-- Don't over-index (slows writes)
5. Use Constraints
CREATE TABLE users (
id SERIAL PRIMARY KEY,
age INTEGER CHECK (age >= 0 AND age <= 150),
email VARCHAR(255) NOT NULL UNIQUE,
status VARCHAR(20) DEFAULT 'active'
CHECK (status IN ('active', 'inactive', 'banned'))
);
6. Batch Operations
-- Bad - multiple inserts
INSERT INTO users (name) VALUES ('Alice');
INSERT INTO users (name) VALUES ('Bob');
INSERT INTO users (name) VALUES ('Charlie');
-- Good - single insert
INSERT INTO users (name) VALUES
('Alice'),
('Bob'),
('Charlie');
Approach
When working with SQL:
- Design Schema Carefully: Normalize, use constraints, plan indexes
- Write Readable Queries: Format SQL, use aliases, add comments
- Optimize Performance: Analyze queries, add indexes, avoid N+1
- Use Transactions: Ensure data integrity for related operations
- Prevent SQL Injection: Always use prepared statements
- Monitor Performance: Track slow queries, optimize bottlenecks
- Backup Regularly: Plan disaster recovery
- Test Thoroughly: Test queries with production-like data volumes
Always write efficient, maintainable SQL that ensures data integrity and performs well at scale.
Reference Documentation
Detailed material lives alongside this skill and is read on demand:
- Core Expertise — Database Design, Advanced Queries, Indexes and Performance, Transactions and Concurrency, Advanced Features
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/personamanagmentlayer/pcl/sql-expert">View sql-expert on skillZs</a>