mainai
A CLI that figures out which coding agent (Claude Code, Codex, Grok, ...) last did real work in a project folder, and hands off cleanly to the one you pick next.
The problem
Working the same project folders with several coding agents means that coming back months later, it's unclear which agent did the most recent real work, and what the other agents did in the meantime.
What it does
$ mainai .
Found 6 session(s) in /home/user/projects/endotypes
codex 2026-09-25 "fix the endotype clustering..." <- latest work
claude 2026-09-18 "add the GSE cohort loader..."
...
Continue with: codex (its edits match the files on disk; the Claude sessions
were read-only questions)
Advice: cd /home/user/projects/endotypes && codex
$ mainai --handoff .
...
Wrote /home/user/projects/endotypes/HANDOFF.md
Launching: codex resume --last "Read HANDOFF.md and integrate it into our existing conversation"
- Reads every agent's stored conversations, keeps the ones for the given folder.
- Decides which agent to continue with. An LLM reads each session's actual content (not just the newest timestamp) and recommends one, with its reasoning printed alongside the pick.
- Prints advice: the command to run to continue with that agent.
- With
--handoff, also summarizes the other sessions intoHANDOFF.mdand launches the picked agent itself, continuing its most recent conversation and feeding it a prompt to readHANDOFF.md.
The folder argument is required (mainai . for the current directory) --
mainai with no arguments prints help and does nothing, so a stray bare
invocation after install never spends tokens or bills an API key unasked.
Flags: --list (sessions + a free file-evidence guess only, no LLM call, no
file written), --agent NAME (override the pick, no LLM call), --handoff
(summarize the other agents' sessions into HANDOFF.md, one extra LLM
call, then launch the picked agent -- continuing its most recent
conversation and pointing it at HANDOFF.md; Linux/macOS only),
--handoff-agents grok[,codex,...] (summarize only the named agent(s)
instead of every agent other than the one picked -- implies --handoff,
but never launches anything, even combined with --handoff; e.g. continue
with Claude via --agent claude while still pulling in context from Grok
via --handoff-agents grok), -y/--yes (skip the confirmation before an
LLM call that would bill ANTHROPIC_API_KEY directly, when no claude.ai
subscription login is found).
Platform support
Developed and tested on Linux and macOS only; Windows is untested.
--handoff's launch step explicitly refuses to run on Windows, with a
clear error, rather than fail in some confusing way: Claude Code, Codex,
and Grok's CLIs are commonly installed there as npm .cmd/.ps1 wrapper
scripts rather than native .exes, which Windows can't exec directly -- it
has to go through cmd.exe, which does its own parsing of shell
metacharacters first (a well-known source of bugs in other tools' Windows
launchers).
See mainai.md for the full design notes (reader architecture, per-agent log
formats, picker logic, summarizer, scope/build order).
Status
Readers for Claude Code, Codex, and Grok, the LLM-based picker, --handoff,
and the CLI are implemented. Published to PyPI as mainai.
Development
uv-managed project.
uv sync
uv run mainai --list .
Metadata
Release files for mainai 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mainai-0.4.1.tar.gz | 30.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mainai-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 51.9 kB
Release files / mainai-0.4.1.tar.gz
| Download URL | mainai-0.4.1.tar.gz |
|---|---|
| Size | 30.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2476fecea09d0238c547274d6a5a473f7a9e7b00ca7b42841790da4be55a7b28
|
|
BLAKE2b-256 checksum How to use checksums |
e6050bd93d4514d5d5eb25fb54269771832e91cee2b8bd04ff336bb577ed3184
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Release files / mainai-0.4.1-py3-none-any.whl
| Download URL | mainai-0.4.1-py3-none-any.whl |
|---|---|
| Size | 21.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aba68261f53211a74fd15879ee0f45dabfaf93a45a263672a4ddd646440451a9
|
|
BLAKE2b-256 checksum How to use checksums |
e617f2311415e9dd81747246f7de99c7206ce36a42573813837df5733bb12bf9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Security for mainai 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.