Skip to main content

Bundle a repository into a single XML file for LLMs.

Project description

repo2xml

Bundle a complete repository into a single XML file that ChatGPT or other LLMs can read, inspired by repomix.

Features

  • Walks any directory tree and bundles readable files into XML
  • Respects .gitignore rules (via pathspec)
  • Uses layered file detection: Magika, then puremagic MIME, then identify
  • Converts supported non-text files to Markdown via markitdown
  • Skips zero-byte files, oversized files, and common build/cache directories automatically
  • Outputs a well-formed XML document with a directory tree and full file contents
  • CLI tool (repo2xml) and importable Python API

Installation

pip install repo2xml

Or with uv:

uv tool install repo2xml

Usage

CLI

# Bundle current directory to stdout
repo2xml --repo-path .

# Bundle a specific directory and save to a file
repo2xml --repo-path /path/to/repo -o repo.xml

# Skip .gitignore and add extra exclusions
repo2xml --repo-path /path/to/repo --no-gitignore --ignore "*.log" --ignore "tests/"

# Control progress display explicitly
repo2xml --repo-path /path/to/repo --progress
repo2xml --repo-path /path/to/repo --no-progress

When running in an interactive terminal, repo2xml auto-enables a progress bar. Progress is written to stderr, so XML output stays clean for -o FILE and stdout redirection.

Python API

from repo2xml import bundle_repo, RepoBundler

# Simple one-liner
xml = bundle_repo("/path/to/repo")

# More control
bundler = RepoBundler(
    "/path/to/repo",
    respect_gitignore=True,
    max_file_size=500_000,
    extra_ignore_patterns=["*.csv", "data/"],
)
xml = bundler.bundle()

Output Format

<?xml version="1.0" encoding="UTF-8"?>
<repository>
  <file_summary>
    <purpose>...</purpose>
    <usage_guidelines>...</usage_guidelines>
  </file_summary>
  <repository_info>
    <name>my-repo</name>
    <path>/home/user/my-repo</path>
    <file_count>42</file_count>
  </repository_info>
  <directory_structure>
    my-repo/
    ├── README.md
    └── src/
        └── main.py
  </directory_structure>
  <files>
    <file path="README.md">
      <content>...</content>
    </file>
  </files>
</repository>

Development

Requires uv.

# Install dependencies
uv sync --extra dev

# Run tests
uv run pytest --doctest-modules
just test-cov

# Lint and format
uvx ruff check src
uvx ruff format src

# Build one-file executable via PyInstaller
just build

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

repo2xml-2026.4.12.3.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

repo2xml-2026.4.12.3-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file repo2xml-2026.4.12.3.tar.gz.

File metadata

  • Download URL: repo2xml-2026.4.12.3.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for repo2xml-2026.4.12.3.tar.gz
Algorithm Hash digest
SHA256 ab594d91fe29543d39c7c4310368c6ae8bb9be72f9f6664b821a037ff17baeaf
MD5 469e7192766e231d5a50c3c43548940c
BLAKE2b-256 1011279f67e3df26c9c8279cdc499bb0800013530724ac7816585c49712ce305

See more details on using hashes here.

File details

Details for the file repo2xml-2026.4.12.3-py3-none-any.whl.

File metadata

  • Download URL: repo2xml-2026.4.12.3-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for repo2xml-2026.4.12.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ef40e97bc938b3f9899c1a3285d1218deca4dc8adb98e8da0a76aec97c397fc4
MD5 f1de7eb1ad8b6c3e47e9675f62094db7
BLAKE2b-256 acf990f65af39ff34ee1db00cff77780a4a56ad7e0e16a79748ad01be727451e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page