Skip to content

CLI reference

ts-pack downloads tree-sitter parsers and runs code intelligence from the command line.

Installation

cargo install ts-pack-cli
brew install kreuzberg-dev/tap/ts-pack

Verify the install:

ts-pack --version

Commands

Command What it does
download Download parser libraries
clean Remove cached parsers
list List available languages
info Show details about a language
parse Parse a file and output the syntax tree
process Run code intelligence on a file
cache-dir Print the cache directory path
init Create a language-pack.toml config file
completions Generate shell completions

ts-pack download

Download parser libraries to the local cache.

ts-pack download [LANGUAGES...] [OPTIONS]
Flag Description
--all Download all 306 parsers
--groups <groups> Download by group (comma-separated: web, systems, scripting, data, jvm, functional)
--fresh Clear the cache before downloading
# Download specific parsers
ts-pack download python javascript typescript

# Download everything
ts-pack download --all

# Re-download from scratch, ignoring the cache
ts-pack download python --fresh

# Download a group
ts-pack download --groups web,systems

# Download whatever languages-pack.toml specifies (if one is found)
ts-pack download

Without arguments and with no language-pack.toml present, the command exits with an error.


ts-pack clean

Remove all cached parser libraries. Prompts for confirmation unless you pass --force.

ts-pack clean [OPTIONS]
Flag Description
--force Skip the confirmation prompt
ts-pack clean          # prompts: "Continue? [y/N]"
ts-pack clean --force  # no prompt

ts-pack list

List available languages.

ts-pack list [OPTIONS]
Flag Description
--downloaded Show only locally cached parsers
--manifest Show all languages from the remote manifest (default)
--filter <text> Filter by substring
ts-pack list                    # all available languages
ts-pack list --downloaded       # only what's in the cache
ts-pack list --filter script    # languages whose name contains "script"

ts-pack info

Show details about a specific language.

ts-pack info <LANGUAGE>
ts-pack info python

Output when the parser has downloaded:

Language:    python
Known:       true
Downloaded:  true
Cache path:  /home/user/.cache/tree-sitter-language-pack/libtree_sitter_python.so

Before the parser downloads, Cache path shows the cache directory instead.


ts-pack parse

Parse source code and output the syntax tree.

ts-pack parse <FILE> [OPTIONS]

Use - as FILE to read from stdin (requires --language).

Flag Description
--language <lang>, -l Language name. Auto-detected from the file extension if omitted.
--format <fmt>, -f sexp (default) or json
ts-pack parse src/main.py
ts-pack parse src/main.py --format json
echo "def hello(): pass" | ts-pack parse - --language python

Sample sexp output:

(module
  (function_definition
    name: (identifier)
    parameters: (parameters)
    body: (block
      (expression_statement
        (call ...)))))

The JSON format wraps the sexp string alongside the language name and an has_errors boolean.


ts-pack process

Run code intelligence on a source file and output structured JSON.

ts-pack process <FILE> [OPTIONS]

Use - as FILE to read from stdin. When reading from stdin, you must pass --language.

Flag Description
--language <lang>, -l Language name. Auto-detected from extension if omitted.
--all Enable all analysis features
--structure Extract functions, classes, and methods
--imports Extract import statements
--exports Extract exported symbols
--comments Extract comments
--symbols Extract all identifiers
--docstrings Extract docstrings
--diagnostics Report syntax errors
--chunk-size <n> Split output into chunks of at most n bytes

Without any feature flags, the default extracts structure, imports, and exports.

# Full analysis
ts-pack process src/app.py --all

# Structure only
ts-pack process src/app.py --structure

# Chunk a large file for LLM ingestion
ts-pack process large_module.py --chunk-size 800

# From stdin
cat src/main.go | ts-pack process - --language go --imports

ts-pack cache-dir

Print the effective cache directory path.

ts-pack cache-dir
# /home/user/.cache/tree-sitter-language-pack

# Use in scripts
CACHE=$(ts-pack cache-dir)
du -sh "$CACHE"

ts-pack init

Create a language-pack.toml config file in the current directory.

ts-pack init [OPTIONS]
Flag Description
--cache-dir <path> Set a custom cache directory in the generated file
--languages <langs> Comma-separated languages to pre-fill
ts-pack init
ts-pack init --languages python,javascript,typescript,rust

Generated file (empty init):

# language-pack.toml
# languages = ["python", "rust"]

With --languages python,rust:

languages = ["python", "rust"]

After init, run ts-pack download to fetch the listed parsers.


ts-pack completions

Generate shell completion scripts.

ts-pack completions <SHELL>

Supported: bash, zsh, fish, powershell, elvish.

ts-pack completions bash >> ~/.bash_completion
ts-pack completions zsh > ~/.zsh/completions/_ts-pack
ts-pack completions fish > ~/.config/fish/completions/ts-pack.fish

Exit codes

Code Meaning
0 Success
1 Error — message printed to stderr

Use in CI

Pre-download parsers and cache them between runs:

- name: Install ts-pack
  run: cargo install ts-pack-cli

- name: Cache parsers
  uses: actions/cache@v4
  with:
    path: ~/.cache/tree-sitter-language-pack
    key: tslp-${{ hashFiles('language-pack.toml') }}

- name: Download parsers
  run: ts-pack download

- name: Analyze
  run: ts-pack process src/main.py --all