Skip to main content

promptpack-for-code

PyPI PyPI Downloads

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

Use full XML tags instead of compact format:

ppc /path/to/src --no-compact-xml

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
  • XML format has both compact and full-tag modes for different use cases
  • 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, and packcode

Output Formats

Text Format

The generated text output file contains:

  1. A tree-like representation of your project structure (based on the root directory)
  2. 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:

  1. A hierarchical view of your project directory structure
  2. The contents of all specified files, with paths relative to the root

Compact XML (Default)

By default, the tool produces compact XML with minimal tags and no indentation to reduce file size. It includes a legend comment at the beginning of the file explaining all tags:

<!--
XML Tag Legend:
- p: project (root element)
- n: name (project name)
- s: structure (directory structure)
- d: directory
- f: file
- c: contents (file contents section)
- p attribute: path of file or directory
- s inside directory: skipped directory
- e: error
-->
<p><n>project-name</n><s><d p="src"><f p="main.py"/><d p="utils"><f p="helper.py"/></d></d><d p="tests"><f p="test_main.py"/></d></s><c><f p="src/main.py">[file content here]</f></c></p>

Full XML (with --no-compact-xml option)

For better readability, you can use the --no-compact-xml option to get full tags with proper indentation:

<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 name
  • ppc: Short alias for quicker typing
  • packcode: Alternative alias

All commands provide identical functionality:

# These all do the same thing (generate compact 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:

  1. Clone the repository:
git clone https://github.com/changyy/py-promptpack-for-code.git
cd py-promptpack-for-code
  1. Install in development mode:
pip install -e .

Requirements

  • Python 3.6+
  • tqdm (for progress bar support)

License

MIT License - see LICENSE file for details

Metadata

Release files for promptpack-for-code 2.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for promptpack-for-code 2.1.1
File Size Uploaded
promptpack_for_code-2.1.1.tar.gz 12.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for promptpack-for-code 2.1.1
File Interpreter ABI Platform
promptpack_for_code-2.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / promptpack_for_code-2.1.1.tar.gz

Download URL promptpack_for_code-2.1.1.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
59e69d290cd1efc2d0575a4089d146b5c994f7ea9cd0260fa50a5d006bd9e02b
BLAKE2b-256 checksum
How to use checksums
52261e1cdadc5f331bd7bca3712679fc82302348b1e5f89a187df6f160933aa0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 4, 2025.

Transparency log

Release files / promptpack_for_code-2.1.1-py3-none-any.whl

Download URL promptpack_for_code-2.1.1-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
923babed22cbf0201abdd6308a3a10b395265acba1f49f53bda60e3eba5649de
BLAKE2b-256 checksum
How to use checksums
18c018e924ac4d0a6769ef79ad85fdec89cabc38ee42ffd95ec0334b5beb36a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 4, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

2.1.1 This release

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page