Skip to content

A bash utility to turn Claude's monolithic code artefacts into a clean, structured project.

License

Notifications You must be signed in to change notification settings

souravray/Claude2Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖✨🗂️ What is Claude2Project?

Claude2Project (C2P) is a standalone bash utility designed to streamline the process of converting monolithic artefacts generated by the Claude.ai chatbot into a clean, structured project in seconds.

Claude

Key Features

  1. 🏗️ Artefact Parsing and Change Management: Processes content across multiple files, intelligently creating, updating, or modifying them to integrate AI-generated code seamlessly into your project structure.
  2. 🍃 Local Git Workflow: Provides a pull request style review flow locally to manage and integrate iterative code updates. Compare changes, selectively apply updates, and manage modifications without affecting your current branch.

How It Helps

  • Say goodbye to copy-pasting code. Simplifies integrating Claude-generated artefacts into your projects.
  • Keeps your active branch safe and unaltered during reviews.
  • Ensures a tidy workspace, leaving no residual clutter after merging changes.

C2P is designed for developers who want a practical, efficient way to integrate Claude-generated code into their projects, without switching to anagenetic editor like "Cursor", "v0" etc.

Read on to see how it fits into your workflow!

🏁 Set It Up in a Snap

While there isn't a stable release just yet, you can easily install the development build using the installation script.

  1. Clone the repo:
    git clone git@github.com:souravray/Claude2Project.git
    Or download the code zip.

  2. Navigate to the project directory:
    cd /.../download_path../Claude2Project

  3. Give execution permissions to the installer:
    chmod +x installer.sh

  4. Run the installer in dev mode:
    ./installer.sh --dev

The script will copy the /src files to /usr/local/lib/c2p (or the equivalent folder based on your OS), and create a symlink in /usr/local/bin. After that, you should be able to run c2p --help from anywhere.

If the user doesn't have permission to write to the bin folder, the script will prompt you to run it with sudo.

Build Dependencies

C2P has minimal external dependencies, most of which come pre-installed on *nix systems. It supports $${\color{green}Bash \space version \space 3.2 \space \color{lightgreen}and \space onward}$$. You'll need git, grep, and sed. If any one is missing, the installer will prompt you to install them.

System Requirements

The code is currently tested on macOS (Darwin) with an Intel processor but should work on most Linux and BSD distributions. It can also run on Cygwin on Windows.

👮‍♀️ License, Please!

This project is licensed under the 2-Clause BSD License – use, modify, and share freely, just give credit where it’s due! 🍻

🧑‍💻 How to Use

Using C2P is straightforward! Here's the basic command syntax:

c2p [--option] <input_file> [destination_directory]

Options

  • --auto-add-new: Automatically stages a new file during review without prompting. Use this option if you want new files generated by Claude's artefacts to be automatically staged during the review process.

  • --auto-skip-new: Automatically skips a new file during review without prompting. Use this option to ignore new files during the review process without any prompts

Example Usage

  1. Process a file and specify a destination directory
c2p my_artefacts.json /my/project/directory

This will parse the input file and apply the changes to the specified directory.This will parse the input file and apply the changes to the specified directory. 2. Auto-add new files during a review

c2p --auto-add-new my_artefacts.json /my/project/directory

This automatically stages any new files for inclusion during the review process without asking for manual confirmation. 3. Skip adding new files during a review

c2p --auto-skip-new my_artefacts.json /my/project/directory

This will skip all newly generated files and only focus on reviewing changes to existing ones. C2P is designed to seamlessly integrate into your workflow, simplifying the review and integration of AI-generated artefacts.

🕹️ Auto-Detect Initialisation or Update!

C2P adapts based on the state of your project directory. The program will automatically select the appropriate workflow for you:

  1. Initialisation Workflow
  • Triggered when the project directory is empty, and Git is not initialised.

  • All files will be created, staged, and committed directly to the main branch—no review required in this flow.

  • This provides a quick and hassle-free way to kickstart your project.

    Project initiation screenshot

  1. Update Workflow
  • Triggered when the project directory has an initialised Git repository and a clean working tree.

  • Changes are applied on a review branch, where you can review modifications and select or reject changes, before they are merged back to the original branch.

    Project update screenshot

🔭 Review Process in Update Workflow

During the update workflow, a review option is presented for you to choose:

  • User can chose one of the tool depending on it's availability:

    • VS Code
    • VIM/NeoVIM
    • Default Git Diff Tool: this will be there even when other tools are not available

    Project update screenshot

  • Choose which code to keep or discard during the review. This is particularly useful for selectively applying partial code generated by Claude.

  • All changes are made on a separate review branch, ensuring that the main branch remains untouched until the changes are finalised.

    VS Code Vs. VIM Diff

    For more details on Git-related operations, check out the Git Workflow section.

🪄 Git Workflow

Git flow

The Git branching strategy in C2P ensures that code changes are systematically reviewed, staged, merged, and cleaned up to maintain a tidy and conflict-free repository. Borrowing from tried-and-tested Git methodologies, such as feature branching and pull-request workflows. It streamlines the workflow for you to minimizes the need for manualy executing git commands.

Branching Strategy

The workflow revolves around a review branch pattern, creating temporary branches to isolate and validate changes before merging into the last working branch.

  • Working Branch: Serves as the stable branch, housing the final, polished code. All merges funnel back here after careful review.
  • Review Branch: A dynamically named branch (e.g., review-branch/{incremental_number}) where proposed changes are staged, reviewed, and finalised. This branch is created for every new update action and deleted after the merge process.

Staging and Commit Management

During the update process:

  • Changes generated by Claude are staged in the review branch for inspection.
  • Users review file modifications using their preferred diff tool, such as VS Code, VIM, or the default Git diff viewer.
  • After review:
    • Accepted changes are staged.
    • Rejected and unstaged partial changes are reverted, ensuring the working tree reflects only the desired updates.

By maintaining a clean staging area, the workflow avoids accidental inclusion of unwanted changes.

Merging Strategies

Once reviewed, changes in the review branch are merged into the main branch.

  • Fast-Forward Merges: Used if no other changes have been introduced in the main branch since the review branch was created.
  • Three-Way Merges: Used when concurrent changes in the main branch require conflict resolution.

git mergetool, is integrated int the flow to automate and simplify the process. Once conflicts are resolved, the merge is committed with a descriptive message.

Cleanup Strategies

After a successful merge, C2P ensures the repository remains tidy:

  • Review Branch Deletion: The temporary review branch is deleted locally and, if applicable, from the remote repository.
  • Workspace Cleanup: Untracked files and other temporary artifacts are removed using: git clean -fd

This cleanup prevents clutter and keeps the repository ready for future actions.

💭 Why This Workflow?

The workflow balances structure with flexibility:

  • Isolated Changes: By staging all updates in review branches, the workflow minimizes disruptions to the main branch.
  • Granular Control: The review process enables selective integration of changes, essential for iterative code generation.
  • Automated Cleanupn: A clean repository ensures clarity and reduces the likelihood of errors in future updates.

🫵🏽 Your Contribution Matters!

Every contribution helps improve C2P, whether it’s fixing bugs, adding features, or refining documentation.

👾 Contributing

Start by reviewing the Contribution Guidelines for details on how to get involved.

🐛 Reporting Issues

Encounter a bug? Open an issue to bring it to attention.

💡 Requesting Features

Have an idea to enhance C2P? Suggest a feature by creating an issue.

About

A bash utility to turn Claude's monolithic code artefacts into a clean, structured project.

Resources

License

Stars

Watchers

Forks

Languages