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

repo-extract

v0.4.4

Published

CLI tool to analyze and create text dumps of codebases for LLMs

Readme

repo-extract

Extract repository content into a formatted text dump for LLM analysis. Perfect for analyzing codebases with AI models like DeepSeek, OpenAI, or other LLMs.


Features

  • Extract Repository Content: Dump entire repositories or specific files into a structured format.
  • Multiple Output Formats: Supports text, json, and markdown formats for flexibility.
  • Customizable Filters: Include or exclude files using glob patterns.
  • Token Estimation: Estimates token count for LLM compatibility.
  • Chunking Support: Split large repositories into smaller chunks for LLMs with token limits.
  • CLI and Package: Use as a command-line tool or integrate into your Node.js projects.

Why Use This?

  • AI-Powered Code Analysis: Prepare repository content for AI-driven code reviews, documentation, or analysis.
  • Customizable Outputs: Tailor the output to your needs with flexible formatting and filtering options.
  • Handles Large Repositories: Use the chunkSize option to process repositories that exceed LLM token limits.
  • Easy Integration: Works as a CLI tool or a Node.js package for seamless integration into your workflow.

Install

As a CLI Tool

npm install -g repo-extract

As a Package

npm install repo-extract


Usage

CLI

repo-extract https://github.com/user/repo

Creates output.txt with repository content

Package

import { extract } from 'repo-extract';

const { summary, tree, content, stats, tokens } = await extract({
  source: 'https://github.com/user/repo',    // Repository URL or local path
  output: 'output.txt',                      // Optional: output file path
  format: 'text',                            // Optional: 'text' | 'json' | 'markdown' (default: text)
  includePatterns: ['src/**/*.ts'],          // Optional: files to include
  excludePatterns: ['**/*.test.ts'],         // Optional: files to exclude
  maxFileSize: 10485760,                     // Optional: max file size in bytes (default: 10MB)
  chunkSize: 32000                           // Optional: max tokens per chunk (default: no chunking)
});

// Returns:
// - summary: Overview of processed files, sizes, and tokens
// - tree: Repository file structure visualization
// - content: Extracted contents in the specified format
// - stats: Detailed analysis statistics
// - tokens: Estimated token count

Options

CLI Options

  • -o, --output : Custom output file path.
  • -f, --format : Output format: text, json, or markdown (default: text).
  • --include-docs: Include documentation files (e.g., README, markdown files).
  • -i, --include : Include specific files using glob patterns (e.g., src/**/*.ts).
  • -e, --exclude : Exclude specific files using glob patterns (e.g., **/*.test.ts).
  • -s, --max-size : Max file size to process in bytes (default: 10MB).
  • --chunk-size : Max tokens per chunk (default: no chunking). Useful for LLM token limits.

Package Options

  • source: Repository URL or local path.
  • maxFileSize: Max file size in bytes (default: 10MB).
  • includePatterns: Array of glob patterns to include (e.g., ['src/**/*.ts']).
  • excludePatterns: Array of glob patterns to exclude (e.g., ['**/*.test.ts']).
  • output: Output file path (optional).
  • format: Output format: text, json, or markdown (default: text).
  • chunkSize: Max tokens per chunk (optional). Useful for LLM token limits.

Examples

CLI Examples

Extract a GitHub Repository

repo-extract https://github.com/user/repo

#### Extract Current Directory as JSON
repo-extract . -f json

#### Extract Only Source Code, Exclude Tests, and Output as JSON
repo-extract . -i "src/**/*.ts" -e "**/*.test.ts" -f json

#### Extract Content from a GitHub Repo and Output as Markdown (Exclude Documentation Files)
repo-extract https://github.com/user/repo -f markdown --exclude-docs

#### Extract with Chunking for LLM Token Limits
repo-extract https://github.com/user/repo --chunk-size 32000

Package Examples

Basic Usage

import { extract } from 'repo-extract';

const { summary, content } = await extract({
  source: '.',
  format: 'json'
});

Advanced Usage with Multiple Options

const result = await extract({
  source: 'https://github.com/user/repo',
  format: 'markdown',
  includePatterns: ['src/**/*.ts'],
  excludePatterns: ['**/*.test.ts'],
  chunkSize: 32000
});

Advanced Usage

Chunking for Large Repositories

If your repository exceeds the token limit of your LLM (e.g., 32k tokens for DeepSeek), use the chunkSize option to split the content into smaller chunks.

const result = await extract({
  source: 'https://github.com/user/repo',
  chunkSize: 32000 // Split content into 32k token chunks
});

Custom Output Formats

Choose from text, json, or markdown formats to suit your needs.

const result = await extract({
  source: 'https://github.com/user/repo',
  format: 'markdown' // Output as Markdown
});

Filtering Files

Use includePatterns and excludePatterns to focus on specific files or directories.

const result = await extract({
  source: 'https://github.com/user/repo',
  includePatterns: ['src/**/*.ts'], // Include only TypeScript files
  excludePatterns: ['**/*.test.ts'] // Exclude test files
});

License

This project is licensed under the MIT License.