CodebaseToPrompt

CodebaseToPrompt

Turn local files into a prompt for an LLM

Stars: 156

Visit
 screenshot

CodebaseToPrompt is a tool that converts a local directory into a structured prompt for Large Language Models (LLMs). It allows users to select specific files for code review, analysis, or documentation by exploring and filtering through the file tree in an interactive interface. The tool generates a formatted output that can be directly used with LLMs, estimates token count, and supports flexible text selection. Users can deploy the tool using Docker for self-contained usage and can contribute to the project by opening issues or submitting pull requests.

README:

CodebaseToPrompt

A simple tool that converts your local directory into a structured prompt for Large Language Models (LLMs). It helps you pick which files to include or ignore, then outputs everything in a format you can copy directly into an LLM for code review, analysis, or documentation.

User Interface

Try it here: CodebaseToPrompt Web App


Overview

CodebaseToPrompt scans your chosen folder right in the browser (no files are uploaded anywhere) and builds a file tree. You can expand folders, see which files are text or code, and select only what you need. The selected files are then compiled into a snippet of structured text, which you can copy for use with an LLM.


Features

  • Interactive File Tree
    Explore and expand your local folders in a simple interface.

  • File Filtering
    Automatically ignores system or binary files (e.g., .DS_Store, node_modules, images, videos).

  • Local Storage
    Your selections are remembered so you can pick up where you left off.

  • LLM-Ready Output
    Generates a format that's easy to paste into chatbots and other AI tools.

  • Token Count Estimate
    Provides a rough calculation of how many tokens the selected content might use.

  • Flexible Text Selection
    Choose between selecting text or copying directly to clipboard, ensuring compatibility with both HTTP and HTTPS environments.


How to Use

  1. Open the App
    Clone this repository, then open index.html in a modern browser (Chrome or Firefox recommended).

    git clone https://github.com/hello-nerdo/CodebaseToPrompt.git
  2. Select Your Folder
    Click “Select Directory” to choose the folder you want to analyze.

  3. Pick Files
    Expand or collapse directories. Check or uncheck files to decide what gets included.

  4. Copy or Select Text
    View or copy your selected files in the generated prompt format by clicking “Copy to Clipboard” or “Select Text” (the latter is useful in HTTP-only environments).


Docker Quickstart

For a self-contained deployment, you can use the included Dockerfile:

# Build the Docker image
docker build -t codebasetoprompt .

# Run the container (maps container port 80 to host port 8080)
docker run -d -p 8080:80 codebasetoprompt

# Then open http://localhost:8080

Note: This simply serves the static files using nginx:alpine. If you prefer GitHub Pages or other hosting, you can ignore Docker.


Use Cases

  • Creating context for AI-based code review or Q&A
  • Quickly extracting only the important parts of a large project for analysis
  • Preparing short or large code snippets for LLM debugging
  • Generating reference material for new developers or documentation

Configuration

Certain folders and file types are automatically ignored (e.g., node_modules, .git, venv, common binary files). You can modify the lists inside the JavaScript code (app.js) if you need more control.


Browser Support

  • Chrome/Chromium (recommended)
  • Edge
  • Firefox
  • Safari (basic directory selection may vary)

Contributing

Contributions are welcome! Feel free to open issues for bugs or requests. For major changes, create an issue to discuss them first.

  1. Fork and clone the repo
  2. Make your changes in a branch
  3. Open a Pull Request describing your updates

License

MIT


Acknowledgments

  • Built with vanilla JavaScript and Web APIs
  • Uses SheetJS for spreadsheet parsing
  • Uses PDF.js for PDF parsing

Contact

  • Open an issue on GitHub for ideas or bug reports
  • Submit a Pull Request for direct contributions
  • Reach out via the repo's issues page if you have questions

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for CodebaseToPrompt

Similar Open Source Tools

For similar tasks

For similar jobs