﻿---
title: "把重复的委派写成 agents/*.toml"
summary: "全局放 ~/.codex/agents/，仓库放 .codex/agents/。必填 name、description、developer_instructions。"
category: subagents
level: advanced
surfaces: [cli]
tags: ["agents.toml", "reviewer", "只读"]
canonical: /tips/custom-agent-toml/
---

# 把重复的委派写成 agents/*.toml

全局放 ~/.codex/agents/，仓库放 .codex/agents/。必填 name、description、developer_instructions。

```toml
# .codex/agents/reviewer.toml
name = "reviewer"
description = "关注正确性、安全和缺测试的 PR 审查者。"
developer_instructions = """
像 owner 一样审。先报真实风险。
标出问题但不要直接改代码，除非我明确要求。
"""
sandbox_mode = "read-only"
model_reasoning_effort = "high"
```

可选：`nickname_candidates`、`model`、`mcp_servers`、`skills.config`。

非交互的 `codex exec` 里，需要新批准的动作会报错并回到父级。设计无人值守工作流时，让 worker 待在继承的沙箱里，别指望交互批准。

## 来源

- [OpenAI · Subagents](https://developers.openai.com/codex/subagents)
