Codex MCP Dev
Use the local Codex installation through the wrapper script at {baseDir}/scripts/codex_mcp.py.
This gives a stable path:
OpenClaw → mcporter → codex-mcp-server → local INLINECODE1
Quick Setup
Install prerequisites first:
- - INLINECODE2
- local INLINECODE3
- INLINECODE4
Create the project MCP entry if config/mcporter.json does not exist yet:
CODEBLOCK0
This skill expects a workspace-local MCP server named codex-cli.
Workflow
- 1. Use this skill for non-trivial coding tasks.
- If it is the first use in a session or something looks broken, run:
-
python3 {baseDir}/scripts/codex_mcp.py doctor
- 3. Choose a mode:
-
Analysis / planning / explanation: use
ask without
--full-auto
-
Implementation / refactor / test-writing: use
ask --full-auto
- 4. Always set
--cwd to the target repo or project directory. - Give Codex a concrete prompt with files, constraints, and acceptance criteria.
- After Codex responds, inspect files and run local tests yourself when feasible instead of trusting the tool output blindly.
- Summarize changes, tests run, and any remaining risks.
Good Uses
- - Implementing features across multiple files
- Fixing bugs with real repo context
- Refactoring with constraints
- Writing or updating tests
- Debugging failing commands or stack traces
- Asking local Codex for a second implementation pass or review
Command Patterns
Health check
CODEBLOCK1
Version info
CODEBLOCK2
Normal implementation
CODEBLOCK3
Read-only analysis
CODEBLOCK4
Long prompt from file
CODEBLOCK5
Prompting Rules
Include as many of these as possible:
- - Target files or directories
- Desired behavior
- Exact error messages or failing tests
- Constraints on scope
- Required test updates
- Expected output format
Prefer prompts like:
- - "Fix the failing test in
tests/api.test.ts without changing public behavior. Run the relevant tests and summarize the root cause." - "Refactor
src/cache.py for readability, keep behavior identical, and add regression tests for TTL edge cases." - "Review the auth flow in
server/ and identify the top 3 correctness risks with concrete file references."
Guardrails
- - Prefer
--full-auto for ordinary implementation work. - Do not use
--yolo unless the user explicitly wants aggressive execution. - Use repo-specific
--cwd; do not run against the wrong directory. - Validate with local reads/tests when possible.
- If the task is tiny or surgical, skip this skill and edit directly.
Codex MCP Dev
通过位于 {baseDir}/scripts/codex_mcp.py 的包装脚本来使用本地 Codex 安装。
这提供了一个稳定的路径:
OpenClaw → mcporter → codex-mcp-server → 本地 codex
快速设置
首先安装先决条件:
- - mcporter
- 本地 codex
- codex-mcp
如果 config/mcporter.json 尚不存在,则创建项目 MCP 条目:
bash
mcporter config add codex-cli --scope project --command codex-mcp
此技能需要一个名为 codex-cli 的工作区本地 MCP 服务器。
工作流程
- 1. 对于非平凡的编码任务使用此技能。
- 如果是会话中首次使用或出现异常,请运行:
- python3 {baseDir}/scripts/codex_mcp.py doctor
- 3. 选择一种模式:
-
分析/规划/解释: 使用 ask 而不加 --full-auto
-
实现/重构/测试编写: 使用 ask --full-auto
- 4. 始终将 --cwd 设置为目标仓库或项目目录。
- 为 Codex 提供包含文件、约束和验收标准的具体提示。
- 在 Codex 响应后,自行检查文件并在可行时运行本地测试,而不是盲目信任工具输出。
- 总结变更内容、已运行的测试以及任何剩余风险。
适用场景
- - 跨多个文件实现功能
- 在真实仓库上下文中修复错误
- 在约束条件下进行重构
- 编写或更新测试
- 调试失败的命令或堆栈跟踪
- 请求本地 Codex 进行二次实现或审查
命令模式
健康检查
bash
python3 {baseDir}/scripts/codex_mcp.py doctor
版本信息
bash
python3 {baseDir}/scripts/codex_mcp.py version
正常实现
bash
python3 {baseDir}/scripts/codex_mcp.py ask \
--cwd /absolute/path/to/repo \
--full-auto \
--prompt 实现请求的变更,更新测试,并总结变更内容。
只读分析
bash
python3 {baseDir}/scripts/codex_mcp.py ask \
--cwd /absolute/path/to/repo \
--sandbox-mode read-only \
--approval-policy never \
--prompt 解释该错误,确定可能的根本原因,并提出最小的安全修复方案。
从文件读取长提示
bash
python3 {baseDir}/scripts/codex_mcp.py ask \
--cwd /absolute/path/to/repo \
--full-auto \
--prompt-file /tmp/codex-task.txt
提示规则
尽可能包含以下内容:
- - 目标文件或目录
- 期望的行为
- 确切的错误消息或失败的测试
- 范围约束
- 所需的测试更新
- 预期的输出格式
推荐使用类似这样的提示:
- - 修复 tests/api.test.ts 中失败的测试,不改变公共行为。运行相关测试并总结根本原因。
- 重构 src/cache.py 以提高可读性,保持行为不变,并为 TTL 边界情况添加回归测试。
- 审查 server/ 中的认证流程,识别前 3 个正确性风险,并附上具体的文件引用。
安全护栏
- - 对于普通的实现工作,优先使用 --full-auto。
- 不要使用 --yolo,除非用户明确要求激进执行。
- 使用仓库特定的 --cwd;不要在错误的目录下运行。
- 尽可能通过本地读取/测试进行验证。
- 如果任务很小或很精确,跳过此技能并直接编辑。