A community-driven registry for Claude, Cursor, Windsurf, Cline & more. Not affiliated with Anthropic.
Are you the author? Sign in to claim
Telegram bot for Claude Code and Codex CLI with MCP routing, multi-agent orchestration, cron jobs, and access controls.
A Telegram bot that gives you remote access to @openai/codex through a Node.js runtime with two Codex backends: the Codex SDK and the legacy CLI/PTy path.
It is strictly inspired by RichardAtCT/claude-code-telegram, but this project is implemented for CodeX SDK/CLI + MCP + Subagent routing.
This bot connects Telegram to Codex and routes tasks to the right execution surface:
/mcp, GitHub Skill)Key design goals:
chat + repogit clone https://github.com/MackDing/CodexClaw.git
cd CodexClaw
npm install
cp .env.example .env
BOT_TOKEN=123456789:telegram-token
ALLOWED_USER_IDS=123456789
STATE_FILE=.codex-telegram-claws-state.json
WORKSPACE_ROOT=.
CODEX_WORKDIR=.
CODEX_BACKEND=sdk
npm run start
/status
/repo
/skill
/dev status
/gh create repo my-new-app
For agent-oriented setup, see SKILL.md.
@BotFathernpm run start - start the botnpm run dev - watch mode for local developmentnpm run check - TypeScript type and syntax validation for the repositorynpm run typecheck - run the TypeScript compiler in --noEmit modenpm run lint - ESLint for source, tests, scripts, and local JS/CJS config filesnpm run lint:fix - apply safe lint fixesnpm run format - format repository files with Prettiernpm run format:check - verify formattingnpm test - run the full test suitenpm run healthcheck - static runtime readiness checknpm run healthcheck:strict - stricter production-oriented health checknpm run healthcheck:live - live Codex + Telegram probe against the configured backend and bot tokennpm run telegram:smoke - live Telegram API smoke test when a real bot token is availableTelegram Message
-> src/bot/handlers.ts
-> src/orchestrator/router.ts
-> src/runner/ptyManager.ts (coding tasks -> Codex SDK or Codex CLI)
-> src/orchestrator/skills/*.ts (general tasks -> MCP/GitHub subagents)
-> src/bot/formatter.ts
-> Telegram sendMessage/editMessageText
Core modules:
src/index.ts: bootstrap and lifecyclesrc/config.ts: env parsing and validationsrc/bot/: auth middleware, formatting, command handlerssrc/orchestrator/: routing + MCP client + skillssrc/runner/ptyManager.ts: Codex runner abstraction for SDK threads, CLI/PTy sessions, and CLI exec fallbacksrc/cron/scheduler.ts: proactive scheduled pushEnterprise target architecture: docs/enterprise-architecture.md Enterprise Phase 1 roadmap: docs/phase-1-roadmap.md
To avoid duplicated context fetch:
/mcp ... commandsThis prevents:
In this repository, "subagent" means a dedicated skill executor behind the router, not a second free-form Codex session.
Current subagents:
github skill - local git actions, repo creation through GitHub API, and test job trackingmcp skill - explicit MCP server inspection, enable/disable, tool listing, and tool callsHow they are triggered:
/gh ... -> GitHub skill/mcp ... -> MCP skillgit push, commit, or run testWhere this happens:
Operationally, subagents are the bot's control plane. Codex remains the coding execution plane.
General:
/start - bootstrap message/help - command summary/status - show current chat status, active runner mode, workdir, model override, MCP servers, and the internal superpowers workflow phase/pwd - show the current project directory for this chat/repo - list switchable git projects under WORKSPACE_ROOT/repo <name> - switch the current chat to another project/repo <keyword> - fuzzy match projects; switch if only one match, otherwise list candidates/repo <typo> - suggests the closest project name when there is no direct match/repo recent - show recent projects for the current chat/repo - - switch back to the previous project/new - clear the saved Codex conversation for the current project and start fresh on the next message/exec <task> - force a one-off Codex run without saving project context/auto <task> - force a one-off fully automatic Codex run without saving project context/plan <task> - ask Codex for a plan only, without direct file modification intent/continue - replay the last blocked same-workdir Codex request once/model [name|reset] - show or set the model override for the current chat/language [en|zh|zh-HK] - show or set the system language for the current chat/verbose [on|off] - show or toggle system notices for the current chat/skill list - show skill switches for the current chat/skill status - alias of /skill list/skill on <name> - enable a skill for the current chat/skill off <name> - disable a skill for the current chat/dev start - start the current repo frontend server (dev, then start)/dev stop - stop the current repo frontend server/dev status - show the current repo frontend server status/dev logs - show the current repo frontend server log tail/dev url - show the detected local frontend URL/sh <command> - run a safe allowlisted Linux command in the current project (disabled by default)/sh --confirm <command> - confirm a dangerous command when writable mode is enabled/restart - restart the bot process explicitly from Telegram/interrupt - interrupt the active Codex run/stop - terminate the active Codex run/cron_now - trigger daily summary immediatelyMCP skill:
/mcp list/mcp status [server]/mcp reconnect <server>/mcp enable <server>/mcp disable <server>/mcp tools <server>/mcp call <server> <tool> {"query":"..."}GitHub skill:
/gh commit "feat: message" -> explicit GitHub write action/gh push -> explicit push for the current branch/gh create repo my-new-repo -> explicit sibling repo creation under WORKSPACE_ROOT/gh confirm -> confirm the pending GitHub write action and execute itcreate repo ..., commit, or push are intercepted and converted into guidance; they no longer execute GitHub writes directly/gh run tests -> launch test job/gh test status <jobId> -> read test status/output tailTelegram adaptation notes:
/exec runs a one-off Codex task and does not overwrite the saved project conversation slot/auto runs a one-off Codex task with approvalPolicy=never on the SDK backend, or codex exec --full-auto on the CLI backend/new is implemented by the bot and resets the current chat session/new only clears the current project's saved Codex conversation slot/status is implemented by the bot and reports local runtime state/status also surfaces the internal superpowers workflow system and the last detected workflow phase for the current chat/project session/repo is implemented by the bot and switches the per-chat working directory inside WORKSPACE_ROOT/skill is implemented by the bot and keeps per-chat skill switches in runtime state/skill only lists toggleable bot skills; superpowers is shown as an internal workflow, not a toggleable skill/dev is implemented by the bot and manages one frontend server per repo workdir, shared across chats/dev start prefers package.json script dev and falls back to start/sh is implemented by the bot, never invokes a shell interpreter, and only accepts configured command prefixes/sh is read-only by default; dangerous prefixes can be configured and require --confirm when writable mode is enabled/plan translates to a planning-only prompt instead of passing a raw /plan slash command to Codex/continue for a one-shot override/language zh or /language zh-HK for localized bot responses/verbose off keeps Telegram output quiet by hiding fallback, startup, and session-exit notices for the current chatCodex output is streamed with throttled editMessageText updates.
STREAM_THROTTLE_MS (default 1200)<think>...</think> extracted and rendered as:
||...||, default)REASONING_RENDER_MODE=quote)CODEX_BACKEND=sdk, Telegram streams structured Codex SDK events and persists thread IDs per projectCODEX_BACKEND=cli, the bot prefers PTY sessions; if node-pty cannot spawn on the current host, it falls back to codex execmcp startup, and duplicate tokens used footernode-pty helper execute permissions before the first PTY sessionConversation state is now tracked per chat + project, not just per chat.
/repo <name>, the bot keeps that project's last Codex session id in runtime state/new clears only the current project's saved conversation slot; other projects in the same Telegram chat are untouched/exec, /auto, and /plan stay one-off by design and do not replace the saved project conversationresumeThread(threadId)codex exec resumeThe bot now blocks a second Codex run when another bot-managed chat already has an active Codex task in the same workdir.
/continue replays the most recently blocked request once for the current chatThe bot includes a minimal repo-scoped frontend runtime layer:
/dev start starts the current repo's frontend command/dev stop stops it/dev status shows whether it is running/dev logs returns the recent output tail/dev url returns the first detected local URL from logsSelection rules:
package.json script devdev is missing, fall back to start/devChoose the execution backend with CODEX_BACKEND:
sdk - preferred for new installs; avoids PTY fragility and uses persistent Codex SDK threadscli - legacy backend; uses PTY when available and falls back to codex execSDK-related options:
CODEX_BACKEND=sdk
CODEX_SDK_CONFIG={}
CODEX_SDK_SKIP_GIT_REPO_CHECK=true
CODEX_SDK_SANDBOX_MODE=danger-full-access
CODEX_SDK_APPROVAL_POLICY=never
CODEX_SDK_REASONING_EFFORT=high
CODEX_SDK_NETWORK_ACCESS_ENABLED=true
CODEX_SDK_WEB_SEARCH_MODE=live
CODEX_SDK_ADDITIONAL_DIRECTORIES=["/abs/path/extra-worktree"]
If CODEX_SDK_SANDBOX_MODE is unset, the bot now defaults SDK threads to Full Access: danger-full-access with approvalPolicy=never. Set it explicitly to workspace-write or read-only only if you want a more restricted mode.
CLI-related options:
CODEX_BACKEND=cli
CODEX_COMMAND=codex
CODEX_ARGS=
node-cron is built in for proactive behavior:
CRON_DAILY_SUMMARY (default 0 9 * * *)PROACTIVE_USER_IDSUse /cron_now for manual trigger during debugging.
Required:
BOT_TOKEN=...
ALLOWED_USER_IDS=123456789,987654321
STATE_FILE=.codex-telegram-claws-state.json
WORKSPACE_ROOT=.
CODEX_WORKDIR=.
Common options:
TELEGRAM_API_BASE=https://api.telegram.org
TELEGRAM_PROXY_URL=
CODEX_COMMAND=codex
CODEX_ARGS=
CODEX_BACKEND=sdk
CODEX_SDK_CONFIG={}
CODEX_SDK_SKIP_GIT_REPO_CHECK=true
CODEX_SDK_SANDBOX_MODE=
CODEX_SDK_APPROVAL_POLICY=
CODEX_SDK_REASONING_EFFORT=
CODEX_SDK_NETWORK_ACCESS_ENABLED=
CODEX_SDK_WEB_SEARCH_MODE=
CODEX_SDK_ADDITIONAL_DIRECTORIES=[]
WORKSPACE_ROOT=/Users/yourname/projects
STATE_FILE=/path/to/codex-telegram-claws-state.json
SHELL_ENABLED=false
SHELL_READ_ONLY=true
SHELL_ALLOWED_COMMANDS=["pwd","ls","git status","git diff --stat","npm test","npm run check"]
SHELL_DANGEROUS_COMMANDS=["git add","git commit","git push","rm","mv","cp","npm publish"]
SHELL_TIMEOUT_MS=20000
SHELL_MAX_OUTPUT_CHARS=12000
STREAM_THROTTLE_MS=1200
STREAM_BUFFER_CHARS=120000
REASONING_RENDER_MODE=spoiler
CRON_DAILY_SUMMARY=0 9 * * *
CRON_TIMEZONE=Asia/Shanghai
PROACTIVE_USER_IDS=123456789
MCP:
MCP_SERVERS=[]
GitHub:
GITHUB_TOKEN=ghp_xxx
GITHUB_DEFAULT_WORKDIR=.
GITHUB_DEFAULT_BRANCH=main
E2E_TEST_COMMAND=npx playwright test --reporter=line
GitHub Actions now includes:
CI workflow on push and pull requestTelegram Smoke manual workflow for live bot-token validation when repository secrets are configuredRelease workflow on v* tags, which reruns validation and publishes a GitHub ReleaseRepository secrets for live smoke checks:
TELEGRAM_BOT_TOKENTELEGRAM_EXPECTED_USERNAME (optional)TELEGRAM_SMOKE_CHAT_ID (optional)Keep live verification output out of git history and release notes. Bot usernames, thread IDs, and chat IDs are environment-specific operator data and should be configured by each user locally or through GitHub secrets.
Recommended local release gate:
BOT_TOKEN=dummy-token ALLOWED_USER_IDS=1 npm run release:check
npm run healthcheck:live
npm run telegram:smoke
v1.0.0 should only be tagged after the full release gate, Telegram smoke checks, and repository metadata sync are complete. The detailed checklist and topic sync command live in release.md.
Release references:
ALLOWED_USER_IDS) is mandatory.env, tokens, or session artifactsCODEX_WORKDIR scoped to a safe workspace rootWORKSPACE_ROOT limited to a parent directory that only contains projects you want the bot to access/sh disabled unless you need it; when enabled, only expose read-only or narrowly scoped command prefixes/sh uses spawn(..., { shell: false }), rejects pipes/redirection/subshell syntax, and runs inside the current project directorySHELL_READ_ONLY=true unless you have a strong reason to allow write commandsSHELL_DANGEROUS_COMMANDS and require /sh --confirm ...The recommended production supervisor is PM2.
ecosystem.config.ts is the canonical config file. Start PM2 with ecosystem.config.cjs, which only bridges PM2 into the TypeScript source.
Basic flow:
pm2 start ecosystem.config.cjs
pm2 status CodexClaw
pm2 logs CodexClaw
pm2 restart CodexClaw
Run exactly one polling process per bot token.
/sh?Usually not for general users. Codex itself can run commands as part of a coding task, so /sh is not required for normal code-edit workflows.
It is useful when you need deterministic operator actions from Telegram, such as:
pwdgit statusgit diff --statnpm testTreat it as an admin-only ops channel, not a general-purpose remote shell.
Telegram can manage runtime usage of Bot-side MCP and skills, but not install arbitrary new servers from chat.
github and mcp independentlySTATE_FILE, so /mcp enable|disable, /skill on|off, /language, /verbose, and per-project Codex conversation slots survive bot restartsBOT_TOKEN and ALLOWED_USER_IDSTELEGRAM_PROXY_URL (HTTP proxy like http://127.0.0.1:7890) or run a local Bot API server and set TELEGRAM_API_BASECODEX_BACKEND, CODEX_COMMAND, and CODEX_WORKDIR~/.codex/sessions and that the saved thread id belongs to the same working directory/mcp tools <server> first to validate server availabilityGITHUB_TOKEN scope (repo) and account permissions/mcpposix_spawnp failed: this usually means the node-pty helper lost execute permissions; startup now auto-repairs it, and npm run healthcheck reports the result@openai/codex-sdk, telegraf, node-pty, node-cron, MCP SDK)Built by @MackDing ? One-Person Company infrastructure powered by AI agents.
| Project | What it does |
|---|---|
| opc.ren | OPC founder hub ? tools, signals, community |
| CodexClaw | Telegram bot for remote Codex access with MCP + subagent routing |
| awesome-ai-api | Leaderboard of 200+ AI API gateways & relays |
| claude-context-health | Diagnose & fix Claude Code session degradation |
| opc-daily-signal | AI-powered daily decision intelligence for OPC founders |
| doc-preprocess-hub | Enterprise document preprocessing ? MinerU + docling |
npx CLI installing 100+ agents, commands, hooks, and integrations in one command
干净、强大、属于你的 AI Agent 平台 --AI agents, without the clutter.
Native macOS app to monitor Claude AI usage limits and watch your coding sessions live
Pocket Flow: Codebase to Tutorial