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.1.tar.gz (5.2 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.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codebatcher-0.1.1.tar.gz
  • Upload date:
  • Size: 5.2 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.1.tar.gz
Algorithm Hash digest
SHA256 f16ce34f77123ffb9a3e66c414ccada932532a91f18217e6bd542246ba2e893b
MD5 195f26776ba0cdcc794a5912f19d1000
BLAKE2b-256 8288b73dcc0ff74942b660040a2e916bdc0f879693686efacaffa1edd09686c8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codebatcher-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8566b4489a248477ccb24b9876fcc4487915a1d38f0ad4e114327e8a3f3ca516
MD5 9e2c0916cbf761d6a23495c8ae4e703c
BLAKE2b-256 8cac3216dac6faec08a940b190465a857d71514abf0933885526834a4f0103c0

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