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

cartotree

v0.1.1

Published

AI-friendly codebase mapping CLI — annotated directory trees that save tokens

Readme

🌲 cartotree

AI-friendly codebase mapping CLI — annotated directory trees that save tokens, not just space.

npm version license


The Problem

When you paste your project structure into an AI assistant, two things happen:

  1. Token waste — Raw tree output burns hundreds of tokens on ASCII box characters with zero semantic value.
  2. Hallucination — AI has no idea what each folder does, so it guesses wrong.

The Solution

cartotree generates a compact, annotated map of your codebase — folder descriptions, exported functions, and an AI-optimized serialization format that fits your architecture into a fraction of the tokens.


Quick Start

npx cartotree

No install required.


Output Formats

Default — Annotated ASCII Tree

my-app/
├── src/                    # Core application source
│   ├── components/         # Reusable UI components
│   │   ├── Button.tsx      <Button, ButtonProps>
│   │   └── Modal.tsx       <Modal, useModal>
│   ├── hooks/
│   │   └── useAuth.ts      <useAuth, useUser>
│   └── services/
│       └── api.ts          <fetchUser, postData>
└── package.json

--ai — Token-Optimized Serialization

# cartotree fmt: name{desc}[children]<exports>
my-app{Core application source}[src{Core application source}[components{Reusable UI components}[Button.tsx<Button,ButtonProps>,Modal.tsx<Modal,useModal>],hooks[useAuth.ts<useAuth,useUser>],services[api.ts<fetchUser,postData>]],package.json]

--json — JSON Format

{
  "my-app": {
    "src": {
      "_desc": "Core application source",
      "components": {
        "Button.tsx": ["Button", "ButtonProps"],
        "Modal.tsx": ["Modal", "useModal"]
      }
    }
  }
}

Usage

# Default annotated ASCII tree
npx cartotree

# AI-optimized single-line serialization
npx cartotree --ai

# JSON format
npx cartotree --json

# Copy to clipboard (paste directly into AI)
npx cartotree --ai --copy

# Sync into CLAUDE.md / AGENTS.md
npx cartotree --ai --sync

# Sync into custom file
npx cartotree --sync .cursorrules

# Limit depth
npx cartotree --depth 2

# No depth limit
npx cartotree --full

# Exclude patterns
npx cartotree --exclude "tests,*.log"

# Disable export parsing
npx cartotree --no-exports

Options

| Option | Default | Description | |--------|---------|-------------| | --ai | false | AI-optimized compact serialization | | --json | false | JSON format | | --copy | false | Copy output to clipboard | | --sync [file] | CLAUDE.md | Inject into AI config file | | --depth <n> | 3 | Max traversal depth | | --full | false | No depth limit | | --exclude <patterns> | — | Comma-separated exclude patterns | | --no-exports | false | Disable export parsing |


Configuration

Create .cartotreerc in your project root to set persistent defaults:

{
  "default": {
    "ai": true,
    "exports": false,
    "depth": 3
  }
}

Now npx cartotree automatically runs with --ai --no-exports.


Folder Annotations

Add a .folder.md to any directory — the first line becomes the annotation:

# Reusable UI components
Atomic design system built with Radix UI primitives.

cartotree also falls back to the first line of README.md if no .folder.md exists.


Ignoring Files

Create .cartotreeignore in your project root:

# .cartotreeignore
*.log
temp
coverage
.env*

node_modules, .git, dist, build are excluded by default.


--sync Integration

Running cartotree --sync injects the tree between marker tags:

<!-- CARTOTREE-START -->
(auto-updated on every sync)
<!-- CARTOTREE-END -->

Works with CLAUDE.md, AGENTS.md, .cursorrules, or any file.


Export Parsing

cartotree reads your source files and surfaces exported symbols directly in the tree:

hooks/
└── useAuth.ts  <useAuth, useUser, AuthProvider>

Supports .js, .ts, .jsx, .tsx, .mjs, .cjs.


License

MIT