home / skills / williamzujkowski / standards / sql

sql skill

/skills/database/sql

This skill helps you apply SQL best practices and secure, maintainable patterns for database projects with clear guidance and testable code.

npx playbooks add skill williamzujkowski/standards --skill sql

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
1.9 KB
---
name: sql
description: Sql standards for sql in Database environments. Covers best practices,
---

# Sql

> **Quick Navigation:**
> Level 1: [Quick Start](#level-1-quick-start) (5 min) → Level 2: [Implementation](#level-2-implementation) (30 min) → Level 3: [Mastery](#level-3-mastery-resources) (Extended)

---

## Level 1: Quick Start

### Core Principles

1. **Best Practices**: Follow industry-standard patterns for database
2. **Security First**: Implement secure defaults and validate all inputs
3. **Maintainability**: Write clean, documented, testable code
4. **Performance**: Optimize for common use cases

### Essential Checklist

- [ ] Follow established patterns for database
- [ ] Implement proper error handling
- [ ] Add comprehensive logging
- [ ] Write unit and integration tests
- [ ] Document public interfaces

### Quick Links to Level 2

- [Core Concepts](#core-concepts)
- [Implementation Patterns](#implementation-patterns)
- [Common Pitfalls](#common-pitfalls)

---

## Level 2: Implementation

### Core Concepts

This skill covers essential practices for database.

**Key areas include:**

- Architecture patterns
- Implementation best practices
- Testing strategies
- Performance optimization

### Implementation Patterns

Apply these patterns when working with database:

1. **Pattern Selection**: Choose appropriate patterns for your use case
2. **Error Handling**: Implement comprehensive error recovery
3. **Monitoring**: Add observability hooks for production

### Common Pitfalls

Avoid these common mistakes:

- Skipping validation of inputs
- Ignoring edge cases
- Missing test coverage
- Poor documentation

---

## Level 3: Mastery Resources

### Reference Materials

- [Related Standards](../../docs/standards/)
- [Best Practices Guide](../../docs/guides/)

### Templates

See the `templates/` directory for starter configurations.

### External Resources

Consult official documentation and community best practices for database.

Overview

This skill defines SQL standards and practical patterns for database development in production environments. It focuses on security, maintainability, and performance to help teams start projects quickly and enforce consistent, battle-tested practices. The guidance spans quick-start checklists through implementation patterns and mastery resources.

How this skill works

The skill inspects database-related practices and templates, providing actionable implementation patterns, testing strategies, and performance tuning guidance. It highlights common pitfalls, error-handling approaches, and observability hooks to make database code resilient and operable in production. Use the patterns to evaluate and improve schema design, queries, and operational safeguards.

When to use it

  • Starting a new project that requires consistent database conventions
  • Auditing an existing codebase for SQL best practices and security risks
  • Designing database schemas and API-to-database integrations
  • Setting up testing and CI for database components
  • Improving performance and adding production observability

Best practices

  • Validate and sanitize all inputs; use parameterized queries or prepared statements
  • Adopt clear architecture patterns (repository, migration, and transaction boundaries)
  • Implement robust error handling and explicit transaction management
  • Write unit and integration tests for queries, migrations, and edge cases
  • Add logging and metrics for slow queries, errors, and schema changes

Example use cases

  • Bootstrapping a new service with standardized migration and schema templates
  • Reviewing database code to enforce secure query patterns and input validation
  • Designing performance tests to identify slow queries and missing indexes
  • Implementing observability: tracing, query latency metrics, and error alerts
  • Creating CI jobs that run migrations and integration tests against ephemeral databases

FAQ

Does this skill cover specific SQL dialects?

The guidance is dialect-agnostic and focuses on universal patterns; adapt examples to your specific database (Postgres, MySQL, SQL Server) as needed.

How do I start applying these standards to an existing project?

Run a focused audit: validate inputs, add tests for critical queries, introduce migrations, and incrementally add logging and monitoring for high-risk areas.