A Claude Code skill for formatting, polishing, and documenting SQL code following Oracle Database 19 best practices.
The SQL Formatter skill helps you write clean, consistent, and readable SQL code by applying comprehensive formatting rules and conventions. It transforms unformatted SQL queries into well-structured, properly indented, and professionally styled code.
- Automatic SQL Formatting - Format SQL queries with consistent style
- Oracle Database 19 Optimized - Best practices for Oracle SQL
- Comprehensive Rules - 13 detailed formatting rules covering all SQL constructs
- Multiple Statement Types - Supports SELECT, INSERT, UPDATE, DELETE, CREATE, and more
- Complex Query Support - Handles CTEs, joins, subqueries, and CASE expressions
- Vertical Alignment - Proper indentation and column alignment
- Case Conventions - UPPERCASE keywords, lowercase identifiers
- Clone or download this repository
- Copy the skill to your Claude Code skills directory:
Windows (Git Bash/PowerShell):
cp -r . "$USERPROFILE/.claude/skills/sql-formatter"Unix/Mac/Linux:
cp -r . ~/.claude/skills/sql-formatter- Restart Claude Code or reload skills
- Download the latest release ZIP from GitHub releases
- Extract to your Claude Code skills directory:
- Windows:
%USERPROFILE%\.claude\skills\sql-formatter - Unix/Mac:
~/.claude/skills/sql-formatter
- Windows:
- Restart Claude Code
Simply ask Claude Code to format your SQL:
Format this SQL code:
select id,name,email from users where status='active'
Claude will automatically apply the SQL Formatter skill and return:
SELECT id,
name,
email
FROM users
WHERE status = 'active';Format SQL files directly:
Format the SQL in database/queries/report.sql
The skill handles complex queries with CTEs, joins, and CASE expressions:
Format this complex query and make it readable
The skill applies 13 comprehensive formatting rules:
- Keywords - UPPERCASE for SQL keywords (SELECT, FROM, WHERE)
- Indentation - 4 spaces per level, no tabs
- Whitespace - Single space around operators and after commas
- Aliasing - Use AS keyword with spaces
- Single Line Initial - First column/condition on same line as clause
- Line Breaks - New line for each clause and column
- Vertical Alignment - Align columns and conditions
- CTEs - Proper WITH clause formatting
- Joins - Explicit JOIN types with aligned ON clauses
- Comments - Standard comment styles (when requested)
- Grouping - Parentheses for related conditions
- Ordering - Logical column and sorting order
- CASE Expressions - Aligned WHEN/THEN/ELSE/END
See references/sql-formatting-rules.md for complete details and examples.
select e.employee_id,e.first_name,e.last_name,d.department_name from employees e join departments d on e.department_id=d.department_id where e.status='ACTIVE' and e.salary>50000 order by e.last_nameSELECT e.employee_id,
e.first_name,
e.last_name,
d.department_name
FROM employees e
INNER JOIN departments d ON e.department_id = d.department_id
WHERE e.status = 'ACTIVE'
AND e.salary > 50000
ORDER BY e.last_name;See the examples/ directory for more comprehensive examples including:
- Basic SELECT statements
- Complex queries with CTEs
- INSERT/UPDATE/DELETE operations
- DDL statements (CREATE TABLE, etc.)
sql-formatter-skill/
├── SKILL.md # Main skill configuration
├── README.md # This file
├── VERSION # Skill version
├── references/
│ └── sql-formatting-rules.md # Complete formatting specification
└── examples/
├── unformatted.sql # Example: before formatting
├── formatted.sql # Example: after formatting
└── complex-query.sql # Example: complex queries
The SQL Formatter skill automatically activates when you:
- Ask to format SQL code
- Request to polish or beautify SQL queries
- Work with
.sqlfiles - Mention SQL formatting, Oracle SQL, or database query polishing
- Ask to improve SQL readability
The skill uses these default settings:
- Database: Oracle Database 19
- Indentation: 4 spaces
- Keywords: UPPERCASE
- Identifiers: lowercase
- Line Length: No strict limit (optimized for readability)
- Format SQL before committing to version control
- Apply formatting consistently across your project
- Test formatted SQL to ensure functionality is preserved
- Use the skill for both new and existing code
- Review complex queries after formatting
- Verify skill is installed in correct directory
- Restart Claude Code
- Try explicit request: "Use the sql-formatter skill to format this SQL"
- Check SKILL.md has valid YAML frontmatter
- Ensure SQL is syntactically valid before formatting
- Check for unbalanced parentheses or quotes
- Test the formatted SQL in your database
- Report issues with specific examples
- Focuses on formatting and style, not query optimization
- Preserves original query logic and structure
- Does not validate SQL syntax
- Optimized for Oracle Database 19 (may work with other databases)
- Does not modify query performance characteristics
Contributions are welcome! To improve this skill:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- 1.0.0 - Initial release
- Complete formatting rule implementation
- Support for all major SQL statement types
- Comprehensive documentation and examples
MIT License - See LICENSE file for details
For issues, questions, or suggestions:
This skill is based on professional SQL formatting standards and Oracle Database best practices. It follows the Claude Code skill creation guidelines and best practices from Anthropic.
Made with Claude Code | A skill for formatting SQL with style and consistency