Skip to content

Snapcube is a powerful CLI tool that allows you to save your project structure to JSON and recreate it anywhere. Perfect for project templates, backups, or sharing project scaffolds with your team.

License

Notifications You must be signed in to change notification settings

tanmayvaij/snapcube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Snapcube

License: MIT npm

πŸ“– Full Documentation β†’ https://snapcube.netlify.app

Clone and recreate complete project structures in seconds! πŸš€

Snapcube is a lightweight CLI tool that snapshots your project's entire directory tree (including or excluding file contents) into a single JSON file β€” and recreates it anywhere instantly. Perfect for templates, backups, AI-assisted reviews, and team sharing.


✨ Features

  • πŸ“¦ Local Project Cloning – Save your project's structure and contents into JSON
  • 🌐 GitHub Repo Cloning – Fetch any public GitHub repository directly into JSON (no manual download needed)
  • 🦊 GitLab Repo Cloning – Fetch GitLab repositories with full support for public and private repos
  • πŸ”‘ Private Repo Cloning – Clone private GitHub/GitLab repositories by passing a Personal Access Token (--token)
  • πŸ— Project Creation – Rebuild projects exactly from saved JSON
  • 🚫 Smart Filtering – Skips unnecessary directories like node_modules
  • πŸ”„ Recursive Scanning – Handles deeply nested folder structures
  • πŸ“ Content Control – Choose to include all, only non-binary, or no file contents
  • πŸ“‚ Structure-Only Mode – Return only an array of file paths (no metadata/contents) β€” lightweight for AI/LLM project analysis
  • ⚑ Fast & Efficient – Minimal disk and memory overhead
  • βœ… Validation – Detects and warns if a .snapcube.json is invalid before creation

πŸ“¦ Installation

Global Install (recommended for frequent use)

npm install -g snapcube

Then use it anywhere:

snapcube clone ./my-project

Using Without Installation (npx)

If you don't want to install globally, you can run Snapcube directly:

npx snapcube clone ./my-project

πŸ’‘ Notes for npx usage:

  • On first run, npx downloads the package temporarily.
  • You must have Node.js installed (version 18+ recommended).
  • If you get command not found, try again β€” sometimes the first run only fetches dependencies.

Example workflow with npx:

# Clone a project structure without binary contents
npx snapcube clone ./my-project --ignore-binaries

# Restore it later
npx snapcube create my-project.snapcube.json

πŸš€ Usage Examples

1. Clone a Local Project

snapcube clone <directory-path>

Example:

snapcube clone ./my-awesome-project

This will generate:

my-awesome-project.snapcube.json

2. Clone a GitHub Repository

snapcube clone-repo github:<username/repo>@<branch>

Examples:

# Clone Snapcube repo itself (main branch)
snapcube clone-repo github:tanmayvaij/snapcube@main

# Clone without binary file contents
snapcube clone-repo github:tanmayvaij/artistly@main --ignore-binaries

# Clone only structure (no file contents)
snapcube clone-repo github:tanmayvaij/artistly@main --ignore-all

πŸ“„ Generates {username}_{repo-name}.snapcube.json.


3. Clone a GitLab Repository

snapcube clone-repo gitlab:<username/repo>@<branch>

Examples:

# Clone a GitLab repo
snapcube clone-repo gitlab:username/my-project@main

# Clone with authentication token
snapcube clone-repo gitlab:username/private-project@main --token <your_gitlab_token>

πŸ”‘ Clone a Private Repository

Private repositories require authentication with a Personal Access Token.

snapcube clone-repo github:username/private-repo@main --token <your_github_token>
snapcube clone-repo gitlab:username/private-repo@main --token <your_gitlab_token>

Examples:

# Clone a private GitHub repo fully
snapcube clone-repo github:myorg/secret-project@main --token ghp_xxx123abc

# Clone private GitLab repo but skip binary files
snapcube clone-repo gitlab:myorg/secret-project@main --ignore-binaries --token glpat_xxx123abc

⚠️ If you try cloning a private repo without --token, Snapcube will throw an error.

πŸ‘‰ How to generate tokens:

GitHub:

  1. Go to GitHub Settings β†’ Developer Settings β†’ Personal Access Tokens.
  2. Click Generate new token β†’ Choose classic token.
  3. Select scopes: repo (to access private repos)

GitLab:

  1. Go to GitLab Settings β†’ Access Tokens
  2. Create token with read_repository scope

