
Product
Introducing Webhook Events for Pull Request Scans
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
@zapier/stubtree
Advanced tools
CLI tool to generate ASCII tree of project structure with symbol stubs using universal-ctags
Generate a bird's-eye view of your codebase with all the important symbols (functions, classes, methods) shown inline. Perfect for documentation, code reviews, or understanding new projects.
$ stubtree --root ./src --lang ts
src/
βββ index.ts
β βββ class FileProcessor
β β βββ constructor(options: ProcessorOptions)
β β βββ processDirectory(dirPath: string): Promise<TreeNode>
β β βββ shouldIgnoreFile(filePath: string): boolean
βββ parser.ts
β βββ parseTags(input: string): Promise<Tag[]>
β βββ interface Tag
β βββ name: string
β βββ path: string
β βββ kind: string
βββ renderer.ts
βββ renderTree(node: TreeNode, options?: RenderOptions): string
βββ formatSymbol(tag: Tag): string
stubtree is a CLI tool that combines the power of ctags with a clean tree visualization to help you quickly understand any codebase. Unlike regular tree commands that only show files and folders, stubtree extracts and displays the actual code structure - classes, methods, functions, and more - giving you instant insight into how a project is organized.
Perfect for AI coding assistants: Tools like Claude, GitHub Copilot, and Cursor can better understand your codebase when provided with stubtree's structured output, leading to more accurate suggestions and refactoring.
# Install globally
npm install -g @zapier/stubtree
# Or with yarn
yarn global add @zapier/stubtree
# Or use directly with npx
npx @zapier/stubtree
stubtree requires ctags
:
# macOS
brew install ctags
# Ubuntu/Debian
sudo apt-get install ctags
# Scan current directory
stubtree
# Scan specific directory with TypeScript files
stubtree --root ./src --lang ts,tsx
# Limit depth for large projects
stubtree --depth 3
# Export as JSON for processing
stubtree --json > structure.json
--root <dir>
- Root directory to scan (default: current directory)--lang <globs>
- Comma-separated file extensions to include (e.g., py,ts,tsx
)--depth <n>
- Maximum directory depth to traverse--json
- Output raw JSON instead of ASCII treestubtree --root ./src --lang ts,tsx,js,jsx
Output:
src/
βββ main.ts
β βββ init_app() -> void
β βββ class Service
β βββ start() -> Promise<void>
β βββ stop() -> Promise<void>
βββ utils/
βββ io.ts
βββ read(path: string) -> string
βββ write(path: string, data: string) -> void
stubtree --root ./myproject --lang py --depth 2
stubtree --json > project-structure.json
stubtree combines the power of ctags with Node.js's streaming capabilities to efficiently parse and render your codebase:
Symbol Extraction: We spawn ctags
as a child process with specific flags:
ctags --output-format=json --fields=+neKStr --extras=+q --sort=no -R .
--output-format=json
: Outputs newline-delimited JSON, one symbol per line--fields=+neKStr
: Includes line numbers, end lines, kind info, scope, type refs, and roles--extras=+q
: Includes extra tag information like signatures--sort=no
: Preserves file discovery order-R
: Recursively scans directoriesStreaming JSON Parser: Instead of loading all ctags output into memory, we use Node's readline
interface to process the JSON stream line-by-line. Each line contains a symbol like:
{"name":"readFile","path":"/project/src/io.ts","kind":"function","signature":"(path: string): Promise<string>"}
Tree Building: We build the tree structure in two passes:
Smart Filtering:
--depth
limits and ignores common non-source directoriesASCII Rendering: The tree renderer uses a recursive algorithm with careful prefix tracking:
βββ
for non-last itemsβββ
for last itemsβ
for continuation linesColor Support: We detect TTY output using Node's isatty()
and apply colors via chalk:
commander
for CLI parsing and chalk
for colorsstubtree is designed to be fast, typically scanning and rendering a project tree in under 1 second on a typical laptop.
# Install dependencies
npm install
# Run in development mode
npm run dev
# Run tests
npm test
# Build
npm run build
# Lint
npm run lint
# Type check
npm run typecheck
MIT
FAQs
CLI tool to generate ASCII tree of project structure with symbol stubs using universal-ctags
The npm package @zapier/stubtree receives a total of 86 weekly downloads. As such, @zapier/stubtree popularity was classified as not popular.
We found that @zapier/stubtree demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 277 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checksβbuilt on trusted open source tools, ready to run out of the box.