8000 GitHub - InCoB/Claude-to-files: Transform Claude reply with code snippets into a zip archive with all files
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

InCoB/Claude-to-files

Repository files navigation

Claude to Files

A utility for extracting code blocks from Claude AI responses and creating a complete project structure automatically.

Why Use This Tool?

When working with Claude AI, it often provides extensive code examples across multiple files. Instead of manually creating each file and copying the code, this tool:

  • Automatically identifies file paths in Claude's responses
  • Extracts all code blocks into their proper files
  • Creates a complete project structure with proper directories
  • Adds supporting files like README.md, requirements.txt, and .gitignore
  • Optionally sets up GitHub repository files and initializes git
  • Creates a ZIP archive for easy sharing

Supported Languages

This tool works with a variety of programming languages and file formats:

  • Python
  • JavaScript/TypeScript
  • Java
  • C/C++
  • Go
  • Ruby
  • Rust
  • HTML/CSS
  • Bash/Shell scripts
  • JSON/YAML
  • Markdown
  • SQL
  • And more!

Setup

  1. Ensure you have Python 3.x installed
  2. Set up the virtual environment:
    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    pip install -r requirements.txt

Usage

Option 1: Process a saved Claude response

  1. Copy your entire conversation with Claude that contains code into a text file
  2. Run the script on that file:
    python claude_to_files.py --file your_claude_conversation.txt --output-dir my_project

Option 2: Interactive mode

Run the script in interactive mode and paste the Claude response directly:

python claude_to_files.py --interactive

Option 3: With GitHub setup

Add the --github flag to create GitHub-specific files and get instructions for publishing:

python claude_to_files.py --file your_claude_conversation.txt --github

Option 4: Auto-initialize Git repository

Add the --init-git flag to automatically initialize a git repository:

python claude_to_files.py --file your_claude_conversation.txt --github --init-git

Recognized Formats

The tool recognizes various ways Claude might introduce code files:

  • File: path/to/file.py
  • Let's create 'path/to/file.py':
  • Create a file named 'path/to/file.py':
  • Create 'path/to/file.py':

And various code block formats:

  • Markdown code blocks (python, javascript, etc.)
  • Claude's pythonCopy format

Options

  • --file: Path to the file containing Claude's response
  • --output-dir: Directory to create the project in (default: claude_project)
  • --zip-name: Name of the ZIP file to create (default: claude_project.zip)
  • --interactive: Run in interactive mode
  • --github: Create GitHub-specific files and provide publishing instructions
  • --init-git: Initialize git repository in the project directory

Publishing to GitHub

Manual Method

  1. Create a new repository at https://github.com/new
  2. Initialize and push your local repository:
    cd claude_project
    git init
    git add .
    git commit -m "Initial commit from Claude AI code"
    git branch -M main
    git remote add origin https://github.com/yourusername/your-repo-name.git
    git push -u origin main

Automated Method

Use the --init-git flag to have the script initialize the git repository for you:

python claude_to_files.py --file your_claude_conversation.txt --github --init-git

Then just add your remote and push:

cd claude_project
git remote add origin https://github.com/yourusername/your-repo-name.git
git push -u origin main

Example

Let's say Claude gives you code for a multi-language project with multiple files. Instead of creating each file manually:

  1. Save Claude's response to claude_response.txt or copy it to your clipboard
  2. Run: python claude_to_files.py --file claude_response.txt --github --init-git
  3. The tool will:
    • Extract all code files
    • Create the proper directory structure
    • Add supporting files
    • Initialize a git repository
    • Generate a ZIP archive

Examples

Check out the examples directory for:

  • Sample Claude responses
  • Testing scripts
  • Usage examples

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Transform Claude reply with code snippets into a zip archive with all files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0