Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

Tree-sitter CLI

$ tree-sitter Foundation Low Risk
Tree-sitter (OSS) · Files & Search · MIT · macos / linux / windows

tree-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.

FCRS-1.0 Score
85 /100
Good
Medium Confidence
Zero-Friction Install
brew install tree-sitter
CLI vs MCP Decision CLI Preferred vs MCP

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

— JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
✓ Read-Only Mode
✓ NO_COLOR Clean
— Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 20 / 25

Non-interactive with --quiet and --xml options, though primary parse output is S-expression text rather than --json.

  • Deterministic stdout for parse, query, and tags subcommands
Trust & Safety 23 / 25

Read-only for parse/query/tags; generate only writes parser artifacts when explicitly invoked.

  • Separates read-only inspection commands from generate
Setup & Portability 12 / 15

Available via brew, npm, cargo, and binaries, though grammar compilation requires a C toolchain.

  • Distributed via brew, npm, and cargo; needs C compiler for grammar builds
Utility & Efficiency 13 / 15

Ideal for syntax verification, .scm query debugging, and grammar development.

  • First-party parser and query evaluation tool
Maintenance & Lineage 9 / 10

Core foundation-grade ecosystem project powering Neovim, GitHub code nav, and ast-grep.

  • Widely adopted foundation project under MIT
Docs & Verifiability 8 / 10

Official CLI reference covers all subcommands and grammar config files.

  • Maintained documentation at tree-sitter.github.io

Security, Auth & Guardrails

Auth Modes
No Auth
Credential Storage

None required; uses local grammar configs and source files.

Side Effects
Read-Only Local Write
Cost & Quotas

100% free, offline, and open-source (MIT).

Copyable Guardrail for CLAUDE.md / AGENTS.md
# 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

Parse a source file into an S-expression CST
tree-sitter parse --quiet src/parser.rs

Validates syntax and prints parse errors or CST nodes depending on flags.

Extract symbol tags from a source file
tree-sitter tags src/main.ts

Outputs discovered function, class, and method definitions using grammar tag queries.

Controlled Writes & Previews

Regenerate C parser files from 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 .scm queries.
  • + Available across brew, npm, and cargo.

Caveats & Pitfalls

  • ! Requires local grammar repositories/configs unless run inside a grammar project; ast-grep is easier for ad-hoc codebase search.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI