A powerful code analysis tool that generates directory trees, extracts file contents, and creates markdown snapshots with intelligent .gitignore integration and clipboard support.
- π³ 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
# Install globally
npm install -g code-snapshot
# Or use with npx
npx code-snapshot# 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 -ccs [path] [options]# 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# 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"| Argument | Description |
|---|---|
path |
File or directory path to analyze (default: current directory) |
| 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 | Alias | Description |
|---|---|---|
code-snapshot |
cs |
Main command (recommended) |
# 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# 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# 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"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!// 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!
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
node_modules.gitdistbuild.DS_Storepnpm-lock.yamlpackage-lock.jsonyarn.lock
- 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 xclip- 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
- 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
MIT