moai-lang-sql

majiayu000's avatarfrom majiayu000

SQL best practices with pgTAP, sqlfluff 3.2, query optimization, and migration management.

⭐0stars🔀0forks📁View on GitHub🕐Updated Jan 5, 2026

When & Why to Use This Skill

This Claude skill streamlines SQL development and database management by enforcing industry best practices using sqlfluff 3.2 and pgTAP. It provides expert-level support for query optimization, schema migration management, and Test-Driven Development (TDD) workflows, specifically tailored for PostgreSQL 17.2 and MySQL 9.1.0 environments to ensure high-performance and maintainable database architectures.

Use Cases

  • Automating SQL linting and style enforcement: Use sqlfluff to maintain consistent code quality and catch syntax errors early in the development cycle.
  • Database Testing and QA: Implement robust unit tests for database functions and schemas using pgTAP to ensure reliability during updates.
  • Performance Tuning: Optimize complex SQL queries for PostgreSQL and MySQL to reduce execution time and improve application responsiveness.
  • Migration Management: Receive structured guidance on managing database schema changes and version control to prevent deployment failures.
  • TRUST 5 Compliance: Review SQL code against the TRUST 5 principles to ensure security, reliability, and architectural integrity.
name"moai-lang-sql"
version"2.0.0"
created2025-10-22
updated2025-10-22
statusstable
descriptionSQL best practices with pgTAP, sqlfluff 3.2, query optimization, and migration management.
keywords['sql', 'postgresql', 'mysql', 'sqlfluff', 'migrations']

Lang Sql Skill

Skill Metadata

Field Value
Skill Name moai-lang-sql
Version 2.0.0 (2025-10-22)
Allowed tools Read (read_file), Bash (terminal)
Auto-load On demand when keywords detected
Tier Language

What It Does

SQL best practices with pgTAP, sqlfluff 3.2, query optimization, and migration management.

Key capabilities:

  • ✅ Best practices enforcement for language domain
  • ✅ TRUST 5 principles integration
  • ✅ Latest tool versions (2025-10-22)
  • ✅ TDD workflow support

When to Use

Automatic triggers:

  • Related code discussions and file patterns
  • SPEC implementation (/alfred:2-run)
  • Code review requests

Manual invocation:

  • Review code for TRUST 5 compliance
  • Design new features
  • Troubleshoot issues

Tool Version Matrix (2025-10-22)

Tool Version Purpose Status
PostgreSQL 17.2 Primary ✅ Current
MySQL 9.1.0 Primary ✅ Current
sqlfluff 3.2.5 Primary ✅ Current
pgTAP 1.3.3 Primary ✅ Current

Inputs

  • Language-specific source directories
  • Configuration files
  • Test suites and sample data

Outputs

  • Test/lint execution plan
  • TRUST 5 review checkpoints
  • Migration guidance

Failure Modes

  • When required tools are not installed
  • When dependencies are missing
  • When test coverage falls below 85%

Dependencies

  • Access to project files via Read/Bash tools
  • Integration with moai-foundation-langs for language detection
  • Integration with moai-foundation-trust for quality gates

References (Latest Documentation)

Documentation links updated 2025-10-22


Changelog

  • v2.0.0 (2025-10-22): Major update with latest tool versions, comprehensive best practices, TRUST 5 integration
  • v1.0.0 (2025-03-29): Initial Skill release

Works Well With

  • moai-foundation-trust (quality gates)
  • moai-alfred-code-reviewer (code review)
  • moai-essentials-debug (debugging support)

Best Practices

✅ DO:

  • Follow language best practices
  • Use latest stable tool versions
  • Maintain test coverage ≥85%
  • Document all public APIs

❌ DON'T:

  • Skip quality gates
  • Use deprecated tools
  • Ignore security warnings
  • Mix testing frameworks