sql-formatting

Format SQL queries and migration scripts with consistent spacing, indentation, and alignment.

Updated Mar 25, 2020
One-click install
npx skills add https://github.com/daominah/gostructure --skill sql-formatting
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-formatting
Source: https://github.com/daominah/gostructure/tree/main/.claude/skills/sql-formatting
Command: npx skills add https://github.com/daominah/gostructure --skill sql-formatting

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Enforces a consistent, readable SQL style to reduce review friction, minimize diff noise, and make queries and migrations easier to understand and maintain.

Core Features & Use Cases

  • Spacing and Punctuation: Require a space before opening and after closing parentheses for clarity.
  • Indentation and Structure: Use 4-space indentation and increase indentation for subordinate clause parts broken across lines.
  • Alignment and Documentation: Align columns and assignments within the same clause and add comments to clarify ambiguous column names.
  • Use Case: Apply these rules when cleaning up legacy queries, preparing migration scripts, or during code review to ensure uniform SQL style across the codebase.

Quick Start

Format the following SQL to use a space before opening and after closing parentheses, 4-space indentation, and aligned columns.

Frequently Asked Questions about sql-formatting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I format SQL queries for consistent indentation and spacing?

Aligning SQL migration scripts involves aligning columns and assignments within the same clause, using 4-space indentation, and adding clarifying comments for ambiguous column names. This reduces review friction and minimizes diff noise when refactoring legacy database code.

What is the best way to clean up legacy SQL queries?

The best way to clean up legacy SQL queries is to enforce uniform SQL style by applying rules for spacing around parentheses, 4-space indentation, and aligned columns. This makes queries easier to understand and maintain during refactoring.

Does consistent SQL style reduce code review friction?

Consistent SQL style reduces code review friction by enforcing readable formatting with standard spacing, indentation, and alignment. Uniform SQL style across the codebase minimizes diff noise and makes migration scripts easier to maintain.

How do I align columns and assignments within an SQL clause?

To align columns and assignments within an SQL clause, apply formatting rules that vertically align elements within the same clause. Combined with 4-space indentation and clarifying comments for ambiguous column names, this ensures uniform SQL style.

When do I need to format SQL migration scripts?

You need to format SQL migration scripts when preparing them for code review or refactoring legacy database code. Formatting enforces consistent spacing, indentation, and alignment, which reduces diff noise and makes the migration scripts easier to understand.