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.3.tar.gz (5.9 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.3-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codebatcher-0.1.3.tar.gz
  • Upload date:
  • Size: 5.9 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.3.tar.gz
Algorithm Hash digest
SHA256 6d0ef375b50c38a9e1c6913ca4a734d19e3ca9a5d328f88e1fda260a865df972
MD5 754ae31f6bc907088c964a86637320fa
BLAKE2b-256 a02425a3fa44190c7932902d15909c0a574830d5bc90a83b14c231422bfe6753

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codebatcher-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f4fc7e2de82c9ca2db244051a1ae80ceb6969d47883fedc3cd91ed2e50feec1e
MD5 34ea4636b4ed8505aabf0b516a0ab693
BLAKE2b-256 79e134b6c01eae42812731b7abf0779825d49d6c02e22a9f8c65ba98a69132ae

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