Skip to main content

A tool to create readable snapshots of your codebase

Project description

SnapGPT 📸

SnapGPT is a command-line utility that creates a single, well-organized snapshot of your codebase. It's especially handy for sharing your project context with AI coding assistants (like ChatGPT) while keeping your code local. By default, SnapGPT automatically opens the snapshotted code file in Cursor, so that on the ChatGPT Desktop app your code repository is "autofocused" and you can start asking ChatGPT questions right away—no copy and pasting required. You can configure it to open in other editors as well (VS Code, Windsurf, Zed, Xcode, or any other editor).

SnapGPT crawls through your directories, gathers all relevant code files (based on your config and preferences), and concatenates them into one text file for easy reading or chat-pasting.

Table of Contents


Features ✨

  • Collect code from multiple directories into a single output file
  • Select specific files to include instead of scanning directories
  • Automatically exclude certain directories (e.g., __pycache__, .git, node_modules)
  • Smart directory scanning safety:
    • Warns when scanning non-Git directories (helps prevent accidental scanning of non-project folders)
    • Detects and warns about system directories (Windows, macOS, Linux) to prevent accidental system scanning
    • Requires explicit confirmation before scanning sensitive directories
  • Configurable file extensions (e.g., .py, .js, .tsx) so you can include exactly what you want
  • Auto-open the snapshot in an editor of your choice (Cursor, VS Code, Windsurf, Zed, Xcode, or fallback to your system default)
  • Auto-copy to clipboard - Automatically copy the snapshot to your clipboard (configurable)
  • First-time setup wizard - Interactive setup to choose your preferred editor and clipboard settings
  • Cross-platform editor support - Improved support for editors across Windows, Mac, and Linux
  • Lightweight and has minimal dependencies
  • Local only: SnapGPT does not make any network calls, keeping your code fully private

Installation 🚀

macOS (Recommended)

Using Homebrew:

brew install halfprice06/homebrew-tap-snapgpt/snapgpt

Using pipx (recommended for Python CLI tools):

# Install pipx if you haven't already
brew install pipx
pipx ensurepath

# Install snapgpt
pipx install snapgpt

Other Methods:

Using pip:

pip install --user snapgpt

Using a virtual environment:

python3 -m venv myenv
source myenv/bin/activate
pip install snapgpt

SnapGPT requires Python 3.7+. It is tested on Linux, macOS, and Windows.

Quick Start 🏃‍

When you run SnapGPT for the first time, you'll be greeted with a setup wizard:

Welcome to snapgpt! Let's set up your preferences.

Available editors:
1. Cursor
2. Code
3. Windsurf
4. Zed
5. Xcode

Which editor would you like to use as default? (enter number): 
Would you like snapshots to be automatically copied to clipboard? (y/n): 

After setup, simply run:

snapgpt

By default, SnapGPT will:

  1. Recursively scan the current directory (.)
  2. Exclude folders such as __pycache__, .git, node_modules, etc.
  3. Include files with extensions like .py, .js, .md, .json, and more
  4. Save everything to full_code_snapshot.txt
  5. Open that file in your chosen editor
  6. Copy the content to your clipboard (if enabled)

You will see:

  1. A directory tree at the top of full_code_snapshot.txt
  2. Followed by the full text of every included file, separated by headers indicating file paths

This single file is perfect for sharing with ChatGPT or any other AI coding assistant (or just for your own review)!

Usage 📝

snapgpt [options]

Common Options 🛠️

Option / Flag Description
-d, --directories List of directories to scan (default: .)
-f, --files List of specific files to include (overrides directory scanning)
-o, --output Output file path (default: full_code_snapshot.txt)
-e, --extensions File extensions to include (e.g. -e .py .js .md)
--exclude-dirs Directories to exclude from scanning
--no-open Do not automatically open the snapshot after creation
--no-copy Do not copy the snapshot to clipboard
--editor {cursor,code,windsurf,zed,xcode} Editor to open the snapshot in
--set-default-editor Set the default editor globally
--set-default-extensions Set the default file extensions globally
--set-default-exclude-dirs Set the default excluded directories globally
--max-size Maximum file size in MB to include (0 for no limit)
--max-depth Maximum directory depth to traverse (0 for no limit)
-q, --quiet Suppress progress and non-error messages

