Synopsis

bash
tsmetrics analyze <PATH>... [OPTIONS]

Arguments

ArgumentRequiredDescription
<PATH>...YesOne or more file paths or directories to analyze (recursive)

Options

FlagShortDefaultDescription
--format <FORMAT>-ftableOutput format: table, json, csv, html
--exclude <PATTERN>see belowGlob pattern(s) to exclude from analysis. Can be specified multiple times.
--verbose-voffReport skipped files to stderr
--min-complexity <N>noneOnly show functions with CC ≥ N
--min-loc <N>noneOnly show functions with LOC ≥ N
--timingoffPrint elapsed time and thread count to stderr after analysis
--versionPrint version and exit
--help-hPrint help and exit

Default exclusions

tsmetrics automatically skips these directories unless you explicitly pass them as a <PATH>:

default excluded paths
node_modules/    .git/    dist/    build/    coverage/    .next/

Use --exclude to add additional patterns on top of the defaults. To analyze a normally-excluded directory, pass it explicitly as a <PATH> argument.

Examples

bash
# Table output (default)
tsmetrics analyze ./src

# JSON output — pipe to jq for querying
tsmetrics analyze ./src --format json | jq '.files[].functions[] | select(.cyclomatic_complexity > 10)'

# CSV output — import into spreadsheet
tsmetrics analyze ./src --format csv > metrics.csv

# Self-contained HTML report
tsmetrics analyze ./src --format html > report.html

# Exclude test files and generated code
tsmetrics analyze ./src --exclude "**/*.test.ts" --exclude "**/*.generated.ts"

# Filter to complex functions only
tsmetrics analyze ./src --min-complexity 10

# Show timing info
tsmetrics analyze ./src --timing

# Verbose — see skipped files
tsmetrics analyze ./src --verbose 2>&1 | grep SKIP

Exit codes

CodeMeaning
0Success
1Error (parse failure, invalid config, etc.)
Note: When using --min-complexity or --min-loc, the summary counts (files, functions) reflect only the filtered results, not the total analyzed.
Edit on GitHub