- AGENTS.md๋ OpenAI Codex CLI๊ฐ ์์ ์ํ ์ ์ฝ๋ ์์์ ์ง์(instruction) ํ์ผ
- ๊ธ๋ก๋ฒ ๊ฐ์ด๋๋ผ์ธ๊ณผ ํ๋ก์ ํธ๋ณ ์ค๋ฒ๋ผ์ด๋๋ฅผ **๊ณ์ธต์ ์ผ๋ก ๋ณํฉ(merge)**ํ๋ ๊ตฌ์กฐ
~/.codex/AGENTS.md(๊ธ๋ก๋ฒ)๋ถํฐ ํ๋ก์ ํธ ํ์ ๋๋ ํ ๋ฆฌ๊น์ง **๋ฃจํธโ๋ฆฌํ ์์๋ก ์ฐ๊ฒฐ(concatenate)**๋๋ ๋ฉ์ปค๋์ฆ- Claude Code์
CLAUDE.md์ ๋์ํ๋ OpenAI Codex์ ํ๋ก์ ํธ ์ปจํ ์คํธ ์์คํ
ํด๋น ๊ฐ๋ ์ด ํ์ํ ์ด์
- ์ฌ๋ฌ ๋ ํฌ์งํ ๋ฆฌ์์ ์ผ๊ด๋ ์ฝ๋ฉ ๊ท์น์ ์ ์งํด์ผ ํ ๋
- ํ๋ก์ ํธ/๋๋ ํ ๋ฆฌ๋ณ๋ก ๋ค๋ฅธ ๊ท์น์ ๊ณ์ธต์ ์ผ๋ก ์ ์ฉํด์ผ ํ ๋
- Codex SDK๋ฅผ ์๋น์ค์ ํตํฉํ ๋ instruction ์ฃผ์ ๋ฐฉ์์ ์ดํดํด์ผ ํ ๋
AS-IS
sequenceDiagram autonumber participant Dev as ๊ฐ๋ฐ์ participant Codex as Codex CLI Dev->>Codex: ์์ ์์ฒญ Note over Codex: ์ง์์ฌํญ ์์ Codex->>Codex: ๊ธฐ๋ณธ ๋์๋ง ์ํ Codex-->>Dev: ์ผ๊ด์ฑ ์๋ ๊ฒฐ๊ณผ
TO-BE
sequenceDiagram autonumber participant Dev as ๊ฐ๋ฐ์ participant Codex as Codex CLI participant Global as ~/.codex/AGENTS.md participant Project as {cwd}/AGENTS.md participant Sub as {cwd}/sub/AGENTS.md Dev->>Codex: ์์ ์์ฒญ Codex->>Global: 1) ๊ธ๋ก๋ฒ ์ง์ ๋ก๋ Codex->>Project: 2) ํ๋ก์ ํธ ์ง์ ๋ก๋ Codex->>Sub: 3) ํ์ ๋๋ ํ ๋ฆฌ ์ง์ ๋ก๋ Note over Codex: 1+2+3 ์ฐ๊ฒฐ(concatenate) Codex-->>Dev: ์ผ๊ด๋ ๊ท์น ๊ธฐ๋ฐ ๊ฒฐ๊ณผ
ํ์ผ ํ์(Discovery) ์์
๋๋ ํ ๋ฆฌ๋ณ ํ์ ์ฐ์ ์์
๊ฐ ๋๋ ํ ๋ฆฌ์์ ์ต๋ 1๊ฐ ํ์ผ๋ง ์ ํ๋๋ค:
| ์ฐ์ ์์ | ํ์ผ๋ช | ์ค๋ช |
|---|---|---|
| 1 | AGENTS.override.md | ์์ ์ค๋ฒ๋ผ์ด๋์ฉ |
| 2 | AGENTS.md | ๊ธฐ๋ณธ ์ง์ ํ์ผ |
| 3 | project_doc_fallback_filenames์ ๋ฑ๋ก๋ ํ์ผ | ์ปค์คํ ๋์ฒด ํ์ผ |
์ ์ฒด ๋ณํฉ ์์
flowchart LR A("1 ๊ธ๋ก๋ฒ: ~/.codex/AGENTS.md") -->|concat| B("2 ํ๋ก์ ํธ: root/AGENTS.md") -->|concat| C("3 ํ์: subdir/AGENTS.md")
โCodex concatenates files from the root down, joining them with blank lines. Files closer to your current directory override earlier guidance because they appear later in the combined prompt.โ
ํต์ฌ: ๋์ค์ ๋ฑ์ฅํ๋ ํ์ผ์ด ๋ ๋์ ์ฐ์ ๋๋ฅผ ๊ฐ์ง๋ค. ์ด๋ LLM์ ํ๋กฌํํธ ํน์ฑ์ ๋์ค์ ๋์ค๋ ์ง์๊ฐ ์์ ์ง์๋ฅผ ๋ฎ์ด์ฐ๊ธฐ ๋๋ฌธ์ด๋ค.
๋ณํฉ(Merge) ๋ฉ์ปค๋์ฆ ์์ธ
๋์ ๋ฐฉ์
.git์ด ์๋ ๋๋ ํ ๋ฆฌ๋ฅผ ํ๋ก์ ํธ ๋ฃจํธ๋ก ์ธ์- ๊ธ๋ก๋ฒ(
~/.codex/) โ ํ๋ก์ ํธ ๋ฃจํธ โ ํ์ฌ ๋๋ ํ ๋ฆฌ๊น์ง ํธ๋ฆฌ๋ฅผ ๋ด๋ ค๊ฐ๋ฉฐ ์์ง - ์์ง๋ ํ์ผ์ ๋น ์ค๋ก ๊ตฌ๋ถํ์ฌ ์ฐ๊ฒฐ(concatenate)
- ํฉ์ฐ ํฌ๊ธฐ๊ฐ
project_doc_max_bytes(๊ธฐ๋ณธ 32 KiB)์ ๋๋ฌํ๋ฉด ์ค๋จ
๊ธ๋ก๋ฒ AGENTS.md ๋ก๋ ์๋ฆฌ
๊ธ๋ก๋ฒ ~/.codex/AGENTS.md๋ ํ๊ฒฝ๋ณ์๋ CWD์ ๋ฌด๊ดํ๊ฒ, Codex์ ๋นํธ์ธ config_loader๊ฐ ์๋ ๋ก๋ํ๋ค.
// codex-rs/core/src/config_loader โ Codex ๋ด๋ถ ์ด๊ธฐํ
let layers = load_config_layers_state(
&codex_home, // โ ~/.codex/ (ํญ์ ๊ณ ์ , ํ๊ฒฝ๋ณ์์ ๋ฌด๊ด)
Some(cwd), // โ thread/start์์ ์ ๋ฌํ cwd
&cli_overrides,
LoaderOverrides::default(),
None,
).await?;codex_home์ ํญ์~/.codex/๋ก ๊ณ ์ โ ์คํฐ ์ ์ค์ ํ ์ปค์คํ ํ๊ฒฝ๋ณ์์ ๋ณ๊ฐ ๋ฉ์ปค๋์ฆ- CWD๊ฐ git repo๊ฐ ์๋์ด๋ ๊ธ๋ก๋ฒ AGENTS.md๋ ๋ก๋๋จ (
~/.codex/์์ฒด๊ฐ git repo๊ฐ ์๋ ๊ฒ์ด ๊ทธ ์ฆ๊ฑฐ) model_instructions_file์ค์ ๊ณผ ๋ฌด๊ดํ๊ฒ ๊ธ๋ก๋ฒ/ํ๋ก์ ํธ AGENTS.md๋ ํญ์ ๋ก๋๋จ (์๋ ์์ค ์ฝ๋ ๊ธฐ๋ฐ ๋ถ์ ์ฐธ์กฐ)
์์: 3๊ฐ ๋ ๋ฒจ ๋ณํฉ
# ์ค์ Codex๊ฐ ๋ฐ๋ combined prompt:
[~/.codex/AGENTS.md ๋ด์ฉ] โ ๊ธ๋ก๋ฒ ๊ท์น
[{root}/AGENTS.md ๋ด์ฉ] โ ํ๋ก์ ํธ ๊ท์น (๊ธ๋ก๋ฒ ๊ท์น ๋ฎ์ด์ฐ๊ธฐ ๊ฐ๋ฅ)
[{root}/services/AGENTS.md ๋ด์ฉ] โ ์๋น์ค ๊ท์น (ํ๋ก์ ํธ ๊ท์น ๋ฎ์ด์ฐ๊ธฐ ๊ฐ๋ฅ)
AGENTS.override.md
- ์ด๋ ๋๋ ํ ๋ฆฌ์๋
AGENTS.override.md๋ฅผ ๋๋ฉด ๊ฐ์ ๋๋ ํ ๋ฆฌ์AGENTS.md๋ณด๋ค ์ฐ์ ์ ์ฉ - ์ฉ๋: ์์ ์ค๋ฒ๋ผ์ด๋ โ ๊ธฐ์กด AGENTS.md๋ฅผ ์ญ์ ํ์ง ์๊ณ ๊ท์น์ ๋ฐ๊ฟ ๋
- ์ค๋ฒ๋ผ์ด๋ ํ์ผ์ ์ญ์ ํ๋ฉด ์๋ AGENTS.md๋ก ์๋ ๋ณต์
# services/payments/AGENTS.override.md
## Payments service rules
- Use `make test-payments` instead of `npm test`.
- Never rotate API keys without notifying the security channel.Codex ๋ด๋ถ Instruction ๊ตฌ์กฐ (์์ค ์ฝ๋ ๊ธฐ๋ฐ)
Codex ์์ค ์ฝ๋(codex-rs) ๋ถ์ ๊ฒฐ๊ณผ, ๋ด๋ถ์๋ 3๊ฐ์ ๋ ๋ฆฝ์ ์ธ instruction ๊ฒฝ๋ก๊ฐ ์กด์ฌํ๋ค.
๋ด๋ถ Instruction ์ ์ฒด ๋งต
| ๋ด๋ถ ๊ฐ | ์๋ฏธ | ๊ธฐ๋ณธ๊ฐ (default) | model_instructions_file ์ํฅ | ๋ก๋ ์ถ์ฒ | ์ ์ฉ ๋ฐฉ๋ฒ (์ฝ๋) | API role | ์์ค ์ฝ๋ ๊ทผ๊ฑฐ |
|---|---|---|---|---|---|---|---|
base_instructions | ๋ชจ๋ธ์ ํต์ฌ ํ๋ ๊ท์น โ โ๋๋ Codex๋ผ๋ AI์ผโ. AGENTS.md ์คํ, ๋๊ตฌ ์ฌ์ฉ๋ฒ, ์๋๋ฐ์ค ๊ท์น ๋ฑ ๋ชจ๋ธ์ ์ต์์ ์ง์ | OpenAI ์๋ฒ์์ ๋ชจ๋ธ๋ณ ๋นํธ์ธ ํ๋กฌํํธ (instructions_template) | ์ด ๊ฐ๋ง ๋์ฒด๋จ โ ํ์ผ ๋ด์ฉ์ด ๋นํธ์ธ ๋์ ์ฌ์ฉ | model_info.get_model_instructions() | ํ์ผ: config.toml์ model_instructions_file = "๊ฒฝ๋ก", ์ฝ๋: config์ model_instructions_file ํค ์ถ๊ฐ | instructions (system) | config/mod.rs:2433-2442, codex.rs:553-562, openai_models.rs:316 |
developer_instructions | ์๋น์ค ์ด์์์ ๋น๊ณต๊ฐ ์ง์ โ API ํธ์ถ ์๋น์ค๊ฐ ์ค์ . ์ฌ์ฉ์์๊ฒ ๋
ธ์ถ ์ ๋จ, override ๋ถ๊ฐ. ๋ฐํ์์ sandbox policyยทskillsยทplugins ๋ฑ์ด developer_sections๋ก ํจ๊ป ํฉ์ฐ | None. sandbox policyยทskillsยทplugins ๋ฑ์ Codex๊ฐ ์๋ ์ถ๊ฐ | ์ํฅ ์์ | config.toml์ developer_instructions ํ๋ (string, ํ์ผ๊ฒฝ๋ก ์๋) | ์ฝ๋๋ก ์ค์ : config์ developer_instructions: "๋ด์ฉ" ํค ์ถ๊ฐ โ --config developer_instructions="..." ์ ๋ฌ | developer role msg | config/mod.rs:1179-1181, config/mod.rs:2443, codex.rs:3494-3497, updates.rs:161-162 |
user_instructions | ์ต์ข ์ฌ์ฉ์์ ์ปค์คํ ์ง์ โ ์ฌ์ฉ์๊ฐ AGENTS.md์ ์ง์ ์์ฑ. ํ๋ก์ ํธ ๊ท์น, ์ฝ๋ฉ ์ปจ๋ฒค์ , ์ ํธ ๊ธฐ์ ์คํ. ์ฌ์ฉ์๊ฐ ์ง์ ์ ์ด ๊ฐ๋ฅ | ~/.codex/AGENTS.md(๊ธ๋ก๋ฒ) + {cwd}/AGENTS.md(ํ๋ก์ ํธ) ์๋ ๋ณํฉ, --- project-doc --- ๊ตฌ๋ถ์๋ก ์ฐ๊ฒฐ | ์ํฅ ์์ | โ load_instructions(codex_home) โ ๊ธ๋ก๋ฒ โก read_project_docs() โ ํ๋ก์ ํธ | ํ์ผ ๋ฐฐ์น๋ง์ผ๋ก ์๋: ~/.codex/AGENTS.md ๋๋ {cwd}/AGENTS.md ์์ฑ | user role msg | config/mod.rs:2033, config/mod.rs:2769-2782, project_doc.rs:79-119, project_doc.rs:128-178, updates.rs:165-166 |
์ต์ข ํ๋กฌํํธ ๊ตฌ์กฐ (API ํธ์ถ ๊ธฐ์ค)
โโ instructions (system) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ base_instructions โ
โ โ model_instructions_file ์ค์ ์ ๋์ฒด โ
โ โ ๋ฏธ์ค์ ์: ์๋ฒ ๋นํธ์ธ ํ๋กฌํํธ (๋ชจ๋ธ๋ณ) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโ developer role message โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ sandbox policy + approval policy โ
โ developer_instructions (config ์ค์ ๊ฐ) โ
โ memory tool instructions โ
โ personality, skills, plugins ... โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโ user role message (contextual) โโโโโโโโโโโโโโโโโโโโโโโโโโ
โ user_instructions: โ
โ โโ ~/.codex/AGENTS.md (๊ธ๋ก๋ฒ) โ
โ โโ --- project-doc --- โ
โ โโ {cwd}/AGENTS.md (ํ๋ก์ ํธ ๋ณํฉ) โ
โ environment context (cwd, os, shell ...) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
model_instructions_file์ ์ ํํ ์ญํ (๊ณต์๋ฌธ์ vs ์์ค์ฝ๋)
๊ณต์ ๋ฌธ์ ์ ์:
โReplacement for built-in instructions instead of AGENTS.md.โ โ Configuration Reference,
model_instructions_fileํญ๋ชฉ
์ด ๋ฌธ์ฅ์ ์ฌ๋ฐ๋ฅธ ํด์ (์์ค ์ฝ๋ ๊ธฐ๋ฐ):
โAGENTS.md๋ฅผ ๋์ฒดํ๋คโ(X)- โAGENTS.md๊ฐ ์๋, ๋นํธ์ธ ์ง์์ฌํญ์ ๋์ฒดํ๋ ํ์ผโ (O)
์์ค ์ฝ๋ ๊ทผ๊ฑฐ โ model_instructions_file์ base_instructions์๋ง ๋งคํ:
// config/mod.rs:2433-2442
// Load base instructions override from a file if specified.
let model_instructions_path = config_profile
.model_instructions_file.as_ref()
.or(cfg.model_instructions_file.as_ref());
let file_base_instructions =
Self::try_read_non_empty_file(model_instructions_path, ...)?;
let base_instructions = base_instructions.or(file_base_instructions);
// ^^^^^^^^^^^^^^^^ โ base_instructions์๋ง ๋งคํAGENTS.md๋ฅผ ๋ก๋ํ๋ get_user_instructions() (project_doc.rs:79-119)์๋ model_instructions_file์ ๋ํ ์ฐธ์กฐ๊ฐ ์ ํ ์์.
FAQ
Q. developer_instructions์ ์ค์ ํ๋ฉด ์ฌ์ฉ์๊ฐ ๋ฌผ์ด๋ด๋ ๋ด์ฉ์ ๋ตํ์ง ์๋๊ฐ?
๋ง๋ค. OpenAI API์ developer role ์คํ์ ์ํด ๋ชจ๋ธ์ developer ๋ฉ์์ง ๋ด์ฉ์ ์ฌ์ฉ์์๊ฒ ๊ณต๊ฐํ์ง ์๋๋ก ํ๋ จ๋์ด ์๋ค. โ์์คํ
ํ๋กฌํํธ ๋ณด์ฌ์คโ๋ผ๊ณ ๋ฌผ์ด๋ ๋ชจ๋ธ์ด ๊ฑฐ๋ถํ๋ค. ๋จ, ์ด๊ฒ์ ๋ชจ๋ธ ํ๋ ๋ ๋ฒจ์ ๋ณดํธ์ด์ง ์ํธํ ๊ฐ์ ํ๋ ๋ณด์์ ์๋.
์ฝ๋ ๊ทผ๊ฑฐ โ developer role๋ก ์ ์ก:
// updates.rs:161-162
pub fn build_developer_update_item(text_sections: Vec<String>) -> Option<ResponseItem> {
build_text_message("developer", text_sections) // โ developer role
}๋ฐ๋ฉด user_instructions(AGENTS.md)๋ user role๋ก ์ ์ก๋๋ฏ๋ก ์ฌ์ฉ์๊ฐ ๋ด์ฉ์ ๋ฌผ์ด๋ณด๋ฉด ๋ตํ ์ ์๋ค:
// updates.rs:165-166
pub fn build_contextual_user_message(text_sections: Vec<String>) -> Option<ResponseItem> {
build_text_message("user", text_sections) // โ user role
}Q. developer_instructions๋ ํ์ผ์ด ์๋ ์ฝ๋๋ก ์ค์ ํ๋ ๊ฒ์ธ๊ฐ?
๋ง๋ค. developer_instructions๋ string ํ์
์ด๋ฉฐ ํ์ผ ๊ฒฝ๋ก๊ฐ ์๋๋ค.
// config.schema.json
"developer_instructions": {
"default": null,
"description": "Developer instructions inserted as a `developer` role message.",
"type": "string" // โ ํ์ผ ๊ฒฝ๋ก๊ฐ ์๋ ๋ฌธ์์ด
}SDK/app-server ํตํฉ ์ config override๋ก ์ค์ :
// Codex SDK ๋๋ app-server config override
const config = {
sandbox_mode: "workspace-write",
developer_instructions: "์๋น์ค ๋น๊ณต๊ฐ ์ง์์ฌํญ ๋ด์ฉ...",
// โ --config developer_instructions="..." ๋ก ์ ๋ฌ๋จ
};Q. developer_instructions vs user_instructions์ ์ฐจ์ด๋?
OpenAI API์ message role ์คํ ๊ธฐ๋ฐ:
์ฐ์ ์์: system(base) > developer > user
developer = "์๋น์ค๋ฅผ ๋ง๋ ๊ฐ๋ฐ์"์ ์ง์
โ ์ฌ์ฉ์๊ฐ ๋ณผ ์ ์๊ณ , override ๋ถ๊ฐ
โ e.g. ์๋น์ค๊ฐ "ํญ์ ํ๊ตญ์ด๋ก ๋ต๋ณ" ์ค์
user = "์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ์ต์ข
์ฌ์ฉ์"์ ์ง์
โ ์ฌ์ฉ์๊ฐ AGENTS.md๋ก ์ง์ ์ ์ด
โ e.g. ์ฌ์ฉ์๊ฐ "TypeScript ์ ํธ, ์ปค๋ฐ ํ๊ธ" ์ค์
์๋น์ค์ ์ง์์ฌํญ์ developer_instructions์, ์ฌ์ฉ์ ์ปค์คํ
์ AGENTS.md(user_instructions)์ ๋ฃ๋ ๊ฒ์ด ์๋ฏธ์ ์ผ๋ก ์ ํํ๋ค.
config.toml ์ฃผ์ ์ค์
# AGENTS.md ๊ด๋ จ ์ค์
project_doc_max_bytes = 32768 # ๊ธฐ๋ณธ 32 KiB
project_doc_fallback_filenames = ["TEAM_GUIDE.md", ".agents.md"] # ๋์ฒด ํ์ผ๋ช
model_instructions_file = "/path/to/instructions.md" # AGENTS.md ์ ๋ฉด ๋์ฒด
# ๊ธฐํ ์ฃผ์ ์ค์
model = "gpt-5-codex"
sandbox_mode = "workspace-write" # read-only | workspace-write | danger-full-access
approval_policy = "on-request" # untrusted | on-request | neverClaude Code์ CLAUDE.md์ ๋น๊ต
| ํญ๋ชฉ | Codex AGENTS.md | Claude Code CLAUDE.md |
|---|---|---|
| ๊ธ๋ก๋ฒ ๊ฒฝ๋ก | ~/.codex/AGENTS.md | ~/.claude/CLAUDE.md |
| ํ๋ก์ ํธ ๊ฒฝ๋ก | {cwd}/AGENTS.md | {cwd}/CLAUDE.md |
| ๋ณํฉ ๋ฐฉ์ | ๋ฃจํธโ๋ฆฌํ concatenate | ๋ฃจํธโ๋ฆฌํ concatenate |
| ์ค๋ฒ๋ผ์ด๋ ํ์ผ | AGENTS.override.md | ์์ (๋จ์ผ ํ์ผ) |
| ๋์ฒด ์ค์ | model_instructions_file | ์์ |
| ํฌ๊ธฐ ์ ํ | project_doc_max_bytes (32 KiB) | ์๋ ๊ด๋ฆฌ |
| fallback ํ์ผ | project_doc_fallback_filenames | ์์ |