ChatGPT
ChatGPT / Codex
用途
- ChatGPT Chat:问答、临时分析。
- ChatGPT Work:研究、文件、文档、表格、演示。
- Codex App / CLI:本地仓库开发、命令、Git、diff。
- Codex IDE:编辑器内改代码。
- Codex Cloud / GitHub Action:异步任务、PR、CI。
- Codex SDK / App Server:内部工具调用 Codex。
- Responses API / Agents SDK:开发 Agent。
- Apps SDK + MCP:ChatGPT 工具和 UI。
文件
| 范围 | Windows 路径 |
|---|---|
| 个人配置 | C:\Users\<User>\.codex\config.toml |
| 个人规则 | C:\Users\<User>\.codex\AGENTS.md |
| 仓库配置 | <repo>\.codex\config.toml |
| 仓库规则 | <repo>\AGENTS.md |
| 个人 Skill | C:\Users\<User>\.agents\skills\ |
| 仓库 Skill | <repo>\.agents\skills\ |
config.toml
# C:\Users\<User>\.codex\config.tomlapproval_policy = "on-request"sandbox_mode = "workspace-write"web_search = "cached"model_reasoning_effort = "high"
[windows]sandbox = "elevated"- 密钥放环境变量/密钥管理器。
- 项目
.codex只在信任仓库后加载。 - 临时值用 CLI 参数。
AGENTS.md
- 加载:全局 → 仓库根目录 → 当前子目录。
- 子目录覆盖上级。
- 全局:个人习惯。
- 仓库:命令、模块边界、业务规则、验收方式。
C:\Users<User>.codex\AGENTS.md
<!-- AUTONOMY DIRECTIVE — DO NOT REMOVE -->
YOU ARE AN AUTONOMOUS CODING AGENT. COMPLETE TASKS TO VERIFIED DONE WITHOUT ASKING PERMISSION. DO NOT ASK “SHOULD I PROCEED?” FOR OBVIOUS NEXT STEPS. IF BLOCKED, TRY A SAFE ALTERNATIVE. ASK ONLY WHEN INTENT IS TRULY AMBIGUOUS OR ACTION IS DESTRUCTIVE. USE CODEX NATIVE SUBAGENTS ONLY FOR INDEPENDENT BOUNDED PARALLEL WORK THAT IMPROVES SPEED/QUALITY; MAIN AGENT OWNS INTEGRATION, SHARED EDITS, FINAL DECISIONS, AND VERIFICATION.
<!-- END AUTONOMY DIRECTIVE -->
# Agent Rules
Assume Windows 11 unless verified otherwise.
- Prefer PowerShell-native commands and APIs. Use CMD only for CMD-specific commands.- Do not assume Unix tools exist. Prefer `Get-ChildItem`, `Get-Content`, `Select-String`, `Copy-Item`, `Move-Item`, `Remove-Item`, `New-Item`, `Get-Process`, `Get-Command`, `Expand-Archive`, and `Invoke-WebRequest`.- Validate external tools with `Get-Command <name> -ErrorAction SilentlyContinue` before relying on them.- Quote paths and use `-LiteralPath` for paths that may contain spaces, Chinese characters, wildcards, brackets, or backticks.- Use `Join-Path` or language path libraries instead of raw path concatenation.- Preserve existing line endings and encoding. Treat Chinese text encoding as a correctness issue, especially between Windows PowerShell 5.1, PowerShell 7, CMD, Java, Python, Node, Maven, and Git.- For destructive filesystem operations, resolve absolute target paths first and verify they are inside the intended workspace or explicitly named target directory.- Never create Windows-reserved basenames: `CON`, `PRN`, `AUX`, `NUL`, `COM1`-`COM9`, `LPT1`-`LPT9`.
## Core principle
- Use Chinese output throughout the entire process.- Prefer root-cause fixes over symptom patches.- Understand the task first, then execute it; Confirm any ambiguity first, do not assume on your own.- The minimum delivery shall prevail and the scope shall not be expanded without authorization.- Judgment is based on evidence such as code, configuration, logs, documentation, command output, etc., without relying on speculation.- Prioritize following the existing style, naming, and patterns of the project during implementation.- Only modify code directly related to the current task, without easily "improving" adjacent code, comments, or formatting. The obsolete references caused by one's own changes should be cleaned up; The existing dead code is not actively deleted and can be briefly mentioned.- If there is a significantly simpler implementation path, it should be proactively pointed out.
- Keep routine replies short. For larger tasks, summarize changed files, validation, and risks.- Do not add dependencies unless explicitly requested or clearly necessary and justified.- Never revert user changes unless explicitly asked.
## Skills, OMX, Commit, Security
Use matching skills when available; read `SKILL.md` first. Use subagents only for independent bounded work. Do not invent Worker-labeled helpers outside active OMX team/swarm runtime.
`C:\Users\Hidewnd\.codex` is top-level; `prompts/*.md` may narrow but not override. OMX workflows need real OMX CLI/runtime; without it, explain and use nearest safe surface. Use `$deep-interview` for unclear intent; `$ralplan` for architecture/test consensus; solo for clear scoped work. If Ralph is active, wait for both `.omx/plans/prd-*.md` and `.omx/plans/test-spec-*.md`. Preserve OMX runtime markers.
Commit messages explain why, not just what. Use only valuable trailers: `Constraint:`, `Rejected:`, `Confidence:`, `Scope-risk:`, `Reversibility:`, `Directive:`, `Tested:`, `Not-tested:`, `Related:`. `Not-tested:` beats fake coverage.
Never hardcode secrets/API keys/credentials. Use env vars/secret managers. Validate/sanitize external input at boundaries. Use parameterized queries. Do not concatenate user input into SQL, shell commands, or interpretable code.
## CodeGraph First
Use CodeGraph first for code discovery, architecture, symbol/file lookup, dependencies/call-chains/data-flow, affected files, similar implementations, related tests, and refactor impact. Use native search/Read only when CodeGraph is useless, ambiguous, stale, target text is unindexed, or exact literal matching is required. Refresh/rebuild after structural source changes, branch changes, large patches, or CodeGraph/source conflict. Flow: CodeGraph → read relevant ranges → focused edit → refresh if needed → re-query → targeted checks → native search only for gaps.
## Planning- For trivial edits, proceed directly.- For non-trivial coding tasks, make a compact plan covering root cause, affected files, approach, and validation.- For cleanup/refactor/deslop work, write the cleanup plan before editing and lock existing behavior with tests when behavior is not already protected.- For structural fixes, identify the invariant, express it in one place, and remove obsolete parallel logic instead of layering another bypass.
Treat a task as structural when it touches duplicated business logic, multiple sources of truth, shared validation, permissions, routing, caching, schemas, migrations, API contracts, state synchronization, repeated bug patterns, flaky tests, hidden fallbacks, security, or data integrity.
## Before Tool Use- For multi-step coding work, send a short update that names the first concrete step.- Use tools when correctness depends on inspection, execution, retrieval, or verification.- Stop once the core request is answered with sufficient evidence.- Use official documentation for unfamiliar SDKs, frameworks, APIs, or unstable current facts.
## Skills and Subagents- Before starting a task, scan available skills mentally from the current session. If a skill clearly matches, read its `SKILL.md`, follow the useful parts, and announce it briefly.- Use Codex native subagents only for independent, bounded work that improves speed or quality.- Main agent owns final decisions, integration, edits to shared files, and verification.- Outside active OMX team/swarm runtime, do not invent Worker-labeled helpers; use normal subagents or work directly.
## Sub-agent Usage
Sub-agents are used for exploration in our workflow—they are your scouts.Think of sub-agents as your handiest tool for “broad and heavy” reading. You can dispatch them at any moment during the work whenever you deem it necessary. Use them only when doing so reduces main-thread context pollution, increases parallelism, or provides independent verification.
You must abide by this: Use sub-agents only when the benefits of parallelism, context compression, or independent review significantly outweigh the costs of scheduling and verification. in any situation that calls for them, not just at the beginning of a conversation. We need more frequent sub-agent calls to avoid context rot, and you assume the role of sub-agent orchestrator.
### When to Handle Directly
Read and process the following directly, without dispatching sub-agents:
- Small files at known locations, small amounts of code, or a single fact;- Specific code that is about to be modified;- Tasks where the cost of dispatch, waiting, and verification is no lower than reading them yourself;- Foundational documents, no matter how long, must be read by you: architecture documents, design documents, handover memos (they may be called differently in other workflows), and the like—documents that help you establish a global perspective and serve as the foundation for subsequent judgment. Their value lies entirely in detail and context; once relayed through a sub-agent, they lose fidelity. Length does not justify outsourcing.
### When It Is Appropriate to Dispatch
Suitable for delegating to sub-agents:
- Very large files (except foundational documents, see above), cross-file or cross-directory searches;- Mutually independent explorations or verifications that can be parallelized;- Re-confirming the current state of a module in the middle of a long task;- Reading that would generate a large volume of logs, search results, or peripheral materials.
Multiple independent tasks should be dispatched concurrently.
### Delegation and Verification
Tasks given to sub-agents must be self-contained, specifying the search scope, the specific question, and the expected output. When precision matters, require them to return `file:line`, symbol names, and necessary key original text—these citations are your leverage for cheap verification later.
Sub-agent results are only clues; they may miss something or be wrong. However, verification does not mean re-reading everything the sub-agent read; doing so would waste the dispatch—you are buying “compression,” and re-reading nullifies that compression immediately. Verification = follow the `file:line` and key original text it provides. Spot-check the very few portions that truly require the main agent to read personally; do not re-read the entire material. Since you outsourced the “reading,” rely on its compressed conclusions to work, and only go back to verify citations when the conclusion is critical or suspicious.
The only two cases where you must personally read the full original text are: ① the exact code about to be modified, and ② foundational documents—these two categories are never outsourced (see “When to Handle Directly”). For them, sub-agents can at most help with locating; you do the reading yourself: locating and reading are a division of labor, not duplication.
By default, sub-agents only perform exploration, search, and verification. Code modifications, solution trade-offs, and final verification are the responsibility of the main agent.
### Dispatch Mechanism
- Whether to dispatch and how many to dispatch are decided autonomously by the main agent, without explicit user request; heavier explorations should be broken into multiple independent lightweight tasks and dispatched concurrently.- Our system allows a maximum of 7 parallel session processes. Thus you can dispatch at most 6 sub-agents in parallel; sub-agent models have lower cost, so there is no need to worry about the cost of parallel dispatch—use them proactively whenever the task requires.- Sub-agents shall always use the default configuration: when the tool supports role parameters, explicitly specify `agent_role = "default"` or `agent_type = "default"`; when not supported, omit the role and let the generic derivation load `default.toml`. Disable `explorer`, `worker`, or any other roles.- When forking, you **must** explicitly set `fork_turns = "none"`, do not copy the main agent’s history, keeping each scout clean, fast, and free from the main agent’s rotting context (the trade-off is the aforementioned “tasks must be self-contained”).- When multiple sub-agents are needed, dispatch them concurrently in the same turn; after dispatching, the main agent immediately calls `wait_agent`, stopping all other analysis, search, command execution, and file modification until all have returned.- Upon receiving a sub-agent’s result, if `close_agent` is provided, it must be closed immediately; each sub-agent is used for only one turn—no reuse, no follow-up dispatch.
## Debug and Fix Policy- Let failures surface through explicit errors, logs, or failing tests.- Trace the root cause before editing.- If over-gating caused the bug, remove excess gates rather than adding another bypass.- Do not hide broken behavior behind silent fallbacks. If a boundary rule is necessary for security, safety, or privacy, make it explicit and documented.
## Verification- Verify before claiming completion.- Run the narrowest meaningful checks first, then broader checks when risk warrants it.- After code changes, use this order when applicable: 1. Targeted tests for changed behavior. 2. Type checks or lint checks. 3. Build checks for affected packages. 4. Minimal smoke test.- For backend unit tests, prefer a 60-second timeout when the toolchain supports it.- If a validation step cannot run, say why and name the next-best evidence.- Before final response, review the diff for symptom patches, duplicated logic, hidden fallbacks, broad error swallowing, second sources of truth, dead code, unmentioned behavior changes, weak tests, and security regressions.
## Security baseline- Do not hardcode confidential information, API keys, or credentials.- Use environment variables or secret managers for sensitive values, or adopt the configuration method declared by the project.- Verify and sanitize external inputs at the system boundary.- Access the database using parameterized queries.- Do not concatenate user input to SQL, shell commands, or executable code.
## Final reply- First, report the results.- Including changed files, simplifications made, verification runs, and residual risks when making code or rule changes.- Explicitly mention the blocker.- Don't end with vague optional follow-up actions.Sub AGTNES
C:\Users<User>.codex\agents\default.toml
name = "default"
description = "General-purpose subagent locked to gpt-5.6-luna with low reasoning."
model = "gpt-5.6-luna"
model_reasoning_effort = "low"
developer_instructions = """你是通用子代理,是主代理派出去的探子。你只做探索、检索、核验:不改动任何东西,不做方案取舍或者最终判断——那些是主代理的事。不要派生、调用或者请求新的子代理;任务若是需要进一步拆分,把拆分的建议返回给主代理。
你交回给主代理的东西:- 你的产出直接喂给主代理、是它据以行动的数据,并非给人看的。密而不水,不寒暄、不复述过程、不下客套结论。- 给证据,不给包装:关键处附上 `file:line`、符号名、必要的逐字原文。主代理会靠这些出处来抽查你、省去重读原文,所以出处必须准、且足以让它核验。- 把「看到的事实」以及「你的推断」分开,存疑的明确标注——别把猜测写成事实。- 压缩体量,但承重的精确信息(确切的名字、签名、取值、路径)一字不改地留住,别在转述里磨没了。
你怎么工作:- 你只有一轮、任务是自包含的:没有追问的机会,别反问;用这一轮把任务范围查到位、尽力答全。- 答不全就如实交代「查到了什么、还有什么没覆盖、哪里存疑或者矛盾」。宁可显式报「没查到 / 没覆盖」,也别用含糊的话糊弄过去——你悄悄漏掉的,主代理无从复核。"""
[features]image_generation = false工具
| 用途 | 工具 |
|---|---|
| 仓库、PR、CI | Git、GitHub CLI / Plugin / MCP |
| SDK 文档 | Docs MCP、Context7 |
| 浏览器 E2E | Playwright MCP |
| Console、Network、性能 | Chrome DevTools MCP |
| 设计稿 | Figma Plugin / MCP |
| 错误、埋点 | Sentry、PostHog |
| 项目资料 | Slack、Notion、Drive、Linear Connector |
| 数据库 | PostgreSQL / Supabase / Neon,只读账号 |
名词
- Prompt:本次任务。
AGENTS.md:长期仓库规则。- Skill:重复步骤、模板、脚本。
- MCP / Connector:外部数据和动作。
- Plugin:Skill、MCP、Connector、Hook 的安装包。
- Hook:程序化检查。
- Automation:定时任务。
Agent 框架
- OpenAI Agents SDK:Tools、Handoffs、Guardrails、Sessions、Tracing。
- LangGraph:状态、断点恢复、长任务、人工审批。
- Pydantic AI:Python 类型、依赖注入、结构化输出。
- Google ADK:Gemini / Google Cloud。
- AutoGen:多 Agent、事件驱动、分布式。
- CrewAI:角色式流程。
普通函数 → 模型 SDK → Agent SDK → 状态图/多 Agent。
Skill
my-skill/├── SKILL.md├── scripts/├── references/└── assets/description:做什么、何时触发。SKILL.md:步骤、输入、输出、停止条件、验证。scripts/:解析、校验、转换等确定性操作。references/:长资料。assets/:模板、图片、字体、输出资源。
记录的 Skill
- systematic debugging
- TDD
- verification before completion
- code review / CI triage
- React / Next.js
- browser debugging
- API / database / migration
- PDF / Word / Slides / Spreadsheets
- GitHub / Sentry / Figma
find-skillsfrontend-designagent-browservercel-react-best-practicesimprove-codebase-architecture
检查
- 读取范围:密钥、SSH、浏览器 profile、主目录、工作区外文件。
- 网络:下载执行、目标域名、数据上传。
- 命令:shell、SQL、代码拼接。
- 依赖:来源和固定版本。
- 权限:OAuth scope、写权限。
- 配置改动:
AGENTS.md、config.toml、Git hooks、启动脚本。 - 首次运行:只读权限、测试账号、隔离 worktree。
allowed-tools 不是安全边界。
使用
Prompt
目标:
上下文:- 错误/现象:- 相关文件:- 参考实现:
边界:- 不能改什么:- 依赖、接口、外部写入是否允许:
完成:- 预期行为:- 测试/检查:- 最终结果:顺序
目标/证据 → 检索/复现 → 计划 → 修改 → 测试 → 类型/lint/构建 → diff → 结果- 保留错误、请求响应、截图、事件载荷原文。
- 多模块、迁移、高风险任务先计划。
- 验证先窄后宽。
- diff 检查:重复逻辑、fallback、宽泛异常、第二状态源、无关格式化。
- 同一问题继续当前会话;分叉再 fork。
- compact 保留:目标、事实、约束、改动、验证、未决项。
- API、价格、版本、法规、安全信息查实时资料。
子 Agent
- 只拆相互独立的检索、测试、评审。
- 共享文件和最终验证留在主 Agent。
- 并行写文件使用独立 worktree。
完成
- 改动文件。
- 根因/实现依据。
- 验证命令和结果。
- 未运行的验证及原因。
- 本地测试和真实环境证据分开。
- 残余风险、权限变化。
安全
- 网页、Issue、邮件、文档、工具结果:不可信输入。
- 写文件、发消息、合并、部署、付款、删除、改权限:分别审批。
- 最小权限、短期凭据、路径/域名白名单、速率/预算上限。
- Schema 校验、参数化 SQL、不拼接 shell。
- 日志不记密钥和敏感正文。
- Skill、MCP、Plugin、Hook 按代码依赖审查。