A tool to bundle code files into a single file for AI analysis
Project description
promptpack-for-code
A command-line tool that bundles your code files into a single text or XML file, optimized for AI code review and analysis. It helps developers prepare their codebase for productive conversations with AI language models by combining multiple source files into a well-formatted context.
Installation
pip install promptpack-for-code
Usage
You can use the tool with its full name promptpack-for-code or with the convenient short aliases: ppc or packcode.
Basic usage with a single directory:
ppc /path/to/your/code
Process multiple directories:
ppc dir1 dir2 dir3
Specify root directory for tree structure and full relative paths:
ppc /path/to/specific/folder -r /path/to/project/root
Specify output file path (default is output.xml):
ppc /path/to/src -o /path/to/output/result.xml
Generate text output instead of XML (XML is now the default):
ppc /path/to/src --format text
Ignore specific patterns:
ppc /path/to/src --ignore "*.log" "*.tmp"
Show progress bar during processing:
ppc /path/to/src --progress
Force overwrite existing output file:
ppc /path/to/src -f
Features
- Combines multiple source files from one or more directories into a single output file
- Generates a tree-like directory structure based on the specified root
- Preserves file structure with full relative paths from the root directory
- Supports both XML (default) and plain text output formats
- Built-in ignore patterns for common files (e.g.,
.git,__pycache__, etc.) - Customizable output file path
- Optional progress bar for large projects
- Easy to integrate with various AI chat platforms
- Multiple command aliases:
promptpack-for-code,ppc, andpackcode
Output Formats
Text Format
The generated text output file contains:
- A tree-like representation of your project structure (based on the root directory)
- The contents of all files in the specified directories, with paths relative to the root
Example text output:
Project Directory Structure:
==========================
project-name
├── src
│ ├── main.py
│ └── utils
│ └── helper.py
└── tests
└── test_main.py
File Contents from Selected Directories:
===================================
====
File: src/main.py
----
[file content here]
XML Format
The generated XML output file provides a structured representation with:
- A hierarchical view of your project directory structure
- The contents of all specified files, with paths relative to the root
Example XML output:
<project>
<name>project-name</name>
<structure>
<directory path="src">
<file path="main.py" />
<directory path="utils">
<file path="helper.py" />
</directory>
</directory>
<directory path="tests">
<file path="test_main.py" />
</directory>
</structure>
<contents>
<file path="src/main.py">
<content>
[file content here]
</content>
</file>
<!-- Other file contents -->
</contents>
</project>
The XML format offers better structure and is easier to parse programmatically, making it ideal for automated analysis or integration with other tools.
Command Aliases
For convenience, this tool provides three command aliases:
promptpack-for-code: The full nameppc: Short alias for quicker typingpackcode: Alternative alias
All commands provide identical functionality:
# These all do the same thing (generate XML by default):
promptpack-for-code /path/to/src
ppc /path/to/src
packcode /path/to/src
# These all generate text output:
promptpack-for-code /path/to/src --format text
ppc /path/to/src --format text
packcode /path/to/src --format text
Development
To contribute to this project:
- Clone the repository:
git clone https://github.com/changyy/py-promptpack-for-code.git
cd py-promptpack-for-code
- Install in development mode:
pip install -e .
Requirements
- Python 3.6+
- tqdm (for progress bar support)
License
MIT License - see LICENSE file for 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 promptpack_for_code-2.0.0.tar.gz.
File metadata
- Download URL: promptpack_for_code-2.0.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d6adc35cd9711cda80f8f9e2a861e93180b225ef590f65a4ebdddb9cac3d2ad
|
|
| MD5 |
67b62a97e4887e67b36768a5860d54a2
|
|
| BLAKE2b-256 |
f6b3de4039034955f031c4729d4ce463cc4c87fe34f64a6ea1f8ea0dc552e19a
|
Provenance
The following attestation bundles were made for promptpack_for_code-2.0.0.tar.gz:
Publisher:
python-publish.yml on changyy/py-promptpack-for-code
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
promptpack_for_code-2.0.0.tar.gz -
Subject digest:
2d6adc35cd9711cda80f8f9e2a861e93180b225ef590f65a4ebdddb9cac3d2ad - Sigstore transparency entry: 192980923
- Sigstore integration time:
-
Permalink:
changyy/py-promptpack-for-code@2dc5ac6a1c9c934d3547e4ea62893e288f25bf15 -
Branch / Tag:
refs/tags/2.0.0 - Owner: https://github.com/changyy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@2dc5ac6a1c9c934d3547e4ea62893e288f25bf15 -
Trigger Event:
release
-
Statement type:
File details
Details for the file promptpack_for_code-2.0.0-py3-none-any.whl.
File metadata
- Download URL: promptpack_for_code-2.0.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c78ebe93b0c920b5b6b3c013f9f876d1795933fd891a2eed8938fc898b0c2267
|
|
| MD5 |
418f4e3f993c212796ad90e6e2cc7092
|
|
| BLAKE2b-256 |
e67e1008e5c795d1d81e1869eef4abe34b9c073569d614346c11908b646754fa
|
Provenance
The following attestation bundles were made for promptpack_for_code-2.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on changyy/py-promptpack-for-code
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
promptpack_for_code-2.0.0-py3-none-any.whl -
Subject digest:
c78ebe93b0c920b5b6b3c013f9f876d1795933fd891a2eed8938fc898b0c2267 - Sigstore transparency entry: 192980924
- Sigstore integration time:
-
Permalink:
changyy/py-promptpack-for-code@2dc5ac6a1c9c934d3547e4ea62893e288f25bf15 -
Branch / Tag:
refs/tags/2.0.0 - Owner: https://github.com/changyy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@2dc5ac6a1c9c934d3547e4ea62893e288f25bf15 -
Trigger Event:
release
-
Statement type: