Skip to main content

Codebase Batcher (cbatch) - CLI tool to output codebase to structured file for AI context.

Project description

Codebatcher (cbatch)

A CLI tool that formats your codebase into a structured markdown file, making it easier to provide context to AI tools like ChatGPT or Claude.

Features

  • 📝 Converts your entire codebase into a single, well-structured markdown file
  • 🎯 Intelligent file filtering with .cbatchignore support
  • ⚙️ Configurable project metadata through cbatch.ini
  • 📊 Token estimation for AI context windows
  • 🚀 Simple and intuitive CLI interface

Installation

Install codebatcher using pip:

pip install codebatcher

Quick Start

  1. Navigate to your project directory:
cd your-project
  1. Initialize cbatch configuration:
cbatch init
  1. Generate the structured codebase file:
cbatch update

Commands

  • cbatch init - Initialize configuration and create default ignore patterns
  • cbatch update [path] [output-file] - Update/create the structured codebase file
  • cbatch tokens - Display estimated token count for the generated file

Configuration

cbatch.ini

During initialization (cbatch init), you can configure:

  • Codebase Type (e.g., FastAPI backend, React frontend)
  • Deployment Location
  • General Description
  • Execution Command

Example cbatch.ini:

[General]
codebase_type = FastAPI backend
deployment_location = AWS
general_description = REST API for user management
execution_command = uvicorn main:app --reload

[Summary]
input_token_estimate = 12345

.cbatchignore

Similar to .gitignore, specify patterns for files and directories to exclude. Default patterns include:

  • Common version control files (.git/, .gitignore)
  • Build artifacts (*.pyc, build/, dist/)
  • Environment files (.env, venv/)
  • Dependencies (node_modules/)
  • System files (.DS_Store)
  • Temporary files (*.swp, temp/, tmp/)
  • Log files (*.log)

Add custom patterns by editing .cbatchignore:

# Custom ignore patterns
secrets/
*.config.js
private/*

Output Format

The generated markdown file (codebatch.md by default) includes:

  1. Instructions section
  2. General project information
  3. Structured listing of all codebase files with their contents

Example structure:

# Instructions #

This file represents the entire codebase...

## General Info ##

**Codebase Type**: FastAPI backend
**Deployment Location**: AWS
...

## Files ##

### `src/main.py` ###
```python
# File contents here

## Use Cases

- Providing context to AI tools about your entire codebase
- Generating documentation overviews
- Sharing code context with team members
- Creating structured backups of your source code

## Token Estimation

The tool provides a simple word-count based token estimation to help you stay within AI context windows. Check the current estimate using:

```bash
cbatch tokens

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License

Author

Zach (zh93@nau.edu)

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

codebatcher-0.1.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

codebatcher-0.1.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file codebatcher-0.1.2.tar.gz.

File metadata

  • Download URL: codebatcher-0.1.2.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Linux/6.12.10-200.fc41.x86_64

File hashes

Hashes for codebatcher-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b784194ba8b7317619a33b72d7d0300cf204945080e567db46a23d4567421dea
MD5 f652e32981fe1d21af560ef80d4dbb9d
BLAKE2b-256 a7b7a2d5f3e87d816f36c0f9aa68423d1d714d2df708778a8894f0a1fbef4bd4

See more details on using hashes here.

File details

Details for the file codebatcher-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: codebatcher-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Linux/6.12.10-200.fc41.x86_64

File hashes

Hashes for codebatcher-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 10608469a83ca7db4731f0951bd27398a41b0da2221f02b7105b6a56560f7d40
MD5 8420e672bd3ea01fa2c6d0bdbab10446
BLAKE2b-256 0f1ba48f08a9ebfc480cb0ba1ab2e65403076a6f74a29f77dffffbe1674ef6b8

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