Loading...
Loading...
Compare original and translation side by side
npm install -g @openai/codexcodex-C /path/to/projectnpm install -g @openai/codexcodex-C /path/to/projectcodex exec --json --sandbox workspace-write --skip-git-repo-check --model gpt-5.4 "你的任务描述"{"type":"thread.started","thread_id":"019d32fc-..."}
{"type":"turn.started"}
{"type":"item.completed","item":{"id":"item_0","type":"agent_message","text":"回复内容"}}
{"type":"turn.completed","usage":{"input_tokens":46879,"cached_input_tokens":2432,"output_tokens":54}}thread.startedthread_iditem.completeditem.type == "agent_message"textturn.completedusagestderrstdout{stderrcodex exec --json --sandbox workspace-write --skip-git-repo-check --model gpt-5.4 "Your task description"{"type":"thread.started","thread_id":"019d32fc-..."}
{"type":"turn.started"}
{"type":"item.completed","item":{"id":"item_0","type":"agent_message","text":"Response content"}}
{"type":"turn.completed","usage":{"input_tokens":46879,"cached_input_tokens":2432,"output_tokens":54}}thread_idthread.startedtextitem.completeditem.type == "agent_message"usageturn.completedstderrstdout{stderrReading additional input from stdin...codex exec-codex exec --json --sandbox workspace-write --full-auto --model gpt-5.4 \
--skip-git-repo-check - < /tmp/task-prompt.txt > /tmp/task-out.jsonl 2>&1Reading additional input from stdin...codex exec-codex exec --json --sandbox workspace-write --full-auto --model gpt-5.4 \
--skip-git-repo-check - < /tmp/task-prompt.txt > /tmp/task-out.jsonl 2>&1codex exec resume --json --model gpt-5.4 "thread_id" "后续提问"codex exec resume --json --model gpt-5.4 "thread_id" "Follow-up question"codex exec resume --json --model gpt-5.4 --last "后续提问"--last--allcodex exec resume --json --model gpt-5.4 --last "Follow-up question"--last--all--ephemeral--ephemeral--ephemeral~/.codex/sessions/codex exec resume--last--ephemeralclaude -p --no-session-persistence--ephemeral~/.codex/sessions/codex exec resume--last--ephemeralclaude -p --no-session-persistence| Flag | 说明 |
|---|---|
| JSONL 格式输出,便于解析事件流 |
| 用 JSON Schema 约束最后一条消息的结构 |
| 将最后一条消息直接写入文件 |
| 颜色输出: |
| Flag | Description |
|---|---|
| Output in JSONL format for easy event stream parsing |
| Use JSON Schema to constrain the structure of the last message |
| Write the last message directly to a file |
| Color output: |
| Flag | 说明 |
|---|---|
| 沙箱模式: |
| 当前等价于 |
| 跳过所有确认和沙箱,极度危险 |
| 指定工作目录 |
| 允许在非 git 目录运行 |
| 额外可写目录(可重复) |
| Flag | Description |
|---|---|
| Sandbox mode: |
| Currently a shortcut equivalent to |
| Skip all confirmations and sandbox protections, extremely dangerous |
| Specify the working directory |
| Allow running in non-git directories |
| Additional writable directory (can be repeated) |
| Flag | 说明 |
|---|---|
| 指定模型,建议显式传递 |
| 使用 |
| 覆盖 |
| 启用 feature flag(可重复) |
| 禁用 feature flag(可重复) |
| 使用本地开源模型 provider |
| 指定本地 provider(如 |
| Flag | Description |
|---|---|
| Specify the model, explicit passing is recommended |
| Use the profile in |
| Override configuration items in |
| Enable feature flags (can be repeated) |
| Disable feature flags (can be repeated) |
| Use local open-source model providers |
| Specify local providers (e.g., |
| Flag / 方式 | 说明 |
|---|---|
| 附加图片(可重复) |
| 直接把短任务作为命令行参数传入;只推荐给短 prompt |
| 不传 prompt,或把 prompt 写成 |
| Flag / Method | Description |
|---|---|
| Attach images (can be repeated) |
| Pass short tasks directly as command-line parameters; only recommended for short prompts |
| Do not pass a prompt, or set the prompt to |
| Flag | 说明 |
|---|---|
| JSONL 格式输出 |
| 指定模型 |
| 便捷写法,等价于 |
| 跳过确认和沙箱 |
| 允许非 git 目录 |
| 不持久化 |
| 附加图片 |
| 最后消息写入文件 |
| 覆盖 |
| 启用特性(可重复) |
| 禁用特性(可重复) |
| 恢复最近一次会话(无需指定 ID) |
| 查找全部会话(不限当前目录) |
| Flag | Description |
|---|---|
| Output in JSONL format |
| Specify the model |
| Shortcut equivalent to |
| Skip confirmations and sandbox protections |
| Allow running in non-git directories |
| Do not persist the session |
| Attach images |
| Write the last message to a file |
| Override configuration items in |
| Enable features (can be repeated) |
| Disable features (can be repeated) |
| Resume the most recent session (no need to specify ID) |
| Search all sessions (not limited to current directory) |
codex exec review [OPTIONS] [PROMPT]| Flag | 说明 |
|---|---|
| 审查暂存、未暂存和未跟踪的变更 |
| 对比指定基准分支 |
| 审查指定 commit 引入的变更 |
| review 摘要中显示的标题 |
| 指定模型 |
| JSONL 格式输出 |
| 便捷写法,等价于 |
| 不持久化 |
| 最后消息写入文件 |
codex exec review [OPTIONS] [PROMPT]| Flag | Description |
|---|---|
| Review staged, unstaged, and untracked changes |
| Compare against the specified base branch |
| Review changes introduced by the specified commit |
| Title displayed in the review summary |
| Specify the model |
| Output in JSONL format |
| Shortcut equivalent to |
| Do not persist the session |
| Write the last message to a file |
codex exec --json ...thread_idcodex exec resume --json "thread_id" "prompt"thread_idthread_idcodex exec --json ...thread_idcodex exec resume --json "thread_id" "prompt"thread_idthread_id--model| 任务复杂度 | model | 适用场景 |
|---|---|---|
| 高 | | 架构设计、复杂重构、多文件编码 |
| 中 | | 单文件功能实现、bug 修复 |
| 低 | | 简单问答、代码解释 |
--model| Task Complexity | Model | Applicable Scenarios |
|---|---|---|
| High | | Architecture design, complex refactoring, multi-file coding |
| Medium | | Single-file feature implementation, bug fixes |
| Low | | Simple Q&A, code explanation |
| 场景 | model | sandbox | 其他 flags |
|---|---|---|---|
| 复杂编码 | | | |
| 一般编码 | | | |
| 只读问答 / 分析 | | | |
| 浏览器调研 / Computer Use | | | |
| 代码审查 | | | |
| 仓库 review | | — | |
| 快速问答 | | | |
| 结构化输出 | | | |
| Scenario | Model | Sandbox | Other Flags |
|---|---|---|---|
| Complex Coding | | | |
| General Coding | | | |
| Read-only Q&A / Analysis | | | |
| Browser Research / Computer Use | | | |
| Code Review | | | |
| Repository Review | | — | |
| Quick Q&A | | | |
| Structured Output | | | |
--jsonthread_id--modelcd /path/to/project-C /path/to/projectworkspace-write--sandbox workspace-write--full-autoread-onlycodex exec reviewthread_id--ephemeral--output-schema-o- < file.txtReading additional input from stdin...-o--json-o--jsonread-only--full-autoDo not modify local files.--jsonthread_id--modelcd /path/to/project-C /path/to/projectworkspace-write--sandbox workspace-write--full-autoread-onlycodex exec reviewthread_id--ephemeral--output-schema-o- < file.txtReading additional input from stdin...-o--json-o--jsonread-only--full-autoDo not modify local files.用户:用 Codex 在当前项目里实现一个 TODO API
步骤 1 - 新建会话:
cd /path/to/project && codex exec --json --full-auto --model gpt-5.4 "Implement a REST API for TODO items with CRUD endpoints. Use Express.js."
→ 解析输出,获得 thread_id: "xxx",回复: "Implemented server.js ..."
用户:加上单元测试
步骤 2 - 继续会话:
cd /path/to/project && codex exec resume --json --model gpt-5.4-mini "xxx" "Add unit tests for all the TODO API endpoints using vitest."User: Use Codex to implement a TODO API in the current project
Step 1 - Create a new session:
cd /path/to/project && codex exec --json --full-auto --model gpt-5.4 "Implement a REST API for TODO items with CRUD endpoints. Use Express.js."
→ Parse output to get thread_id: "xxx", response: "Implemented server.js ..."
User: Add unit tests
Step 2 - Resume the session:
cd /path/to/project && codex exec resume --json --model gpt-5.4-mini "xxx" "Add unit tests for all the TODO API endpoints using vitest."cd /path/to/project && codex exec resume --json --model gpt-5.4-mini --last "Continue the refactor and remove the dead helper functions."thread_idcd /path/to/project && codex exec resume --json --model gpt-5.4-mini --last "Continue the refactor and remove the dead helper functions."thread_idundefinedundefinedundefinedundefinedcd /path/to/project && codex exec --json --sandbox read-only --model gpt-5.4-mini \
--output-schema ./review-schema.json \
-o /tmp/review-result.json \
"Review src/todo.ts and output summary, risks, and suggested tests."cd /path/to/project && codex exec --json --sandbox read-only --model gpt-5.4-mini \
--output-schema ./review-schema.json \
-o /tmp/review-result.json \
"Review src/todo.ts and output summary, risks, and suggested tests."codex exec \
-m gpt-5.4 \
--sandbox read-only \
--skip-git-repo-check \
-C "$PWD" \
-o /tmp/codex-last.txt \
"Use Computer Use on my Mac. Open Google Chrome, go to Reddit, search for 'Duolingo review', open 3 representative posts (one positive, one negative, one long-term review), then summarize the findings in Chinese. Do not modify local files."codex exec \
-m gpt-5.4 \
--sandbox read-only \
--skip-git-repo-check \
-C "$PWD" \
-o /tmp/codex-last.txt \
"Use Computer Use on my Mac. Open Google Chrome, go to Reddit, search for 'Duolingo review', open 3 representative posts (one positive, one negative, one long-term review), then summarize the findings in Chinese. Do not modify local files."codex exec \
-m gpt-5.4 \
--sandbox read-only \
--skip-git-repo-check \
-C "$PWD" \
--json \
-o /tmp/codex-last.txt \
"Use Computer Use on my Mac. Open Google Chrome, search Reddit for Duolingo reviews, open a few representative posts, and then summarize them in Chinese. Do not modify local files."/tmp/codex-last.txtcodex exec \
-m gpt-5.4 \
--sandbox read-only \
--skip-git-repo-check \
-C "$PWD" \
--json \
-o /tmp/codex-last.txt \
"Use Computer Use on my Mac. Open Google Chrome, search Reddit for Duolingo reviews, open a few representative posts, and then summarize them in Chinese. Do not modify local files."/tmp/codex-last.txtcd /path/to/project && codex exec --json --sandbox read-only --model gpt-5.4-mini \
-i ./screenshots/login-bug.png \
"Describe the UI issue in this screenshot and propose a minimal fix plan."cd /path/to/project && codex exec --json --sandbox read-only --model gpt-5.4-mini \
-i ./screenshots/login-bug.png \
"Describe the UI issue in this screenshot and propose a minimal fix plan."undefinedundefined
适合市场调研、多段 Markdown 约束、脚本拼装 prompt,或任何已经超过一屏的任务描述。
Suitable for market research, multi-paragraph Markdown constraints, script-assembled prompts, or any task description that exceeds one screen.cat ./prompt.md | codex exec --json --sandbox workspace-write --model gpt-5.4 -- < file.txtcat ./prompt.md | codex exec --json --sandbox workspace-write --model gpt-5.4 -- < file.txt