Zigzag LogoZigZagDocs

API Reference

Complete reference for ZigZag CLI commands, flags, and configuration.

API Reference

Full reference documentation for ZigZag's CLI commands, flags, and configuration file.

Subcommands

CommandDescription
zigzag initCreates zig.conf.json with default values in the current directory. No-ops if the file already exists.
zigzag runLoads zig.conf.json as the base config, then applies any CLI flags on top.

Without a subcommand, ZigZag applies CLI flags directly — no config file is loaded.

CLI Flags

General

FlagTypeDefaultDescription
--versionboolfalseShow ZigZag version
--helpboolfalseShow help information
--logboolfalseEnable logging

Input

FlagTypeDefaultDescription
--pathstringDirectory to scan. Can be specified multiple times for multi-path scanning
--ignorestring[][]Pattern(s) to ignore. Same syntax as ignore_patterns in config

Output

FlagTypeDefaultDescription
--outputstring"report.md"Filename for the Markdown report
--output-dirstring"zigzag-reports"Directory to store generated reports
--jsonboolfalseGenerate a JSON report alongside Markdown
--htmlboolfalseGenerate an interactive HTML dashboard
--portnumberPort for serving the HTML dashboard
--openboolfalseAutomatically open the HTML report in a browser

LLM Reports

FlagTypeDefaultDescription
--llm-reportboolfalseEnable LLM-optimized report generation
--llm-max-linesnumber150Maximum number of lines per file in LLM reports
--llm-descriptionstringnullOptional project description included in LLM reports

Performance

FlagTypeDefaultDescription
--skip-cacheboolfalseSkip cache operations and force a clean rebuild
--smallnumber1048576Threshold (bytes) below which files are read fully into memory
--mmapnumber16777216Threshold (bytes) above which memory-mapped I/O is used
--watchboolfalseEnable watch mode for real-time report updates
--timezonestringnullTimezone offset for timestamps (e.g., "+1", "-5:30")

Configuration File

The zig.conf.json file maps directly to CLI flags. Create one with zigzag init:

{
  "paths": [],
  "ignore_patterns": [],
  "skip_cache": false,
  "skip_git": false,
  "small_threshold": 1048576,
  "mmap_threshold": 16777216,
  "timezone": null,
  "output": "report.md",
  "watch": false,
  "log": false,
  "json_output": false,
  "html_output": false,
  "output_dir": "zigzag-reports",
  "llm_report": false,
  "llm_max_lines": 150,
  "llm_description": null
}

Config Fields

FieldTypeDefaultDescription
pathsstring[][]Directories to scan
ignore_patternsstring[][]Patterns to exclude from scanning
skip_cacheboolfalseBypass the cache and rebuild from scratch
skip_gitboolfalseSkip .git directory detection
small_thresholdnumber1048576File size limit (bytes) for full in-memory reads
mmap_thresholdnumber16777216File size limit (bytes) for memory-mapped I/O
timezonestring|nullnullTimezone offset for report timestamps
outputstring"report.md"Output filename for Markdown reports
watchboolfalseEnable filesystem watch mode
logboolfalseEnable logging output
json_outputboolfalseGenerate JSON reports
html_outputboolfalseGenerate HTML dashboards
output_dirstring"zigzag-reports"Output directory for all reports
llm_reportboolfalseEnable LLM-optimized reporting
llm_max_linesnumber150Max lines per file in LLM reports
llm_descriptionstring|nullnullProject description for LLM reports

Output Formats

Markdown Report

The default output. Each scanned directory gets a report.md containing:

  • A header with the scanned path and generation timestamp
  • A table of contents linking to every file
  • Each file's metadata (size, language, last modified) followed by its syntax-highlighted source code

JSON Report

Enabled with --json. Written as report.json next to the Markdown file. Contains structured metadata: version info, summary statistics, per-file details (path, size, language, line count), and detected binary files.

HTML Dashboard

Enabled with --html. A single self-contained .html file with all assets bundled. Features summary cards, language charts, size distribution, sortable file table, source viewer with syntax highlighting, virtual scrolling for large files, and automatic dark mode.

File Reading Strategies

ZigZag automatically selects the optimal reading strategy based on file size:

File SizeStrategyDescription
0 – 1 MiBreadFileAllocLoad entire file into memory
1 – 16 MiBreadFileMappedMemory-mapped I/O (platform-specific)
> 16 MiBreadFileChunkedStream in chunks

Thresholds are configurable with --small and --mmap flags.

Processing Pipeline

  1. Argument Parsing — Parse CLI flags and configuration
  2. Config File Loading — Apply zig.conf.json as base (when using run)
  3. Cache Initialization — Load and validate cache, remove stale entries
  4. Thread Pool Setup — Configure parallel workers based on CPU cores
  5. Directory Traversal — Walk each specified path
  6. File Filtering — Apply ignore patterns and binary detection
  7. File Processing — Read, cache, and collect metadata in parallel
  8. Report Generation — Generate outputs (Markdown, JSON, HTML)
  9. Cleanup — Save cache, free resources

Statistics

After each run, ZigZag reports processing statistics in three categories:

CategoryDescription
CachedFiles read from cache (unchanged since last run)
ProcessedFiles that were read and processed (new or modified)
IgnoredFiles excluded by patterns or binary detection

On this page