npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

contextree

v1.0.3

Published

AI-optimized project tree — fast, filtered, context-ready

Readme

directree

AI-optimized project tree. Fast. Efficient. Context-ready.

directree gives you a clean, signal-rich view of your project structure — purpose-built for pasting into AI context windows. Filters noise automatically, adds semantic annotations, and estimates token cost.

my-app/
├── src/  [source-root]
│   ├── app/  [app-router]
│   │   ├── layout.tsx  [layout]
│   │   ├── page.tsx  [page]
│   │   └── dashboard/
│   │       └── page.tsx  [page]
│   ├── components/  [ui-components]
│   │   └── Button.tsx  [ui-component]
│   └── lib/
│       └── supabase.ts  [db-client]
├── next.config.js  [config]
└── package.json  [manifest]

Install

via npm (Recommended)

npm install -g contextree

Note: This installs the CLI under the package name contextree, making both contextree and directree commands available on your system.

via cargo

git clone https://github.com/ayushcody/directree
cd directree
cargo install --path .

Add aliases to your shell:

alias dt="contextree"
alias dta="contextree --ai"
alias dtf="contextree --flat"

Usage

contextree [PATH] [OPTIONS]

| Command | What it does | |---------|-------------| | contextree | Tree of current dir | | contextree --ai | AI context-ready XML output with annotations | | contextree --ai --stats | AI output + token cost estimate | | contextree --flat | Flat path list — cheapest token format | | contextree --group | Files grouped by type (source/config/test/asset) | | contextree --format json | Structured JSON tree | | contextree src --depth 3 | Subdir, max 3 levels deep | | contextree --only ts,tsx | Only TypeScript files | | contextree --focus src/components | Zoom into subpath with breadcrumb | | contextree --collapse | Collapse repeated sibling patterns | | contextree --show-ignore | See all active ignore rules | | contextree --stats | File counts + estimated tokens |


The --ai flag

<project_structure lang="typescript" framework="nextjs" files="8" est_tokens="420">
my-app/
├── src/  [source-root]
│   ├── app/  [app-router]
│   │   ├── layout.tsx  [layout]
│   │   └── page.tsx  [page]
│   └── lib/
│       └── supabase.ts  [db-client]
└── package.json  [manifest]
</project_structure>

tokens: ~420  ·  files: 8  ·  ignored: node_modules .git dist build

Paste this directly into Claude or GPT. The XML wrapper, lang/framework attributes, and role annotations give the model everything it needs to understand your structure immediately.


Smart ignore

Built-in ignores that always apply: node_modules .git .DS_Store .idea .vscode .cache coverage .turbo and more.

Framework-aware extras (auto-detected):

  • Next.js.next/ out/ next-env.d.ts
  • Rusttarget/
  • Python__pycache__/ .venv/ dist/
  • Govendor/

Override with a .directreeignore file in your project root (same syntax as .gitignore).

Global config at ~/.directreerc:

default_depth = 4
ignore = ["*.log", "scripts/migrations/", "**/*.generated.ts"]

v0.2 Features

| Feature | Usage | |---------|-------| | Clipboard | directree --ai --copy → output straight to clipboard | | Git diff | directree --since HEAD~1 → only changed files | | Importance | directree --important → ★ marks entry points, hot files, core infra | | Watch mode | directree --watch --ai → live refresh on file save | | Init | directree init → scaffold .directreeignore for your framework | | Completions | directree completions zsh → tab completions for all flags |

Shell setup (one-time)

# Zsh
source <(directree completions zsh)

# Bash
source <(directree completions bash)

# Fish — save to completions dir
directree completions fish > ~/.config/fish/completions/directree.fish

Live AI context refresh workflow

# Terminal 1: keep AI context fresh as you code
directree --watch --ai --copy

# Paste once in Claude/GPT — re-paste after each file save (1 keystroke)

Git diff workflow

directree --since HEAD~1 --ai     # what changed in last commit, AI-ready
directree --since main --ai       # your branch's changes vs main
directree --since HEAD --flat     # uncommitted changes as flat list

| Mode | 50-file project | 500-file project | |------|----------------|-----------------| | --flat | ~200 tokens | ~1,800 tokens | | --tree | ~350 tokens | ~3,000 tokens | | --ai | ~420 tokens | ~3,500 tokens |

For huge monorepos: directree --flat --only ts,tsx keeps context under 500 tokens.


Project structure

src/
├── cli.rs        — Arg parser (zero deps, hand-rolled)
├── config.rs     — ~/.directreerc loader
├── detector.rs   — Framework detection + file role classifier
├── ignorer.rs    — Ignore engine (built-in + framework + .directreeignore + CLI)
├── walker.rs     — FS walker + sibling collapse engine
├── tree.rs       — TreeNode data structure + stats collector
└── render.rs     — All renderers: tree / ai / flat / group / json / stats

Zero external dependencies outside serde/serde_json. Single binary, no runtime.


Built for the AI-native developer workflow.