Skip to content

πŸš€ Code2Prompt transforms your codebase ZIP files into structured, prompt-optimized formats (Plaintext, Markdown, XML, JSON) for language models like ChatGPT. Upload your projects, filter unwanted directories and file types, and generate customizable prompts with ease.

License

Notifications You must be signed in to change notification settings

BjornMelin/code2prompt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Code2Prompt πŸš€

Code2Prompt is a modern, web-based tool that transforms one or more ZIP files containing a codebase into a structured, prompt-optimized format for language models like ChatGPT. With a sleek, customizable Streamlit interface, you can upload ZIP files, manage ignore patterns dynamically, filter file types, and customize prompt generation with advanced options.


Table of Contents πŸ“š


Features ✨

  • Modern Streamlit Interface:
    • Uses Streamlit's built-in theming with customizable configuration.
    • Responsive layout with a sidebar for advanced settings and progress indicators.
  • Advanced Customization Options:
    • Dynamic ignore pattern management (including custom patterns).
    • File type filtering (select which file extensions to process).
    • Custom prompt header and options to include/exclude file boundaries, truncate content, and add file metadata.
  • Batch Processing:
    • Upload and process multiple ZIP files simultaneously.
    • Progress bars and detailed logging for processing steps.
  • Interactive File Tree Viewer:
    • Collapsible preview of the file tree, preserved in session state.
  • Robust Error Handling:
    • Clear, user-friendly error messages with custom exceptions.
  • Extensible & Modular:
    • Clean, modular codebase for future enhancements.

Project Structure πŸ—‚οΈ

graph TD;
    A[streamlit_app.py] --> B[config.py]
    A --> C[file_processor.py]
    A --> D[formatter.py]
    A --> E[exceptions.py]
Loading
  • config.py: Default settings for ignore directories and file type filters.
  • file_processor.py: Handles extraction of ZIP files and retrieval of file paths.
  • formatter.py: Formats file content into optimized prompts (Plaintext, Markdown, XML) with advanced customization.
  • exceptions.py: Custom exceptions for robust error handling.
  • streamlit_app.py: Main entry point with advanced UI and customization features.
  • Makefile: Shortcut for running the app.
  • requirements.txt: Project dependencies.

Installation πŸ”§

  1. Clone the Repository:

    git clone https://github.com/yourusername/Code2Prompt.git
    cd Code2Prompt
  2. Create a Virtual Environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install Dependencies:

    pip install -r requirements.txt
  4. Format Code (Optional):

    Use Black to format the code:

    black .

Usage πŸš€

  1. Run the Application:

    streamlit run streamlit_app.py
  2. Using the App:

    • Upload ZIP Files: Upload one or more ZIP files containing your codebase.
    • Customize Settings: Use the sidebar to manage ignore patterns, select file types, choose output format, and adjust other formatting options. Add a custom prompt header if desired.
    • Generate Prompt: Click "Generate Prompt" to process your files.
    • Preview & Log: View the generated prompt, a file tree preview, and processing logs.
    • Built-In Theming: The app uses Streamlit’s built-in theming, so the default Light/Dark modes are available through Streamlit’s config.

Screenshots πŸ“Έ

Include screenshots or GIFs of the updated app here to showcase the modern UI and enhanced features.

Code2Prompt Screenshot


Mermaid Diagram

Below is a diagram representing the project structure:

graph TD;
    A[streamlit_app.py] --> B[config.py]
    A --> C[file_processor.py]
    A --> D[formatter.py]
    A --> E[exceptions.py]
Loading

Contributing 🀝

Contributions are welcome! Please fork the repository and submit a pull request with your changes. For major changes, open an issue first to discuss your ideas.


License πŸ“„

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


Author πŸ‘¨β€πŸ’»

Bjorn Melin - GitHub Profile


How to Cite πŸ“

If you use Code2Prompt in your research or project, please cite it using the following BibTeX entry:

@software{melin2025code2prompt,
  author       = {Bjorn Melin},
  title        = {Code2Prompt: A Streamlit Tool for Codebase-to-Prompt Conversion},
  year         = {2025},
  publisher    = {GitHub},
  journal      = {GitHub repository},
  howpublished = {\url{https://github.com/BjornMelin/Code2Prompt}}
}

Enjoy using Code2Prompt to supercharge your prompt engineering and optimize your AI interactions! πŸŽ‰

About

πŸš€ Code2Prompt transforms your codebase ZIP files into structured, prompt-optimized formats (Plaintext, Markdown, XML, JSON) for language models like ChatGPT. Upload your projects, filter unwanted directories and file types, and generate customizable prompts with ease.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published