OpenAI Codex CLI 命令在线速查:涵盖代码生成、审查、测试、配置管理等常用命令,点击命令即可复制。
| 操作 | 命令 |
|---|---|
| 启动交互模式 | codex |
| 单次执行 | codex exec "你的指令" |
| 继续会话 | codex resume |
| 列出会话 | codex sessions |
| 清除会话 | codex sessions clear |
| 查看版本 | codex --version |
| 显示帮助 | codex --help |
| 操作 | 命令 |
|---|---|
| 生成函数 | codex generate "实现快速排序函数" |
| 生成类 | codex generate "创建 User 类,包含 name 和 email" |
| 生成 API | codex generate "创建 REST API 端点 /users" |
| 生成数据库模型 | codex generate "创建 Product 数据库模型" |
| 生成前端组件 | codex generate "创建 React 登录表单组件" |
| 指定语言 | codex generate --lang python "实现二分查找" |
| 指定框架 | codex generate --framework django "创建视图" |
| 操作 | 命令 |
|---|---|
| 审查文件 | codex review path/to/file.py |
| 审查目录 | codex review ./src/ |
| 审查 Git 差异 | codex review --diff |
| 检查代码质量 | codex review --quality path/to/file.js |
| 检查安全漏洞 | codex review --security path/to/file.py |
| 检查性能问题 | codex review --performance path/to/file.go |
| 生成审查报告 | codex review --report ./src/ > review.md |
| 操作 | 命令 |
|---|---|
| 生成单元测试 | codex test path/to/function.py |
| 生成集成测试 | codex test --integration path/to/api.py |
| 生成测试用例 | codex test --cases "calculate_total 函数" |
| 指定测试框架 | codex test --framework pytest path/to/file.py |
| 生成 mock | codex test --mock path/to/service.py |
| 覆盖率分析 | codex test --coverage ./tests/ |
| 操作 | 命令 |
|---|---|
| 查看配置 | codex config show |
| 设置 API Key | export OPENAI_API_KEY=your_key |
| 设置模型 | codex config set model gpt-4-turbo |
| 设置温度 | codex config set temperature 0.3 |
| 设置输出格式 | codex config set output_format json |
| 重置配置 | codex config reset |
| 配置文件路径 | ~/.codex/config.yaml |
| 操作 | 命令 |
|---|---|
| 查看限额 | codex quota |
| 降低频率 | codex config set rate_limit 10 |
| 操作 | 命令 |
|---|---|
| 增加限制 | codex config set max_tokens 8192 |
| 操作 | 命令 |
|---|---|
| 添加上下文 | codex generate --context "使用 TypeScript + Express" |
| 操作 | 命令 |
|---|---|
| 测试连接 | curl https://api.openai.com |
| 设置代理 | export HTTPS_PROXY=http://proxy:port |