A human says yes in Telegram before your AI agent publishes anything.
Your coding agent (Claude Code, Codex, Aider, a cron script) prepares a pull request, an issue
comment or a release note. Instead of posting it, it calls agent-approve ask. You get the draft in
Telegram with three buttons:
- ✅ Approve: the agent publishes exactly the bytes you saw;
- ✏️ Redo: the bot asks what to change, and your reply goes back to the agent;
- 🚫 Reject: nothing is published.
One Python file, standard library only, no server or database.
Agents are good at writing replies and small fixes, but letting them post under your name with no review is how you end up apologising in someone else's repository. A review step in a chat you already read on your phone is the cheapest guard there is.
- Only presses and replies from
AA_OWNER_IDcount; anyone else in the chat is ignored. - Each button carries a random per-item token: old messages and replays cannot approve a new draft.
- Approval is bound to the SHA-256 of the draft (shown in full under the title). If the file changes after you approved it,
waitrefuses with an error instead of returning it. - The bot token is read from the environment only and never printed, even in HTTP errors.
- State is plain JSON files with mode
0600in~/.local/state/agent-approve.
- Create a bot with @BotFather and press Start in a chat with it.
- Save
agent_approve.pysomewhere on yourPATHasagent-approveand make it executable. - Set the environment:
export AA_TELEGRAM_TOKEN=123456:ABC... # from BotFather
export AA_CHAT_ID=123456789 # where drafts are sent (your user id, or a group)
export AA_OWNER_ID=123456789 # the only person whose presses count- Keep
agent-approve serverunning (it uses long polling, so no public URL is needed), for example with systemd:
# ~/.config/systemd/user/agent-approve.service
[Service]
EnvironmentFile=%h/.config/agent-approve.env
ExecStart=%h/.local/bin/agent-approve serve
Restart=always
[Install]
WantedBy=default.targetid=$(agent-approve ask --title "Reply to octo/repo#12" --file reply.md)
result=$(agent-approve wait "$id" --timeout 7200); code=$?
case $code in
0) gh pr comment 12 -R octo/repo --body-file "$result" && agent-approve mark "$id" done ;; # $result is the frozen file
3) echo "Owner asked for changes: $result" ;; # rewrite and ask again
4) echo "Rejected" ;;
5) echo "No answer yet" ;;
*) echo "agent-approve failed" >&2 ;; # errors go to stderr; publish nothing
esacwait exit codes: 0 approved (prints the path of the frozen draft), 3 redo (prints your feedback),
4 rejected, 5 timeout. status lists all items, get ID shows one, mark ID done|error [text]
replies under the draft so you see what happened to it.
Tell your agent the rule in its instructions file, for example in CLAUDE.md or AGENTS.md:
Never post to GitHub or anywhere public directly. Write the text to a file, run
agent-approve ask, thenagent-approve wait, and publish only the file it prints.
- One owner and one
serveper state directory (a secondserverefuses to start). Use anotherAA_STATE_DIRfor another person. - Drafts over 3,500 characters, or with invisible characters, are sent as a text file: open it before you press Approve.
servemust be running for presses to be recorded; presses made while it is down are picked up when it starts again (Telegram keeps updates for 24 hours).
python3 -m unittest discover -s testsИИ-агент готовит ответ, PR или комментарий, но не публикует сам: черновик приходит вам в Telegram с кнопками «Одобрить / Переделать / Отклонить». Публикуется ровно тот текст, который вы видели; при «Переделать» бот спрашивает, что исправить, и передаёт ответ агенту. Один файл на Python без зависимостей, работает через long polling — внешний адрес не нужен.
MIT