agentleFS
posit-devposit-dev/ggsql/tree-sitter-ggsql/CLAUDE.md

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
  1. Very specific:

    Add corpus tests under test/corpus/ covering the new construct (and any conflicts).

    line 57
  2. Very specific:

    Update /src/parser/builder.rs to produce the matching AST nodes.

    line 59
  3. Very specific:

    If the new syntax should be highlighted, update queries/highlights.scm.

    line 60
  4. Very specific:

    Document the syntax under /doc/syntax/.

    line 61

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

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 test

In editors with tree-sitter support: npx tree-sitter playground to interactively probe the parser.

Adding new ggsql syntax

  1. Edit grammar.js. Pick node names that downstream code can match against.
  2. Add corpus tests under test/corpus/ covering the new construct (and any conflicts).
  3. npx tree-sitter generate to regenerate src/grammar.json and parser.c. Commit those.
  4. Update /src/parser/builder.rs to produce the matching AST nodes.
  5. If the new syntax should be highlighted, update queries/highlights.scm.
  6. Document the syntax under /doc/syntax/.

Bindings

BindingManifestNotes
RustCargo.toml + bindings/rust/{lib.rs,build.rs}What the workspace uses. Build script compiles src/parser.c.
Nodepackage.json + binding.gyp + bindings/node/Default main. Used by the npm package.
Pythonpyproject.toml + setup.py + bindings/python/Published to PyPI.
Cbindings/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 typed Plot values.
  • /doc/syntax/ — authoritative ggsql syntax reference.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.