debug-formatter
Skill830 starsChanged 31 days agoApache-2.0View on GitHub
Debug a SQL formatter bug. Use when the user reports incorrect formatting, such as wrong whitespace, misplaced comments, or blank lines.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- releaseSkill
- run-codegenSkill
- run-testsSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Add a failing test to syntaqlite/tests/fmt_comments.rs (comment bugs) or the relevant tests/fmt_diff_tests/*.py file.
- Distinctive: line 28
Run it and confirm RED:
- Distinctive: line 61
All 7 integration suites must pass (including ~650 idempotency checks).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
debug-formatter
Debug a SQL formatter bug using red-green testing and pipeline tracing.
Instructions
1. Reproduce (RED)
Add a failing test to syntaqlite/tests/fmt_comments.rs (comment bugs) or the
relevant tests/fmt_diff_tests/*.py file. Always eprintln! the actual output:
#[test]
fn descriptive_name() {
let input = "...";
let out = fmt(input);
eprintln!("=== actual ===\n{out}=== end ===");
assert_eq!(out, "...\n");
}Run it and confirm RED:
cargo test -p syntaqlite --features fmt,sqlite --test fmt_comments TEST_NAME -- --nocapture2. Trace the pipeline
Work through these layers to find the root cause:
| Layer | File | What to check |
| Grammar | syntaqlite-buildtools/parser-nodes/*.synq | fmt { } block; clause("KW", field) expands to IF_SET → LINE → KEYWORD → NEST(LINE, CHILD) |
| Bytecode compiler | syntaqlite-buildtools/src/dialect_codegen/fmt_compiler.rs | How Fmt::Clause, Fmt::Keyword compile to opcodes |
| Interpreter | syntaqlite/src/fmt/interpret.rs | Main loop in interpret_node; state = running (committed doc) + pending (deferred line breaks) |
| Comment drain | syntaqlite/src/fmt/comment.rs | drain_before(offset) respects has_non_comment_text guard; drain_keyword_interior() skips it for multi-word keywords |
| flush_drain | interpret.rs | Integrates DrainResult { trailing, leading } into running/pending; when leading != NIL, pending is dropped |
| Doc renderer | syntaqlite/src/fmt/doc.rs | Wadler-style; hardline always breaks, line breaks if group broken |
3. Common bug patterns
- Blank line between comments: Two consecutive drains both produce
hardline + comment + hardline; back-to-back hardlines = blank line. Fix viacontinuationflag ondrain_keyword_interior. - Comment on wrong side of keyword:
flush_drainfor interior comments runs before keyword text is emitted. Check flush vs keyword append ordering in theKeywordmatch arm. - Comment lost:
has_non_comment_textguard stopsdrain_beforewhen a keyword sits between the comment and target offset. Multi-word interiors needskip_text_check: true. - Pending dropped:
flush_drainwithleading != NILzeroes pending. If pending held a LINE from the clause template, that break is lost.
4. Fix and verify (GREEN)
cargo test -p syntaqlite --features fmt,sqlite --test fmt_comments TEST_NAME -- --nocapture
cargo test -p syntaqlite --features fmt,sqlite
cargo build -p syntaqlite-cli && tools/run-integration-testsAll 7 integration suites must pass (including ~650 idempotency checks).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

