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

code-snapshot

v0.0.1

Published

_description_

Readme

Code-Snapshot

npm version npm downloads bundle License

A powerful code analysis tool that generates directory trees, extracts file contents, and creates markdown snapshots with intelligent .gitignore integration and clipboard support.

Features

  • 🌳 Directory tree visualization - Clean, readable project structure display
  • 📋 Smart clipboard integration - Automatic copying with cross-platform support
  • 📝 Markdown generation - Convert entire projects to markdown format
  • 🔍 Intelligent .gitignore parsing - Automatically respects project ignore patterns
  • 📁 File & directory support - Handle single files or entire project trees
  • Fast and lightweight - Minimal dependencies, maximum performance
  • 🎯 Flexible filtering - Custom ignore patterns, depth control, and hidden file options

Installation

# Install globally
npm install -g code-snapshot

# Or use with npx
npx code-snapshot

Quick Start

# Display directory tree
cs -t

# Generate markdown with all file contents
cs -md

# Display tree and copy to clipboard
cs -t -c

# Generate markdown and copy to clipboard
cs -md -c

Usage

cs [path] [options]

Basic Commands

# Display directory tree structure
cs -t

# Generate markdown with file contents
cs -md

# Copy output to clipboard
cs -t -c
cs -md -c

# Process specific file or directory
cs -md src/index.ts
cs -t /path/to/project

Advanced Options

# Set maximum depth
cs -t --depth 3
cs -md -d 2

# Show hidden files
cs -t --hidden

# Custom ignore patterns
cs -md --ignore "*.log,temp,cache"

# Combine multiple options
cs -md -c --depth 3 --hidden --ignore "*.tmp"

Command Reference

Arguments

| Argument | Description | |----------|-------------| | path | File or directory path to analyze (default: current directory) |

Options

| Option | Description | |--------|-------------| | -t, --tree | Display directory tree structure | | -md, --markdown | Generate markdown with file contents | | -c, --copy | Copy output to clipboard | | -d, --depth <number> | Maximum depth to traverse (default: 5) | | --hidden | Show hidden files and directories | | --ignore <patterns> | Additional ignore patterns (comma-separated) | | -h, --help | Display help information | | -v, --version | Display version number |

Command Aliases

| Command | Alias | Description | |---------|-------|-------------| | code-snapshot | cs | Main command (recommended) |

Examples

Tree Structure Usage

# Display current directory tree
cs -t

# Display and copy tree structure
cs -t -c

# Analyze specific directory with custom depth
cs -t ~/my-project --depth 4

# Show hidden files and directories
cs -t --hidden

Markdown Generation

# Generate markdown for all files
cs -md

# Generate markdown for specific file
cs -md src/index.ts

# Generate markdown with custom filtering
cs -md --ignore "*.log,node_modules" --depth 3

# Generate and copy markdown
cs -md -c

Combined Usage

# Display tree and generate markdown
cs -t -md

# Full analysis with clipboard copy
cs -t -md -c

# Custom configuration
cs -t -md -c --depth 2 --hidden --ignore "*.tmp"

Sample Output

Tree Structure

my-project/
├── package.json
├── README.md
├── src/
│   ├── index.ts
│   ├── components/
│   │   ├── App.tsx
│   │   └── Header.tsx
│   └── utils/
│       └── helpers.ts
├── tests/
│   └── app.test.ts
└── dist/
    └── index.js

📋 Copied to clipboard!

Markdown Output

// src/index.ts
```typescript
#!/usr/bin/env node
import { createApp } from './app'

function main() {
  const app = createApp()
  app.start()
}

main()

// package.json

{
  "name": "my-project",
  "version": "1.0.0",
  "main": "dist/index.js"
}

📋 Copied to clipboard!

Smart .gitignore Integration

Automatically reads and respects your project's .gitignore file:

  • Automatic detection - Finds .gitignore in the target directory
  • Pattern matching - Supports wildcards (*.log), directories (dist/), etc.
  • Layered filtering - Combines default patterns + .gitignore + custom --ignore patterns
  • No configuration needed - Works out of the box with existing projects

Default Ignore Patterns

  • node_modules
  • .git
  • dist
  • build
  • .DS_Store
  • pnpm-lock.yaml
  • package-lock.json
  • yarn.lock

Platform Support

Clipboard Requirements

  • macOS: pbcopy (built-in)
  • Windows: clip (built-in)
  • Linux: Install xclip or xsel
# Ubuntu/Debian
sudo apt-get install xclip

# Fedora/RHEL
sudo dnf install xclip

# Arch Linux
sudo pacman -S xclip

Use Cases

  • Code Reviews - Share complete project structure and code
  • Documentation - Generate comprehensive project snapshots
  • Debugging - Quickly copy relevant code sections
  • Learning - Analyze project structures and implementations
  • Backup - Create markdown archives of code projects

Tips

  • Use cs -t -c for quick directory structure sharing
  • Use cs -md -c to copy entire project code to clipboard
  • Combine with other tools: cs -md -c && echo "Project snapshot copied!"
  • Use --depth to limit output for large projects
  • The tool automatically respects your project's .gitignore

License

MIT