ggsql / tree-sitter-ggsql
CLAUDE.md566 starsChanged 52 days agoMITView on GitHub
The Tree-sitter grammar for ggsql. Consumed by the Rust parser in /src/parser/, by editor highlighters, and by language-aware tooling. Workspace member, also published to npm and PyPI. The files under src/ are generated by tree-sitter generate from grammar.js — they are committed so downstream consumers don't need the tree-sitter CLI to build. grammar.js defines a query rule that is optional(sqlportion) + repeat(visualisestatement). The SQL portion is recognised structurally enough to know where it ends (statement boundaries, recursive subqueries, WITH compound…
We split this CLAUDE.md into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 57
Add corpus tests under test/corpus/ covering the new construct (and any conflicts).
- Very specific: line 59
Update /src/parser/builder.rs to produce the matching AST nodes.
- Very specific: line 60
If the new syntax should be highlighted, update queries/highlights.scm.
- Very specific: line 61
Document the syntax under /doc/syntax/.
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md 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
tree-sitter-ggsql/ — grammar package
The Tree-sitter grammar for ggsql. Consumed by the Rust parser in /src/parser/, by editor highlighters, and by language-aware tooling. Workspace member, also published to npm and PyPI.
Layout
tree-sitter-ggsql/
├── grammar.js Source of truth — the grammar definition
├── tree-sitter.json Tree-sitter project config
├── package.json Node/npm bindings (default consumer)
├── Cargo.toml Rust binding (path = bindings/rust/lib.rs)
├── pyproject.toml Python binding
├── setup.py Python build helper
├── binding.gyp node-gyp config for the Node binding
├── src/
│ ├── grammar.json Generated — JSON form of grammar.js
│ ├── parser.c Generated — the parser
│ └── tree_sitter/ Generated parser headers
├── bindings/
│ ├── rust/ lib.rs + build.rs (used by the workspace)
│ ├── node/ JS binding glue
│ ├── python/ Python binding glue
│ └── c/ C binding glue
├── queries/
│ └── highlights.scm Highlight queries used by editors
└── test/
└── corpus/ Tree-sitter test corpus (parser test cases)The files under src/ are generated by tree-sitter generate from grammar.js — they are committed so downstream consumers don't need the tree-sitter CLI to build.
Grammar at a glance
grammar.js defines a query rule that is optional(sql_portion) + repeat(visualise_statement). The SQL portion is recognised structurally enough to know where it ends (statement boundaries, recursive subqueries, WITH compound statements) without re-implementing a SQL parser — the actual SQL is handed off to the configured Reader. The VISUALISE side is parsed in detail (clauses, layer types, mappings, settings, scales, facets, projections, labels) so /src/parser/builder.rs can build a typed AST from it.
For ggsql language semantics, see /doc/syntax/ — this package only defines how text is parsed, not what the resulting tree means.
Workflow
# Regenerate src/grammar.json + parser.c after editing grammar.js
npx tree-sitter generate
# Run the corpus tests in test/
npx tree-sitter test
# All tests via npm (corpus + the Node binding smoke test)
npm testIn editors with tree-sitter support: npx tree-sitter playground to interactively probe the parser.
Adding new ggsql syntax
- Edit
grammar.js. Pick node names that downstream code can match against. - Add corpus tests under
test/corpus/covering the new construct (and any conflicts). npx tree-sitter generateto regeneratesrc/grammar.jsonandparser.c. Commit those.- Update
/src/parser/builder.rsto produce the matching AST nodes. - If the new syntax should be highlighted, update
queries/highlights.scm. - Document the syntax under
/doc/syntax/.
Bindings
| Binding | Manifest | Notes |
| Rust | Cargo.toml + bindings/rust/{lib.rs,build.rs} | What the workspace uses. Build script compiles src/parser.c. |
| Node | package.json + binding.gyp + bindings/node/ | Default main. Used by the npm package. |
| Python | pyproject.toml + setup.py + bindings/python/ | Published to PyPI. |
| C | bindings/c/ | Plain C library for direct embedding. |
See also
/CLAUDE.md— workspace overview./src/parser/(covered in/src/CLAUDE.md) — the consumer that turns the CST into typedPlotvalues./doc/syntax/— authoritative ggsql syntax reference.
In this repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- doc/CLAUDE.mdCLAUDE.md
- ggsql-cli/CLAUDE.mdCLAUDE.md
- ggsql-jupyter/CLAUDE.mdCLAUDE.md
- ggsql-vscode/CLAUDE.mdCLAUDE.md
- ggsql-wasm/CLAUDE.mdCLAUDE.md
- src/CLAUDE.mdCLAUDE.md
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.

