Skip to main content

aiprep

Overview

The aiprep script is a versatile tool designed to streamline interactions with AI tools. It allows you to combine multiple files into a single, formatted output that is ready to paste into an AI prompt. The script handles filenames and code block delimiters (backticks) to ensure proper formatting, preserving the context and structure of your files when interacting with AI tools.

A key feature of this script is its ability to reformat markdown-style code blocks. This ensures that the pasted content renders properly within AI tools, avoiding issues like losing the code block formatting or having markdown render incorrectly in responses.

Features

  • Combine multiple files into a single, clipboard-ready output.
  • Format the output with filenames and backticks for code blocks.
  • Recursively collect files matching patterns with --recursive.
  • Remove or re-add backticks to ensure correct rendering in AI prompts and responses.
  • Skip invalid files with a warning, ensuring smooth processing.

Why Modify Codeblocks?

When pasting formatted content into AI tools, the rendered markdown can sometimes interfere with the interaction:

  • If markdown is left unprocessed, code blocks might not render correctly when AI responds.
  • By removing and re-adding code block delimiters (backticks), the script ensures that your input retains the correct format and structure. This allows the AI to display and interpret code blocks correctly without inadvertently rendering markdown in its output.

The --deblock and --reblock options allow you to address this issue:

  • -d, --deblock: Replace triple backticks with double backticks (```) to prevent markdown rendering in AI outputs.
  • -r, --reblock: Restore triple backticks after processing to re-enable proper code block formatting.

Installation

Install from PyPI

pip install aiprep

System dependencies

For clipboard functionality, ensure you have xclip installed (Linux):

sudo apt-get install xclip

Note: macOS and Windows clipboard support works out of the box via pyperclip dependency.

Usage

Run the script with the desired functionality using the following options:

Options

  • -c, --combine: Combine multiple files into a single clipboard-friendly format with filenames and codeblocks.
  • -d, --deblock: Replace triple backticks with double backticks (```) in the specified files.
  • -r, --reblock: Replace double backticks (```) with triple backticks in the specified files.
  • --recursive: Recursively include files matching the given glob patterns.
  • -h, --help: Show usage instructions.

Examples

Combine Files into Clipboard

aiprep -c file1.py file2.py file3.py

Recursively Combine All .py Files

aiprep -c --recursive "*.py"

This combines the content of all Python files in the current directory and subdirectories, formats them with filenames and triple backticks, and copies the result to your clipboard.

Modify Codeblocks

Replace triple backticks with double backticks:

aiprep -d file1.md file2.md

Restore double backticks to triple backticks:

aiprep -r file1.md file2.md

Help

aiprep -h

Expected Output (Copied to Clipboard)

For -c, the combined output will have the following format:

file1.py:

<contents of file1.py>

file2.py:

<contents of file2.py>

file3.py:

<contents of file3.py>

Notes

  • Ensure all specified files exist. Non-existent or invalid file paths will be skipped with a warning.
  • Use the --deblock and --reblock options carefully to handle code block rendering issues when interacting with AI tools.
  • --recursive works with glob patterns (e.g., "*.py") to collect matching files in all directories.

Purpose

This script is designed to optimize workflows for loading multiple source code files into AI tools. By preparing files in a clipboard-ready format and ensuring proper rendering of code blocks, it eliminates common issues with markdown formatting in AI responses, allowing you to focus on content rather than formatting.

License

Feel free to use, modify, and distribute this script as needed. No restrictions apply.

Metadata

Release files for aiprep 1.0.3

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

Source distribution (sdist)

Source distribution for aiprep 1.0.3
File Size Uploaded Provenance Actions
aiprep-1.0.3.tar.gz 5.9 kB With provenance Details for aiprep-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiprep 1.0.3
File Interpreter ABI Platform Actions
aiprep-1.0.3-py3-none-any.whl Python 3 none any Details for aiprep-1.0.3-py3-none-any.whl

Total release size: 12.5 kB

Release files / aiprep-1.0.3.tar.gz

Download URL aiprep-1.0.3.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
baffddb0ed0b30e1be7fa2c25d3978574c2dff0ede4e89707f694b5197344b9d
BLAKE2b-256 checksum
How to use checksums
90f123b78314975d54dcc282da5b5b5997d2424fc1eab92653413c7d9aa094cd
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 Apr 7, 2025.

Transparency log

Release files / aiprep-1.0.3-py3-none-any.whl

Download URL aiprep-1.0.3-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5de1341804f0e050db587c88d1532a81d8d9b9d0632aa7e5666cfc238b2313c2
BLAKE2b-256 checksum
How to use checksums
9a93894a3ff11559ad4ce6b1526732aba0db458c50a5f396d2333acfd32298d9
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 Apr 7, 2025.

Transparency log

Security for aiprep 1.0.3

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aiprep-1.0.3.tar.gz

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 Apr 7, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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