安装 Codex CLI
# 方式一:npm(推荐,Node 18+ 环境)
npm install -g @openai/codex
# 方式二:Homebrew(macOS)
brew install --cask codex
# 方式三:从 GitHub Releases 直接下载二进制(网络受限时用)
# macOS Apple Silicon
curl -L https://github.com/openai/codex/releases/download/rust-v0.131.0/codex-aarch64-apple-darwin.tar.gz | tar -xz
sudo mv codex /usr/local/bin/
# macOS Intel
curl -L https://github.com/openai/codex/releases/download/rust-v0.131.0/codex-x86_64-apple-darwin.tar.gz | tar -xz
sudo mv codex /usr/local/bin/
# Linux x86_64(musl 静态链接,不依赖系统 glibc,推荐)
curl -L https://github.com/openai/codex/releases/download/rust-v0.131.0/codex-x86_64-unknown-linux-musl.tar.gz | tar -xz
sudo mv codex /usr/local/bin/
验证安装:
codex --version
# 输出:codex 0.131.0
配置
找到 C:\Users\你的用户名\.codex 文件夹(如果没有则创建)
创建config.toml
disable_response_storage = true
model = "gpt-5.3-codex"
model_reasoning_effort = "high"
model_provider = "openai"
sandbox_mode="danger-full-access"
windows_wsl_setup_acknowledged = true
base_instructions = "Always prefer built-in tools (read_file, list_dir, grep_files) over shell commands for file operations."
[experimental]
use_freeform_apply_patch = true
use_unified_exec_tool = true
[features]
apply_patch_freeform = true
ghost_commit = true
plan_tool = true
rmcp_client = true
streamable_shell = false
unified_exec = false
view_image_tool = true
experimental_sandbox_command_assessment = true
parallel = true
skills = true
[sandbox_workspace_write]
network_access = true
[windows]
sandbox = "unelevated"
[projects.'xxx']
trust_level = "trusted"
[notice.model_migrations]
"gpt-5.3-codex" = "gpt-5.4"
命令-会话前
功能描述
命令
更新 CLI
npm install -g @openai/codex@latest
会话管理: 继续"最近一次会话"
codex resume --last
会话管理: 打开会话选择器 并显示"所有历史会话" 再在列表里手动选一个恢复
codex resume --all
恢复指定会话
codex resume SESSION_ID
展示已知功能开关、成熟度阶段以及当前生效状态
codex features list
命令-会话中
功能描述
命令
初始化项目,生成 AGENTS.md 文件
/init
总结对话内容,避免超出语境限制
/compact
开启计划模式
/plan 或 Shift + Tab
开启 "极速模式",但额度消耗会翻倍
/fast
生成一个侧边聊天 (当你深入讨论,想在当前语境下提出一个附带问题时,它非常有效)
/side
把指定文件放入对话中
/mention 或 @
插件管理
/plugins
mcp 工具管理
/mcp
skills 管理
/skills
主动触发 skill
$name_skill 提示词
将最新的 Codex 输出复制到剪贴板
/copy
配置记忆开关和生成范围
/memories
交互式配置 TUI 底部状态栏项
/statusline
交互式配置终端窗口或标签标题项
/title
选择或隐藏终端宠物
/pets
配置说明
/statusline配置项
使用的主题颜色
Use theme colors
Codex应用版本
codex-version
带推理级别的当前模型名称
model-with-reasoning
当前工作目录
current-dir
当前模型名称
model
项目名称
project-name
当前Git分支
git-branch
当前分支的pull请求号
pull-request-number
针对默认分支提交的分支更改
branch-changes
精简会话运行状态文本 (Ready, Working, Thinking)
run-state
上下文窗口使用的百分比
context-used
上下文窗口剩余的百分比
context-remaining
以token表示的上下文窗口总大小
context-window-size
5小时使用限制的剩余使用量
five-hour-limit
每周使用限制的剩余使用量
weekly-limit
会话中使用的token总量
used-tokens
会话中使用的总输入token
total-input-tokens
会话中使用的总输出token
total-output-tokens
当前会话标识符
session-id
当前是否激活快速模式
fast-mode
裸回滚模式是否激活
raw-output
当前线程标题
thread-title
最新任务进度
task-progress
配置说明
/pets配置项
禁用终端宠物
Disable terminal pets
蓝屏小精灵
BSOD
原始的Codex伴侣
Codex
小水滴
Dewey
小火焰
Fireball
空指针小精灵
Null Signal
小石头
Rocky
小树芽
Seedy
工作栈小精灵
Stacky
Skills调用优化
背景
Codex 的 Skills调用主动性 明显不如 Claude Code
可能出现 匹配Skill 但不调用的情况
Codex 的 API key 无法显式调用,只有账号订阅
解决方法1:反代
解决方法2:补充AGENTS.md
配置开启:打开:.codex/config.toml
添加:
[features]
skills = true
在 .codex/AGENTS.md 中添加:
# Global Agent Rules
You have personal skills stored in `~/.codex/skills/`.
Before starting a task, scan available skills.
If a skill matches, read its `SKILL.md` and follow it.
Announce which skill you are using.
这样codex每次对话启动前就会简单扫描一遍skills文件夹
确保每次对话的时候一定能够扫描一次,确保不会忘记使用skills