My SQL house style, as an agent skill and a local SQL-like formatter with T-SQL awareness. Lowercase keywords, leading commas, alias-first projections, expanded joins and CTEs. Plain SQL, comments that explain why, no query redesign disguised as formatting.
Place this repository's contents in a roy-sql directory inside your agent's skill
directory, or give an agent SKILL.md and its linked references directly.
The instructions are agent-independent. They need no runtime or database connection.
Ask: "use roy-sql to format this query, preserving its identifiers and values."
Requires PowerShell 7. From the repository directory:
pwsh -NoProfile -File scripts/install-scriptdom.ps1
pwsh -NoProfile -File scripts/format-sql.ps1 -Path query.sql
pwsh -NoProfile -File scripts/format-sql.ps1 -Path query.sql -Strict
pwsh -NoProfile -File scripts/format-sql.ps1 -Path query.sql -CheckThe first command downloads a hash-pinned Microsoft ScriptDOM dependency. The formatter then runs locally, with no model, database, network call or input-file edit. Its implementation is visible PowerShell and C# source; no separate .NET SDK is needed.
SQL goes to stdout. Diagnostics go to stderr. Omit -Path to pipe SQL on stdin.
Exit 0 means output produced, 1 means check-mode drift, 2 means strict refusal or an
operational failure. Save stdout to a different file, never the input path.
Recognized T-SQL SELECTs get structural formatting. Unfamiliar syntax, DDL and incomplete
SQL get conservative token layout with a warning, or unchanged input if tokenization is unsafe.
-Strict retains the original SELECT-focused refusal behavior and emits no partial SQL.
Neither mode executes SQL or proves database validity. There is no dialect translation:
LIMIT stays LIMIT. Missing files/dependencies and write failures still report errors.
See coverage, checks and limitations.
MIT. Microsoft ScriptDOM is a separate MIT-licensed dependency, downloaded explicitly rather than bundled. Its notice is in THIRD-PARTY-NOTICES.md.