Example Commands 💡

  1. Include specific files only:
snapgpt -f src/main.py tests/test_main.py README.md
  1. Scan only the src and lib directories, exclude dist:
snapgpt -d src lib --exclude-dirs dist
  1. Set default editor to VS Code, then quit immediately:
snapgpt --set-default-editor code
  1. Use a max file size limit of 1 MB (1,000,000 bytes) and a max depth of 5 subdirectories:
snapgpt --max-size 1 --max-depth 5

Configuration ⚙️

SnapGPT reads configuration from ~/.config/snapgpt/config.json, which is created during first-time setup or with defaults if you skip the setup.

Example config:

{
  "default_editor": "cursor",
  "auto_copy_to_clipboard": true,
  "first_time_setup_done": true,
  "file_extensions": [".py", ".js", ".ts", ".md", ".json"],
  "exclude_dirs": ["__pycache__", ".git", "node_modules", "build"]
}

You can update these values:

  • Through the first-time setup wizard
  • Using command-line flags like --set-default-editor and --no-copy
  • By directly editing the config file

Privacy and Security 🔒

  • Local Only: SnapGPT does not send your code to any external server or service. It simply reads files from your disk and consolidates them into a single text file.
  • Editor Launch: If you choose to open the snapshot automatically, SnapGPT will launch your local editor. No additional code upload or syncing occurs.
  • Directory Safety Checks:
    • Warns when scanning directories that are not part of a Git repository to prevent accidental scanning of personal folders
    • Detects and warns about system directories on Windows, macOS, and Linux
    • Requires explicit confirmation before proceeding with potentially sensitive directories
    • Default 'no' response in quiet mode for safety

Troubleshooting 🔧

  1. Git Repository Warning When scanning a directory that contains a .git folder, SnapGPT will warn you that you might be scanning more files than intended. You can:
  • Choose to continue by typing 'y'
  • Cancel and use more specific paths with -d or -f
  • Use --max-depth to limit the scan depth
  1. Command Not Found Make sure you installed SnapGPT in a directory on your PATH. Try:
pip show snapgpt

If it's not in your PATH, you may need to use python -m snapgpt ... or add the script's location to your PATH.

  1. Permission Denied On some systems, certain directories may be locked down. SnapGPT will skip unreadable directories and display a warning.

  2. No Files Found If your project has unusual file extensions, add them with --extensions .mjs .hbs or via the default config.

  3. Editor Not Opening Confirm your chosen editor (Cursor, VS Code, Windsurf, Zed, or Xcode) is installed and accessible from the command line. Note that Xcode is only available on macOS systems. On Windows, SnapGPT will attempt various fallback methods if cursor is your default editor but not found in your PATH.

Contributing 🤝

Contributions are welcome! If you have ideas for new features or find a bug:

  1. Fork the repo and create a branch for your changes
  2. Submit a pull request with a clear explanation and relevant details
  3. We'll review and merge if it aligns with the project's goals

Please ensure your code follows best practices and is well-documented.

License 📄

This project is licensed under the MIT License. Feel free to use, modify, and distribute the code in accordance with the license terms.

Happy snapping! 🎉 If you have any questions or feedback, feel free to open an issue or start a discussion.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snapgpt-0.2.0.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snapgpt-0.2.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file snapgpt-0.2.0.tar.gz.

File metadata

  • Download URL: snapgpt-0.2.0.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.6

File hashes

Hashes for snapgpt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ee9fd53d300aeeb67ced189bfefdc52317289cdfa026a7189a5e22400f1545e3
MD5 d52dffa68d4fe0ff785bccd53d54c267
BLAKE2b-256 e3aed2c2fe3b0e38b782016a293ec39632041c3a398e69cbb468f43166020fde

See more details on using hashes here.

File details

Details for the file snapgpt-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: snapgpt-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.6

File hashes

Hashes for snapgpt-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a4ce0b7d5fbe68ab02d50a0024260f590135fa20292266c1efc013dd95c6d30
MD5 e3f550b5e253d72f43f93a622d672dff
BLAKE2b-256 231470431171ab01b18926c0997082e64e51b13b9d2ff910b062987401005c9c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page