tree
$ tree Community Low Risktree renders hierarchical directory layouts with minimal setup. For AI agents, -J emits a clean nested JSON tree, -L caps recursion depth, and --gitignore / -I filter out node_modules and build artifacts.
brew install tree Running tree -J -L 3 directly in the shell gives an instant JSON directory map with zero MCP overhead.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Supports native -J JSON output, -n color suppression, --noreport, and non-interactive stdout.
- Native
-JJSON format and-nplain output flags
Purely read-only local directory listing; never writes files or accesses the network.
- Zero write or network side effects
Packaged in nearly every Linux/macOS package manager (brew, apt, apk, dnf).
- Ubiquitous Unix package availability
Single-command repository topology overview in ASCII or JSON.
-Ldepth limits and-Iglob exclusions prevent context explosion
Long-lived Unix standard maintained upstream with --gitignore added in v2.x.
- Decades-long Unix lineage under GPL-2.0
Standard man page and --help cover all flags clearly.
- Built-in man page and concise
--help
Security, Auth & Guardrails
None required; reads local directory entries only.
100% free, offline, and open-source (GPL-2.0).
# tree Agent Rules - ALWAYS cap depth with `-L 2` or `-L 3` and exclude `node_modules|.git` via `-I` or `--gitignore`. - Pass `-J` for JSON output or `-n` to suppress ANSI colors.
Agent-Ready Command Recipes
Safe Read-Only Queries
tree -J -L 3 -I 'node_modules|.git' --noreport .
Outputs structured JSON of the workspace up to 3 levels deep without summary footers.
.gitignore tree -L 3 --gitignore -n .
Renders an uncolored (-n) tree skipping ignored files (requires tree v2.0+).
Strengths for Agents
- + Zero-risk read-only tool with native
-JJSON hierarchy output. - + Available almost everywhere with intuitive
-Ldepth and-Iignore flags.
Caveats & Pitfalls
- ! Running
treewithout-Lor-Ion a repo withnode_moduleswill flood the agent context window. - !
--gitignorerequirestree2.0+; older distro builds need-Ipatterns.