Skip to main content

AIBaton

中文文档

Headless Agent Automation — Python wrapper for codex/claude CLI, enabling arbitrarily complex agent automation/workflows through programmable prompts.

Features

  • Prompt-Oriented Programming — Natural language prompts as Python code, seamlessly interact with agents
  • Skill Support — Use skills to convert intent into aibaton code, making complex tasks more controllable
  • Loop Detection — Built-in iterative optimization (loop_max)
  • Response Parsing — Parse agent results with semantic options using parse(options)

Use Cases

  • Repetitive Tasks — Batch tasks that reuse the same prompt workflow for agent interaction
  • Context Explosion Tasks — Tasks with extensive context where agents miss too many details, requiring finer-grained control
  • Automated Workflows — Build workflows directly on agents, implement arbitrarily complex logic with simple Python syntax

Not Suitable For

  • Non-Repetitive Tasks — No need to script for repeated use
  • Complex Tasks Requiring Step-by-Step Confirmation — Difficult to pre-define all scenarios via script, requires human confirmation at each agent stage

Example

Install the aibaton SKILL using codex, then enter the following prompt:

$aibaton Find Go code files over 300 lines in the project and optimize them, extract redundant code into sub-functions following DRY principles, and update references in other files.

Output executable script:

from aibaton import run, set_default
import os

set_default(provider="codex", dangerous_permissions=True)

prompt = """Review the current file code and optimize, extract redundant code into sub-functions following DRY principles, and update references in other files."""

def get_go_files(root_dir: str, min_lines: int = 0) -> list[str]:
    go_files = []
    for dirpath, _, filenames in os.walk(root_dir):
        for f in filenames:
            if f.endswith('.go'):
                fpath = os.path.join(dirpath, f)
                if min_lines <= 0 or sum(1 for _ in open(fpath)) > min_lines:
                    go_files.append(fpath)
    return go_files

if __name__ == '__main__':
    par_dir = '/app/banbot'
    for fpath in get_go_files(par_dir, min_lines=300):
        run(f"File path: {fpath}\n\n{prompt}", cwd=par_dir, add_dirs=[par_dir], stream=True)

Run the script as prompted.

More Complex Task Example

A complex workflow prompt

After codex uses aibaton skill, output executable script: work_flow.py

Installation

pip install aibaton
# or
uv pip install aibaton

License

Apache 2.0

Metadata

Release files for aibaton 0.1.2

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

Source distribution (sdist)

Source distribution for aibaton 0.1.2
File Size Uploaded
aibaton-0.1.2.tar.gz 23.8 kB Details

Built distribution (wheel)

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

Total release size: 49.4 kB

Release files / aibaton-0.1.2.tar.gz

Download URL aibaton-0.1.2.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2def246d72a20b6dde278e89ebc8e84712d2ace996ff26b6bfc993e63a574861
BLAKE2b-256 checksum
How to use checksums
5024eb43d726e9bb4cb809b0835a1e1a186bdc6bc4a3e7743ca7e4c5c988fee6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / aibaton-0.1.2-py3-none-any.whl

Download URL aibaton-0.1.2-py3-none-any.whl
Size 25.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4635d7669f4ba7ea282ba5db8f6dfabfcf4c2d34f92bf75cdad1a459f388400f
BLAKE2b-256 checksum
How to use checksums
0c288683062a6996319276d990510912496887ca3b4c9b45eac5e9d961a9aee1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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