templates/skills/languages/sql/SKILL.md
Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow).
npx skillsauth add hivellm/rulebook SQLInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
CRITICAL: Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow).
# Complete quality check sequence:
sqlfluff lint migrations/ # SQL linting
sqlfluff format --check migrations/ # Format check
# Run migration tests (project-specific)
# Run pgTAP tests if configured
# Migration validation:
flyway validate # Flyway migrations
# OR: liquibase validate # Liquibase migrations
CRITICAL: Use modern SQL standards with linting and testing.
CRITICAL: After implementing ANY change, you MUST run these commands in order.
IMPORTANT: These commands MUST match your GitHub Actions workflows to prevent CI/CD failures!
# Pre-Commit Checklist (MUST match .github/workflows/*.yml)
# 1. Format check (matches workflow)
sqlfluff format --check .
# 2. Lint (MUST pass with no warnings - matches workflow)
sqlfluff lint .
# 3. Run all tests (MUST pass 100% - matches workflow)
# PostgreSQL:
psql -d testdb -f tests/test_suite.sql
# SQL Server:
sqlcmd -S localhost -d testdb -i tests/test_suite.sql
# 4. Validate migrations (matches workflow)
# Check migration order and dependencies
flyway validate
# or: liquibase validate
# If ANY fails: ❌ DO NOT COMMIT - Fix first!
Why This Matters:
sqlfluff fix locally but sqlfluff format --check in CI = failureExample .sqlfluff configuration:
[sqlfluff]
dialect = postgres
templater = jinja
sql_file_exts = .sql,.sql.j2
max_line_length = 100
indent_unit = space
indented_joins = True
indented_using_on = True
[sqlfluff:rules]
capitalisation.keywords = upper
capitalisation.identifiers = lower
capitalisation.functions = upper
BEGIN;
SELECT plan(3);
-- Test table exists
SELECT has_table('users', 'users table should exist');
-- Test function
SELECT is(
calculate_total(100, 0.1),
110.0::numeric,
'calculate_total should apply 10% markup'
);
-- Test constraint
SELECT col_is_pk('users', 'id', 'id should be primary key');
SELECT * FROM finish();
ROLLBACK;
-- migrations/001_create_users.sql
-- IDEMPOTENT: Can run multiple times safely
-- Create table if not exists
CREATE TABLE IF NOT EXISTS users (
id BIGSERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Create index if not exists
CREATE INDEX IF NOT EXISTS idx_users_email ON users(email);
-- Add column if not exists (PostgreSQL 9.6+)
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'users' AND column_name = 'updated_at'
) THEN
ALTER TABLE users ADD COLUMN updated_at TIMESTAMP WITH TIME ZONE;
END IF;
END $$;
<!-- SQL:END -->research
Author a rulebook task spec interactively — research, draft, ask the user clarifying questions, confirm, then create the tasks in rulebook ready for /rulebook-driver. Use when the user wants to plan/spec a feature before implementing.
development
Behavioral guidelines to reduce common LLM coding mistakes — overcomplication, sloppy refactors, hidden assumptions, weak goals. Use when writing, reviewing, or refactoring code. Auto-applies; invoke explicitly via /karpathy-guidelines or 'follow karpathy discipline'.
data-ai
Autonomous AI agent loop for iterative task implementation (@hivehub/rulebook ralph)
data-ai
Use SQL Server for enterprise relational data storage with advanced features, high availability, and Windows integration.