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.4.tar.gz (6.1 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.4-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codebatcher-0.1.4.tar.gz
  • Upload date:
  • Size: 6.1 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.4.tar.gz
Algorithm Hash digest
SHA256 ec8cb9b101ad25a781932fbd9ac6b6e0c9580e53e621080355049a5c89227e14
MD5 80797200b52809539e664482cec92703
BLAKE2b-256 11164253d063c12ab5a07521da11d8a378083150a3ec7ee24616906b6fdbe9e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codebatcher-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 7.0 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fb5616d742c07734530937a08f935a0521779e63ac9d34ed22b8bff8b826bb0b
MD5 e56e79727868b490fc078a94ae5034c2
BLAKE2b-256 49c2c4246a675dfbb8adc849d37958623b65020ec6f79fd6c9c091a5022d7d2d

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