codex-notify is a small CLI tool that tails Codex session log files and posts compact Slack notifications.
It is intended for lightweight run visibility: one small monitoring-start message, then one Slack thread per new user prompt with the corresponding Codex responses attached.
- Send Codex conversations to Slack without building a separate service
- Keep Slack notifications focused on prompts and responses
- Start a fresh Slack thread for each new user prompt
- The script loads configuration from
.env, environment variables, and CLI flags. - It posts a small root Slack message showing that monitoring has started.
- It finds a Codex session log file under
~/.codex/sessionsor uses the file you specify. - It tails that log from the end, so existing history is not reposted on startup.
- Each newly detected user prompt is posted as a new Slack thread root.
- Codex responses and optional tool events are posted into that prompt's thread.
- One monitoring-start message with run title and working directory
- One new Slack thread for each new user prompt
- Thread replies for:
- assistant responses
- concise failure notices
- Optional thread replies for:
command_executionfile_changeweb_search- other completed items
- Long payloads are split into safe chunks before posting
.envloading without requiringpython-dotenv
.
├── .env.sample
├── .gitignore
├── README.md
├── codex-notify.py
├── pyproject.toml
├── src/
│ └── codex_notify/
│ ├── __init__.py
│ └── cli.py
└── tests/
└── test_cli.py
Create .env from .env.sample.
SLACK_BOT_TOKEN=xoxb-your-token
SLACK_CHANNEL=C0123456789
CODEX_PROMPT=Variables:
SLACK_BOT_TOKEN: Slack bot token used forchat.postMessageSLACK_CHANNEL: Slack channel ID to receive the run threadCODEX_PROMPT: Optional initial prompt to post as a user message when monitoring begins
CLI flags override environment variables.
codex-notify reads Codex session logs directly, so piping Codex output into this tool is not required.
Codex should still be started with --no-alt-screen, because that is the supported way to keep its execution output compatible with this workflow.
Start a new Codex run:
codex --no-alt-screenResume the previous Codex session:
codex --no-alt-screen resumeRun codex-notify separately:
python codex-notify.pyMonitor a specific session file:
python codex-notify.py --session-file ~/.codex/sessions/2026/03/10/rollout-....jsonlProcess the current contents once and exit:
python codex-notify.py --onceIn normal follow mode, codex-notify starts from the end of the session log and only posts prompts and responses appended after the monitor starts.
With explicit flags:
python codex-notify.py \
--token "$SLACK_BOT_TOKEN" \
--channel "$SLACK_CHANNEL" \
--title "Codex run: my-project" \
--prompt "Investigate failing tests"Including tool events:
python codex-notify.py --include-toolsUsing a custom env file:
python codex-notify.py --env-file .env.localUsing a custom sessions directory:
python codex-notify.py --sessions-dir ~/.codex/sessionsWithout --no-alt-screen, Codex switches to its alternate screen UI and the execution logs used by this tool are not emitted in the expected form.
Create a virtual environment and install test dependencies:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e .[test]Run tests:
pytestRun tests with coverage:
pytest --cov=src/codex_notify --cov-report=term-missingThe test suite is designed to stay above 70% coverage.