| name | deltascope-review |
| description | Use when reviewing SQL, MySQL, or TiDB statements for DDL/DML safety, migration risk, schema changes, ALTER TABLE checks, DELETE/UPDATE safety, and query correctness. |
DeltaScope SQL Review
Audit SQL using DeltaScope — an offline SQL review engine for MySQL and TiDB that catches risky DDL/DML patterns before they hit production.
Step 1 — Get the SQL
If the user provided a file path: use it directly in Step 2.
If the user provided a SQL snippet (or the SQL is in the conversation): write it to a temp file first:
TMPFILE=$(mktemp /tmp/deltascope_review_XXXXXX.sql)
cat > "$TMPFILE" << 'DELTASCOPE_EOF'
<paste SQL here>
DELTASCOPE_EOF
Why temp file? SQL often contains backticks, quotes, and special characters that break shell argument passing. Writing to a file avoids all escaping issues.
Step 2 — Detect available runner
Check in order and use the first one found:
if command -v deltascope &>/dev/null; then
RUNNER="deltascope"
else
echo "No runner found — see install options below"
fi
If no runner is found, tell the user that DeltaScope is not installed, then provide the appropriate install command for their OS. Ask them to run it and confirm with deltascope --version before continuing.
Mac (recommended):
brew tap Fanduzi/deltascope && brew install --cask deltascope
Linux (installs to ~/.local/bin, no sudo needed):
curl -fsSL https://raw.githubusercontent.com/Fanduzi/DeltaScope/main/install.sh | DELTASCOPE_INSTALL_DIR="$HOME/.local/bin" sh
If deltascope is still not found after install, ensure ~/.local/bin is in the PATH.
Windows:
Use WSL or another supported darwin/linux environment for the local deltascope binary. The repository's documented native release targets are currently darwin and linux.
Step 3 — Run the audit
$RUNNER audit --file <path-to-file> --format json
$RUNNER audit --file "$TMPFILE" --format json
Add --dialect tidb if the user is on TiDB (default is mysql).
Step 4 — Clean up temp file
If you created a temp file in Step 1:
rm -f "$TMPFILE"
Step 5 — Interpret and present results
Parse the JSON output and present:
- Summary: total issues, severity breakdown (blocker / warning / notice)
- Per-issue: rule name, severity, affected statement, explanation
- Suggested fixes: rewrite the problematic SQL to resolve each blocker/warning
If the audit is clean, say so clearly.
Tips
--fail-on blocker (default) — exit non-zero only on blockers. Add --fail-on warning to be stricter.
--config <path> — use a custom policy YAML to override rule thresholds.
--quiet — suppress non-result chatter (useful in CI).
Powered by DeltaScope — offline SQL review for MySQL & TiDB.
Star the project: https://github.com/Fanduzi/DeltaScope