Skip to content

Quick Start

This guide walks you from install to parsing, code intelligence, and LLM chunking.


Terminal window
pip install tree-sitter-language-pack

Parsers download automatically on first use. For production, CI, Docker, or offline environments, pre-download them.

CLI
# Download specific languages
ts-pack download python javascript rust go
# Download all available languages
ts-pack download --all
# Download a language group
ts-pack download --groups web,systems
# Fresh download (clear cache first)
ts-pack download --fresh python
# Check what's cached
ts-pack list --downloaded
Terminal window
ts-pack download --all

Groups bundle related languages: web, systems, scripting, data, jvm, functional.

Terminal window
# Download all web languages (HTML, CSS, JS, TS, Vue, Svelte, …)
ts-pack download --groups web,data
# See what's cached
ts-pack list --downloaded

Pre-download parsers during your build to avoid runtime network calls:

Dockerfile
FROM python:3.12-slim
RUN pip install tree-sitter-language-pack
# Pre-download at build time — no network needed at runtime
RUN python -c "from tree_sitter_language_pack import download_all; download_all()"
GitHub Actions
- name: Install and pre-download parsers
run: |
pip install tree-sitter-language-pack
python -c "from tree_sitter_language_pack import download; download(['python', 'javascript', 'rust'])"

Declare which languages your project needs in a language-pack.toml:

language-pack.toml
languages = ["python", "javascript", "rust", "go"]
# groups = ["web", "systems"]
# cache_dir = "/tmp/parsers"

Then download everything declared in the config:

Terminal window
# Reads language-pack.toml automatically
ts-pack download

Build a concrete syntax tree from source code.

CLI
# Download parsers
ts-pack download python javascript rust
# Parse a file
ts-pack parse main.py --format json
# Run code intelligence
ts-pack process src/app.py --all
# List available languages
ts-pack list --manifest

Go beyond the raw syntax tree. Extract functions, classes, imports, docstrings, and more with process.

CLI
# Parse and show S-expression
ts-pack parse main.py --language python
# Parse as JSON
echo "fn main() {}" | ts-pack parse - --language rust --format json
# Full code intelligence
ts-pack process src/app.py --language python --all
# Structure + imports only
ts-pack process src/app.py --structure --imports

process() covers the built-in intelligence fields. There is no public extract() helper for arbitrary query execution. For custom analysis, fetch bundled query source with helpers such as get_tags_query(), then run tree-sitter query APIs yourself or walk the AST manually.

from tree_sitter_language_pack import get_tags_query
tags_query = get_tags_query("python")
if tags_query is not None:
print(tags_query.splitlines()[0])

Split code at natural boundaries so language models receive coherent, complete units which is ideal for embedding pipelines and context windows.

from tree_sitter_language_pack import process, ProcessConfig
with open("large_module.py") as f:
source = f.read()
config = ProcessConfig(
language="python",
chunk_max_size=1500, # max bytes per chunk
structure=True,
)
result = process(source, config)
for i, chunk in enumerate(result.chunks):
print(f"Chunk {i}: lines {chunk.start_line}-{chunk.end_line} "
f"({chunk.end_byte - chunk.start_byte} bytes)")

You now have the full workflow. You can now install, download, parse, extract intelligence, inspect query sources, and chunk for LLMs. Go further with the following guides: