twig

A context-efficient Linux directory tree viewer with plain output shared by humans, agents, scripts, and logs.

Human & AI
published v0.4.3first release Apr 27, 2026LinuxRustMIT

Architecture before contents

twig answers “what is the shape of this project?” first. Directories appear by default. Files, metadata, sorting, and alternate output formats are explicit additions. Plain whitespace carries the hierarchy without a decorative layer.

Published output

$ twig -L 2 twig-v0.4.3/
  twig-v0.4.3
    bench
    src
    tests
| 4 directories

Common paths

twig                 # directories
twig -f              # include files
twig -L 2            # depth limit
twig -s              # payload sizes
twig -t              # descendant time
twig --json          # structured output
twig --md            # Markdown output

The example above was reproduced with the published v0.4.3 x86_64 binary against its release source archive. Empty directories remain visible; symlinks are not followed; files stay behind -f.

Published measurements

32–77%
fewer tokens than matching tree output
17–169
tokens from twig -L 2
193.6 ms
largest recorded default walk
3
published Linux architectures

The v0.4.3 benchmark used four real directory trees ranging from 35 to 18,235 lines of default tree output. The savings grew with the amount of repeated path and box-drawing structure.

Token cost on the four recorded trees

Treetree -dtwigSavedtreetwig -fSaved
Tiny522944%35124032%
Small43720852%1,7261,03840%
Medium24,7577,38370%299,220100,96366%
Large33,1427,66977%377,409105,03672%

Warm-cache walk time

Treefind dirstree -dtre -dtwigtreetretwig -f
Small8.7 ms4.2 ms4.2 ms5.4 ms4.5 ms
Medium98.9 ms194.5 ms265.2 ms135.4 ms441.6 ms577.6 ms141.2 ms
Large952.4 ms229.0 ms281.6 ms193.6 ms438.5 ms611.3 ms192.3 ms

Read the numbers narrowly. This was one Intel Linux machine on ext4, using warm state, hyperfine -N --warmup 10 --min-runs 1000, and the cl100k_base tokenizer. Small-tree differences fall inside measurement noise. find was faster on the medium directory-only tree. Absolute results depend on hardware, filesystem state, ignored directories, output scope, and tokenizer.

Design contract

Defaults

  • Directories first; files require -f.
  • Plain two-space indentation without box drawing.
  • No configuration file, theme, icons, or color.
  • Empty directories remain information unless pruned.
  • No ignore-file interpretation in published v0.4.3.

Cost and safety

  • The default path performs no per-entry metadata collection.
  • Size and time work occurs only when requested.
  • Published v0.4.3 is read-only and follows no symlinks.
  • It makes no network connections or subprocess calls.
  • JSON is the safe mode for filenames containing control characters.

-s reports visible descendant file payload, not filesystem block allocation. Use du for disk accounting and dust for proportional disk-use visualization.

Lineage and acknowledgment

tree defined this category and remains the right tool for many jobs. twig is not presented as its replacement; it chooses a different default for the narrower question of project shape.

Tree output

tree supplied the category and baseline. tre, eza, and erdtree demonstrate Rust implementations, Git-aware traversal, structured output, and alternative layouts.

Navigation

broot, lstr, tere, and walk explore truncation, interactive navigation, and folders-first workflows that twig deliberately leaves to interactive tools.

Measurement and machine context

GNU find, GNU du, and dust are the filesystem baselines. Repomix treats token budgeting as a first-class concern. stump is a reference for tree data exposed through machine-oriented protocols.

Built by Nate Rich through iterative, machine-assisted development. These open-source projects supplied the category, design contrasts, and measurement baselines; release judgment and responsibility remain human.

Download v0.4.3

Release boundary: v0.4.3 is the published site and GitHub release. Local v0.4.4 development refines compact counting, metadata notation, and explicit ignore controls; it is not presented here as a released binary.

Manual install

sha256sum -c sha256.txt --ignore-missing
tar -xzf twig-v0.4.3-x86_64-unknown-linux-gnu.tar.gz
sudo install -m 755 twig-v0.4.3-x86_64-unknown-linux-gnu/twig /usr/local/bin/twig
twig --version