4. Recreate a Project

snapcube create <json-file>

Example:

snapcube create my-awesome-project.snapcube.json

The project will be recreated inside a folder named after the original project.


5. Structure-Only Mode

If you only want the directory tree (without file contents, sizes, encodings, etc.), use --structure-only.

snapcube clone ./my-project --structure-only

Example Output:

[
  "my-project/package.json",
  "my-project/src/index.js",
  "my-project/src/App.jsx",
  "my-project/public/index.html"
]

This is extremely useful for AI/LLM project understanding, lightweight snapshots, or tech stack analysis.


πŸ“‹ Commands & Flags

Command / Option Description Example
clone Save local project structure to JSON snapcube clone ./my-project
clone-repo Save structure of a remote repo to JSON snapcube clone-repo github:user/repo@main
create Restore project from JSON snapcube create my-project.snapcube.json
--ignore-binaries Ignore content of binary files (images, PDFs, videos, etc.) snapcube clone ./my-project --ignore-binaries
--ignore-all Ignore content of all files β€” only structure & metadata saved snapcube clone ./my-project --ignore-all
--structure-only Save only the file paths (no metadata/contents) snapcube clone ./my-project --structure-only
--token <token> Provide authentication token for private repos snapcube clone-repo github:user/private@main --token xxx
--help Show help information snapcube --help
--version Show version number snapcube --version

πŸ’‘ Tip: If both --ignore-all and --ignore-binaries are provided, --ignore-all takes priority. πŸ’‘ Note: --structure-only overrides everything else and just outputs an array of file paths.


πŸ“ JSON File Structure

Example output:

[
  {
    "fileName": "package.json",
    "filePath": "my-awesome-project",
    "content": "{\n  \"name\": \"my-project\"...\n}",
    "isBinary": false,
    "encoding": "utf-8"
  },
  {
    "fileName": "logo.png",
    "filePath": "my-awesome-project/assets",
    "content": null,
    "isBinary": true,
    "encoding": "base64"
  }
]

πŸ“Œ Structure-only mode simplifies this to just file paths:

[
  "my-awesome-project/package.json",
  "my-awesome-project/assets/logo.png"
]

🎯 Use Cases

  • πŸ“‹ Project Templates – Distribute starter kits instantly
  • πŸ”„ Backup & Restore – Keep lightweight project backups
  • 🌐 Clone Remote Repos to JSON – Store snapshots for later use
  • πŸ”‘ Private Repo Snapshots – Archive or share internal projects securely
  • 🀝 Collaboration – Share codebases without using Git
  • πŸ“š Education – Distribute coding examples & tutorials
  • πŸ€– AI Code Review – Send .snapcube.json for AI-assisted debugging
  • 🧠 LLM Project Analysis – Use --structure-only to let AI quickly identify frameworks, languages, and project setup

βš™οΈ How It Works

Cloning Process

  1. Scans the target directory or remote repo recursively
  2. Skips ignored folders (node_modules, .git, etc.)
  3. Reads file content (Base64 for binary, UTF-8 for text) unless ignored
  4. Saves everything to a .snapcube.json file

Creation Process

  1. Validates the .snapcube.json format
  2. Creates necessary folders
  3. Restores files with their original content (if available)
  4. Recreates the exact directory structure

🚫 Ignored by Default

  • node_modules/
  • .git/ and hidden directories
  • .next/, dist/, out/, and build output folders
  • __pycache__/, venv/, vender/
  • Temporary files like .DS_Store, thumbs.db, and cache directories

🀝 Contributing

  1. 🍴 Fork the repo
  2. 🌱 Create a branch: git checkout -b feature/AmazingFeature
  3. πŸ’Ύ Commit changes: git commit -m "Add some AmazingFeature"
  4. πŸ“€ Push: git push origin feature/AmazingFeature
  5. πŸŽ‰ Open a Pull Request

πŸ› Issues & Support


πŸ™ Acknowledgments

  • Built with ❀️ using Node.js + Commander.js
  • Inspired by the need for quick project structure sharing
  • Thanks to all contributors and early adopters

⭐ If you like Snapcube, star the repo to support development!

Made with πŸ’– by Tanmay Vaij

About

Snapcube is a powerful CLI tool that allows you to save your project structure to JSON and recreate it anywhere. Perfect for project templates, backups, or sharing project scaffolds with your team.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published