This repository provides a simple relay that lets you trigger Codex CLI from Slack mentions. A Slack Socket Mode bot (slack_bot/app-socket.py) listens for @codex-bot mentions, builds a prompt with recent thread context, and launches Codex CLI to work inside the local project folder. Codex then posts progress back to the same Slack thread via the Slack MCP server and performs code changes/PRs via the GitHub MCP server.
Why use this
- Run Codex on your own machine, so it can access local files, Docker, and GPU workloads.
- Trigger coding tasks from anywhere (phone, tablet, etc.) while staying in Slack threads.
- Automate a full loop: receive a request, edit code, run tests, and open a PR.
Repository layout
codex_dir/: The actual working folder for Codex CLI. This is where Codex runs commands and edits files.slack_bot/: The Python Socket Mode app that receives Slack mentions and launches Codex CLI.
This project runs Codex CLI in --full-auto mode, which grants it significant autonomy to execute commands, modify files, and interact with external services (Slack, GitHub) without manual confirmation. While this enables a powerful hands-free workflow, please be aware of the following:
- Use at your own risk. The authors of this project are not responsible for any unintended changes, data loss, or other issues that may arise.
- Review the permissions carefully. The GitHub token and Slack app have broad access. Consider limiting scopes or repository access where possible.
- Start with low-risk tasks. We recommend testing with non-critical repositories first to get comfortable with how the bot behaves.
By using this project, you acknowledge that you understand these risks and accept full responsibility for its operation in your environment. Happy automating! 🚀
- Slack app with Socket Mode enabled.
- Slack bot token (
SLACK_BOT_TOKEN) and app token (SLACK_APP_TOKEN). - Slack team/workspace ID (
SLACK_TEAM_ID) for Slack MCP. - GitHub Personal Access Token with repo permissions for the GitHub MCP server.
- Codex CLI installed and configured.
- Node.js (for MCP server execution via
npx).
- Go to Slack API: Your Apps (https://api.slack.com/apps) and click Create New App → From scratch.
- Name it (for example
codex-bot) and select your workspace. - In Socket Mode, enable it and generate an app-level token (starts with
xapp-).- The token must include the
connections:writescope. - Save this as
SLACK_APP_TOKEN.
- The token must include the
- In OAuth & Permissions, add Bot Token Scopes:
app_mentions:readchat:writegroups:history
- Click Install to Workspace and copy the bot token (starts with
xoxb-).- Save this as
SLACK_BOT_TOKEN.
- Save this as
- In Event Subscriptions, enable events and subscribe to Bot Events:
app_mention- Save changes (you may be asked to reinstall the app).
- Get your workspace (team) ID for Slack MCP:
- Run
curl -X POST https://slack.com/api/auth.test -H "Authorization: Bearer xoxb-...". - Save the
"team_id"value asSLACK_TEAM_ID.
- Run
- Go to GitHub Settings → Developer settings.
- Select Personal access tokens → Fine-grained tokens.
- Click Generate new token.
- Configure Repository access:
- Select All repositories (or specific repos if you prefer).
- Configure Permissions (Repository permissions):
- Administration: Read and write
- Contents: Read and write
- Issues: Read and write
- Pull requests: Read and write
- Click Generate token and copy the token (starts with
github_pat_).- Save this as
GITHUB_PERSONAL_ACCESS_TOKEN.
- Save this as
⚠️ Note: These permissions are relatively broad. Handle the token with care and consider limiting repository access if possible.
Edit ~/.codex/config.toml (or create it if missing):
sandbox_mode = "workspace-write"
[features]
streamable_shell = true
web_search_request = true
skills = true # for skills
# Slack MCP: progress reports
[mcp_servers.slack]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-slack"]
env = { SLACK_BOT_TOKEN = "xoxb-...", SLACK_TEAM_ID = "T0..." }
# GitHub MCP: code operations
[mcp_servers.github]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-github"]
env = { GITHUB_PERSONAL_ACCESS_TOKEN = "github_pat_..." }Replace the placeholders with your real tokens/IDs.
Create slack_bot/.env:
# Slack tokens
SLACK_APP_TOKEN=xapp-...
SLACK_BOT_TOKEN=xoxb-...
# Folder where Codex will run (this repo's codex_dir)
CODEX_ACTION_FOLDER=/absolute/path/to/this/repo/codex_dir
# Optional: how many recent messages to include in the prompt
SLACK_HISTORY_LIMIT=50cd slack_bot
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install slack-bolt python-dotenv
python app-socket.pyWhen you see Start App, the bot is running.
Mention the bot in a channel the app is invited to:
@codex-bot Fix the login validation and run tests, then open a PR.
The bot will:
- Collect recent thread messages (if any).
- Launch Codex CLI with a prompt that includes the Slack thread context.
- Codex posts progress and results back into the same thread.
The current slack_bot/app-socket.py differs from older examples:
- It runs
codex exec --full-autodirectly (no fixed session ID). - It injects recent Slack history into the prompt using
SLACK_HISTORY_LIMIT.
If you update the Python bot, keep the README in sync with its behavior.