Generate prompts from codebase structure and content
Project description
Codebase2Prompt
Description
Codebase2Prompt is a minimal command-line tool that generates structured prompts from codebases. It does not provide the full function code, but purely the method addresses. It supports multiple output formats (Markdown, JSON, YAML) and automatically copies results to your clipboard. The tool is particularly useful for:
- Creating codebase overviews for AI prompts
- Generating documentation templates
- Sharing code context with collaborators
Purpose
There are many times the LLM context window is maxed out when providing the full codebase. Because it is good practice to name functions with logical addresses, it goes to reason that a LLM will be able to intuit what a class, method, etc contains based on its naming and location in the folder structure. This is meant to provide high level understanding to the LLM in times where LLM drift becomes and issue.
Installation
PyPI Installation
Install directly from PyPI:
pip install codebase2prompt
Verify installation:
c2p --version
Development Installation
For local development:
- Clone the repository:
git clone https://github.com/epicshardz/codebase2prompt
cd codebase2prompt
- Install dependencies using Poetry:
poetry install
- Install the CLI tool:
poetry shell
pip install .
Configuration
The tool can be configured using a config.ini file. Copy the example configuration:
c2p config.ini.example config.ini
Configuration Options
- Default Path: Set the default directory to scan
- File Extensions: Specify which file types to include
- Exclusion Patterns: Define patterns to exclude files/directories
- Output Format: Choose between markdown, json, or yaml
- Clipboard Settings: Enable/disable automatic clipboard copying
Usage
Basic Usage
Scan the current directory:
c2p
Scan a specific directory:
c2p /path/to/codebase
Excluding Files/Directories
Exclude specific patterns:
c2p --exclude node_modules --exclude .git
Output Formats
Generate JSON output:
c2p --output-format json
Generate YAML output:
c2p --output-format yaml
Clipboard Integration
Disable clipboard copying:
c2p --no-clipboard
Force clipboard copying:
c2p --clipboard
Development
Setting Up
- Install development dependencies:
poetry install --with dev
- Activate the virtual environment:
poetry shell
Running Tests
Run all tests:
pytest
Run tests with coverage:
pytest --cov=Codebase2Prompt
Code Formatting
Format code with Black:
black .
Sort imports with isort:
isort .
Building and Releasing
Build the package:
poetry build
Publish to PyPI:
poetry publish
Contributing
We welcome contributions! Please follow these guidelines:
- Open an issue to discuss proposed changes
- Fork the repository and create a feature branch
- Submit a pull request with:
- Clear description of changes
- Updated tests
- Documentation updates if needed
For bug reports, please include:
- Steps to reproduce
- Expected behavior
- Actual behavior
- Environment details
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codebase2prompt-0.1.4.tar.gz.
File metadata
- Download URL: codebase2prompt-0.1.4.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.1 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b292423a7c35fe84597a2d3a31d45452238e9556a2914dd4c589611a6249fe2d
|
|
| MD5 |
03a13548718bf8d79021b24a9dd4ecf3
|
|
| BLAKE2b-256 |
85d0d6e255ce8798d6a6fcff6121f7a16f3294ecf8188d03a546c10d6a32e68b
|
File details
Details for the file codebase2prompt-0.1.4-py3-none-any.whl.
File metadata
- Download URL: codebase2prompt-0.1.4-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.1 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd68a048504974ef45ab4369c2bd546c912e0fcf2c4c72bc440dcad204d59533
|
|
| MD5 |
84ccfcd8f0a8ea99d7af10725fe4d97b
|
|
| BLAKE2b-256 |
2272db68ef7a09e252f2adcc6fff79c1634ad209de3d2b4d13e423be33c53678
|