TOKREPO · 工具
Codex CLI logo
CLI · OpenAI

Codex CLI

openai.com

它是什么

Codex CLI 是 OpenAI 官方的命令行 coding agent,2025 年发布,开源在 openai/codex 仓库(Apache-2.0)。本地终端跑,对接 ChatGPT Pro/Plus 或 API 鉴权,用 OpenAI 的推理模型(GPT-5 系 + o 系),文件编辑、shell、补丁工具一应俱全。

Codex CLI 也是带火 AGENTS.md 约定的工具 —— 一个跟 Claude 的 CLAUDE.md 平行的中立约定文件。AGENTS.md 现在被 Aider、Continue.dev、不久还会有 Gemini CLI 等多个 agent 采纳,项目级别指令能跨工具复用。

什么时候应该用:

  • 已经在交 ChatGPT Pro/Plus,想拿这份配额做终端 coding
  • 想要中立的指令文件,其他 agent 也认
  • 喜欢 OpenAI 推理模型在找 bug、规划重构上的强度

它为什么突出

功能 给你什么
ChatGPT 鉴权 直接用 ChatGPT Pro/Plus 账号登 —— 不用单独 API key
AGENTS.md 中立指令文件,跨 agent 通用
Apache-2.0 跟 Gemini CLI 同 OSI 开源协议,可自由 fork
MCP 支持 2025 年底加入;Codex CLI 现在读 ~/.codex/mcp.json
审批模式 --auto-edit / --full-auto / --read-only 分级信任
推理模型 GPT-5 / o 系在深度规划上强
沙箱 shell macOS 用 Seatbelt,Linux 用 Landlock,命令执行更安全

怎么装

# macOS / Linux / WSL
npm install -g @openai/codex

# 或者 Homebrew
brew install codex

装完在任意项目目录跑 codex。首次会提示 ChatGPT 登录(浏览器 OAuth)或要 OPENAI_API_KEY。在仓库根放一份 AGENTS.md 写项目约定,Codex CLI 每次会话开头都会读。

在 Codex CLI 里装啥

Codex CLI 表面有两个主要配置:~/.codex/config.toml 全局设置,AGENTS.md 项目级指令。三个 TokRepo pack 起手:

  • AGENTS.md 模板 —— 经过实战的 Python / Node / Go / Rust monorepo 指令文件
  • MCP 服务器全家桶 —— Postgres / GitHub / Filesystem MCP server,跟 Claude Code 共用
  • OpenAI 推理工作流 pack —— codex 命令调好 o 系的强项

tokrepo install 装其一,你的 AGENTS.md~/.codex/ 目录就跟 OpenAI 研究预览 demo 的基线对齐了。

常见坑

  • API key 和 ChatGPT 鉴权混用 —— 二选一;混用会让 CLI 同时打两个 endpoint,配额冲突
  • --full-auto 烧钱忘 —— 全自动会跑所有提议的 shell 命令;要么配沙箱要么会在重构循环里跑 npm install 30 次
  • AGENTS.md 越写越大 —— Codex 每轮都重读。控制在 200 行以内,或拆到每个目录单独的 AGENTS.md
  • MCP 路径解析 —— Codex 看 ~/.codex/mcp.json,不是 .claude/。别建软链,用自带的 tokrepo migrate
  • macOS Seatbelt 拦 GUI 工具 —— 任务要浏览器自动化,只在一次性 VM 里 --sandbox=none,永远别在开发机上

与其他工具的关系

Codex CLI 最大的胜利是 AGENTS.md 约定 —— 多个 agent 都认这个文件,写好一次跨工具链都受益。跟 Claude Code 比,Codex CLI subagent 生态没那么成熟,但 ChatGPT Pro 集成更紧。跟 Gemini CLI 比,多模态没那么顺,但有 o 系推理模型扛硬重构。2026 年多数团队把 Codex CLI 当 AGENTS.md 编辑环境,特定阶段再换其他 agent。

7个资产·5个 script·2个 skill
全部资产

7 个资产适配 Codex CLI

Script#01
GPT Researcher — Autonomous Research Report Agent

