Tree-sitter CLI
$ tree-sitter Foundation Low Risktree-sitter parses source files into concrete syntax trees, executes .scm Tree-sitter queries, extracts symbol definitions via tree-sitter tags, and builds parser grammars. Parsing and query subcommands are read-only, while generate builds local C parser artifacts.
brew install tree-sitter Running tree-sitter parse or tree-sitter tags directly in the workspace is faster and simpler than wrapping parser calls in MCP.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Non-interactive with --quiet and --xml options, though primary parse output is S-expression text rather than --json.
- Deterministic stdout for
parse,query, andtagssubcommands
Read-only for parse/query/tags; generate only writes parser artifacts when explicitly invoked.
- Separates read-only inspection commands from
generate
Available via brew, npm, cargo, and binaries, though grammar compilation requires a C toolchain.
- Distributed via
brew,npm, andcargo; needs C compiler for grammar builds
Ideal for syntax verification, .scm query debugging, and grammar development.
- First-party parser and query evaluation tool
Core foundation-grade ecosystem project powering Neovim, GitHub code nav, and ast-grep.
- Widely adopted foundation project under MIT
Official CLI reference covers all subcommands and grammar config files.
- Maintained documentation at tree-sitter.github.io
Security, Auth & Guardrails
None required; uses local grammar configs and source files.
100% free, offline, and open-source (MIT).
# tree-sitter Agent Rules - Use `parse`, `query`, and `tags` for read-only inspection; only run `generate` inside grammar repos. - Ensure target language parsers are configured in `~/.config/tree-sitter/config.json` before invoking `parse`.
Agent-Ready Command Recipes
Safe Read-Only Queries
tree-sitter parse --quiet src/parser.rs
Validates syntax and prints parse errors or CST nodes depending on flags.
tree-sitter tags src/main.ts
Outputs discovered function, class, and method definitions using grammar tag queries.
Controlled Writes & Previews
grammar.js tree-sitter generate
Writes updated src/parser.c artifacts inside a Tree-sitter grammar repository.
Strengths for Agents
- + Authoritative parser CLI for validating syntax trees and testing
.scmqueries. - + Available across
brew,npm, andcargo.
Caveats & Pitfalls
- ! Requires local grammar repositories/configs unless run inside a grammar project;
ast-grepis easier for ad-hoc codebase search.