code-snapshot
v0.0.1
Published
_description_
Readme
Code-Snapshot
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-snapshotQuick 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 -cUsage
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/projectAdvanced 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 --hiddenMarkdown 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 -cCombined 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
.gitignorein the target directory - Pattern matching - Supports wildcards (
*.log), directories (dist/), etc. - Layered filtering - Combines default patterns + .gitignore + custom
--ignorepatterns - No configuration needed - Works out of the box with existing projects
Default Ignore Patterns
node_modules.gitdistbuild.DS_Storepnpm-lock.yamlpackage-lock.jsonyarn.lock
Platform Support
Clipboard Requirements
- macOS:
pbcopy(built-in) - Windows:
clip(built-in) - Linux: Install
xcliporxsel
# Ubuntu/Debian
sudo apt-get install xclip
# Fedora/RHEL
sudo dnf install xclip
# Arch Linux
sudo pacman -S xclipUse 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 -cfor quick directory structure sharing - Use
cs -md -cto copy entire project code to clipboard - Combine with other tools:
cs -md -c && echo "Project snapshot copied!" - Use
--depthto limit output for large projects - The tool automatically respects your project's
.gitignore
License
MIT