AI agent that generates detailed research reports from a single query. Searches multiple sources, synthesizes findings, and cites references.

by TokRepo Curated·339 views
$ tokrepo install gpt-researcher-autonomous-research-report-agent-23330210
Script#02
OpenAI Codex CLI — Official Coding Agent

OpenAI official coding agent CLI. Supports Agent Skills, custom prompts, and IDE integration. Open-source alternative to Cursor.

by OpenAI·226 views
$ tokrepo install openai-codex-cli-official-coding-agent-3de6c5c7
Script#03
OpenAI Realtime Agents — Voice AI Agent Patterns

Advanced agentic patterns for voice AI built on OpenAI Realtime API. Chat-supervisor and sequential handoff patterns with WebRTC streaming. MIT, 6,800+ stars.

by OpenAI·139 views
$ tokrepo install openai-realtime-agents-voice-ai-agent-patterns-0d228731
Skill#04
OpenAI Codex & Cookbook — Official Collection

Official OpenAI resources: Codex CLI coding agent and the OpenAI Cookbook with prompting guides for GPT, Codex, and Realtime API.

by OpenAI·138 views
$ tokrepo install openai-codex-cookbook-official-collection-63156b9d
Script#05
OpenAI Codex CLI — Terminal Coding Agent by OpenAI

Official OpenAI terminal coding agent. Reads your codebase, writes code, runs commands, and manages files from the command line. Multi-model support with sandbox execution. 20,000+ stars.

by OpenAI·125 views
$ tokrepo install openai-codex-cli-terminal-coding-agent-openai-11647c80
Script#06
OpenAI Agents SDK — Build Multi-Agent Systems in Python

Official OpenAI Python SDK for building multi-agent systems with handoffs, guardrails, and tracing. Agents delegate to specialists, enforce safety rules, and produce observable traces. 8,000+ stars.

by OpenAI·83 views
$ tokrepo install openai-agents-sdk-build-multi-agent-systems-python-38035d0b
Skill#07
Codex Plugin for Claude Code — OpenAI Cross-Review

Official OpenAI plugin that adds Codex code review and task delegation inside Claude Code. Get adversarial reviews, rescue debugging, and multi-model collaboration.

by Agent Toolkit·53 views
$ tokrepo install codex-plugin-claude-code-openai-cross-review-208207e5
FAQ

常见问题

Codex CLI 免费吗?

CLI 本身 Apache-2.0 开源免费。要跑得有 OpenAI API key(按量付费)或 ChatGPT Pro/Plus 订阅。ChatGPT Pro 每月 $200 给 Codex CLI 配额最足;Plus $20/月够轻度用。

AGENTS.md 是啥,Codex CLI 为啥用?

AGENTS.md 是项目根的中立文件,告诉任何 agent 在这个 codebase 怎么干活 —— 编码约定、构建命令、要避开的事。Codex CLI 是第一个主流支持的 agent,规范在 agents.md,现在 Aider、Continue 等都认。一次写,跨工具用。

Codex CLI 能用 Claude 或 Gemini 模型吗?

官方出厂指向 OpenAI 模型(GPT-5、o 系)。社区 fork 允许换 base URL 到 OpenRouter 或 Anthropic 兼容端点,但工具调用 schema 差距足够大,容易碎。主流路径是 Codex CLI 走 OpenAI 模型,其他厂用各自 CLI。

Codex CLI 和 Claude Code 哪个好?

各有所长。Claude Code subagent 和 hook 生态最成熟。Codex CLI 是 ChatGPT Pro 集成最好且带火 AGENTS.md 的。很多人两个都跑:要 OpenAI 推理用 Codex CLI,要长任务多步重构用 Claude Code。

Codex CLI 能在 CI 非交互跑吗?

能。codex --quiet --full-auto 配上 OPENAI_API_KEY 即可。常见模式:GitHub Actions job 跑 Codex CLI 起草 PR 审查或 codemod,人审后合并。配 --sandbox=workspace-write 限制损害面。

更多工具

回首页浏览全部工具

8 个工具精选 · favicon 真实 logo · 按类型聚合

返回工具总览