Skip to content
←INDEX / 提示詞庫
TUTORIAL/OpenAI Codex/入門

Codex AGENTS.md 產生器:把專案規則寫成 Codex 看得懂的指引檔

讓 Codex 訪談你的專案,再產出一份結構化、不囉嗦的 AGENTS.md,把建置/測試指令、程式風格、commit 規範、禁區一次寫清楚,每次開工自動載入。

SakuyaPromptCraft 主筆 · 寫於 2026-06-08
AI 教學 / 腳本OpenAI Codex入門預期輸出說明≈ 771 tokens · 實際用量依工具與輸入而異
Last reviewed2026-06-08Read~13 MIN

01PROMPT

You are helping me author an `AGENTS.md` file for this repository so that Codex loads consistent project guidance at the start of every session.

Context you already know about how AGENTS.md works (do NOT lecture me on this, just apply it):
- Codex reads AGENTS.md from the git root down to the current directory, concatenated, closest file wins. Keep the root file focused and lean.
- Content should be operational instructions for an agent, not marketing prose. Think "what would I tell a competent new contributor on day one".

Project: {{PROJECT_NAME}}
Primary stack / language: {{STACK}}
What the project does (1-2 lines): {{PROJECT_PURPOSE}}

STEP 1 — Investigate the repo yourself before writing anything. Read package manifests, lockfiles, CI config, existing README, scripts, and any existing AGENTS.md / CLAUDE.md. From the actual files, determine:
- the real install / build / test / lint / typecheck commands (quote them exactly — do not guess)
- the package manager and runtime version in use
- the directory layout and where the important code lives
- existing conventions (formatter, lint rules, commit style, branch naming)

STEP 2 — Ask me at most {{MAX_QUESTIONS}} sharp clarifying questions ONLY about things you genuinely could not determine from the repo (e.g. which test command is the canonical one, what must never be touched, deployment gotchas). Skip anything you already found. If you found everything, say so and skip straight to STEP 3.

STEP 3 — Write `AGENTS.md` at the repo root with these sections, in this order. Omit any section that does not apply rather than padding it:
1. **Project overview** — 2-3 sentences max: what it is, the stack.
2. **Setup & commands** — exact commands to install, run, build, test, lint, typecheck. Use a table or code blocks. These must be copy-pasteable and correct.
3. **Project layout** — a short map of the key directories and what lives where.
4. **Conventions** — code style, naming, formatting/lint rules to follow, language/framework idioms specific to this repo.
5. **Commit & PR rules** — the commit message format ({{COMMIT_STYLE}}), branch naming, and anything required before opening a PR (e.g. tests green, changelog entry).
6. **Guardrails / do-not-touch** — files, dirs, secrets, generated code, or behaviors Codex must not modify without asking. Be specific.
7. **Verification checklist** — the exact steps Codex should run to self-verify a change before declaring it done.

Writing rules:
- Be terse and imperative. Bullet points over paragraphs. No "you are an expert" filler.
- Only state things you actually confirmed from the repo or from my answers. If something is genuinely unknown, leave a clearly-marked `TODO(owner): ...` line instead of inventing a command — a wrong build command is worse than a flagged gap.
- Keep the root file lean; if a subdirectory has materially different rules, tell me to create a nested `AGENTS.md` there instead of bloating the root.

After writing the file, output a 5-line summary of what you put in it and list any `TODO(owner)` gaps I still need to fill in.

把方括號 [ ] 內的變數換成你的內容,丟進 OpenAI Codex。

◆ 直接開到工具ChatGPT(記得貼)
RUN站內試跑 / TRY IT
▶ 站內試跑

不用離開網站,直接看這組 prompt 跑出來長怎樣(AI 即時生成,扣 1 點)。

SKILL安裝成 SKILL / INSTALL
安裝成 SKILLCodex custom prompt

不只複製貼上 — 下載後放到 ~/.codex/prompts/agents-md-author.md,之後輸入 /agents-md-author 一鍵呼叫。

macOS / Linux
mkdir -p ~/.codex/prompts && mv ~/Downloads/agents-md-author.md ~/.codex/prompts/agents-md-author.md
Windows PowerShell
New-Item -ItemType Directory -Force "$env:USERPROFILE\.codex\prompts" | Out-Null; Move-Item "$env:USERPROFILE\Downloads\agents-md-author.md" "$env:USERPROFILE\.codex\prompts\agents-md-author.md"

02CONTEXT / 使用情境

何時用:剛把 Codex 接上一個既有 repo、或團隊想統一「Codex 開工該知道的事」時。為何有效:Codex 每次啟動會把從 git root 到當前目錄的 AGENTS.md 串起來當系統指引,這支強制它『先讀你的 repo 再下筆』,而不是憑空生一份漂亮但錯誤的設定檔——錯的 build 指令比沒有還糟。技巧:① 先讓它調查 package.json / CI / lockfile 抓出真實指令,再只問你它查不到的事,省掉來回;② 要求對不確定的指令留 TODO(owner) 而非編造,符合『誠實>花俏』;③ commit 格式寫進 AGENTS.md 是最有效的一招(它是 Codex 產出 commit 風格的主分類依據)。進階:子目錄規則不同時讓它建巢狀 AGENTS.md,保持 root 精簡(預設約 32 KiB 上限)。

03SAMPLE / 期待成果

# AGENTS.md ## Project overview luvai-stock-app — a Taiwan-equities analytics site (technical + institutional flow + AI). Next.js 15 (App Router) + TypeScript, deployed to Cloudflare Workers via OpenNext, data in D1. ## Setup & commands | Task | Command | |------|---------| | Install | `npm ci` | | Dev | `npm run dev` | | Build | `npm run build` | | Typecheck | `npx tsc --noEmit` | | Lint | `npm run lint` | | Deploy | `npm run deploy` | ## Commit & PR rules - Conventional Commits: `feat(scope): ...`, `fix(scope): ...`, `chore: ...`. - Before opening a PR: `npx tsc --noEmit` and `npm run lint` must pass. ## Guardrails / do-not-touch - Never edit `migrations/` files that are already applied to prod — add a new one. - Do not touch credit/entitlement logic in `lib/entitlements.ts` without asking. TODO(owner): confirm whether `npm test` or `npm run test:ci` is the canonical suite — both exist in package.json.

這是預期成果的文字說明。請查看本文實測說明,並以自己的輸入素材小規模試用。

04VARIABLES / 變數說明

01[PROJECT_NAME]

專案名稱,例如 luvai-stock-app

02[STACK]

主要技術棧/語言,例如 Next.js 15 + TypeScript on Cloudflare Workers

03[PROJECT_PURPOSE]

專案一兩句話用途,例如 台股技術+籌碼+AI 分析網站

04[MAX_QUESTIONS]

允許 Codex 反問的最多題數,建議 3-5,避免它一直問

05[COMMIT_STYLE]

你要的 commit 格式,例如 Conventional Commits(feat/fix/chore…)或團隊自訂格式

05RESOLVER · 變數代入器0 / 5

填下面的欄位,上方 prompt 會即時替換 [方括號] 內容。填好後按「複製組好的 prompt」直接丟進工具。

修飾
Assembled · 填剩餘變數…
You are helping me author an `AGENTS.md` file for this repository so that Codex loads consistent project guidance at the start of every session.

Context you already know about how AGENTS.md works (do NOT lecture me on this, just apply it):
- Codex reads AGENTS.md from the git root down to the current directory, concatenated, closest file wins. Keep the root file focused and lean.
- Content should be operational instructions for an agent, not marketing prose. Think "what would I tell a competent new contributor on day one".

Project: {{PROJECT_NAME}}
Primary stack / language: {{STACK}}
What the project does (1-2 lines): {{PROJECT_PURPOSE}}

STEP 1 — Investigate the repo yourself before writing anything. Read package manifests, lockfiles, CI config, existing README, scripts, and any existing AGENTS.md / CLAUDE.md. From the actual files, determine:
- the real install / build / test / lint / typecheck commands (quote them exactly — do not guess)
- the package manager and runtime version in use
- the directory layout and where the important code lives
- existing conventions (formatter, lint rules, commit style, branch naming)

STEP 2 — Ask me at most {{MAX_QUESTIONS}} sharp clarifying questions ONLY about things you genuinely could not determine from the repo (e.g. which test command is the canonical one, what must never be touched, deployment gotchas). Skip anything you already found. If you found everything, say so and skip straight to STEP 3.

STEP 3 — Write `AGENTS.md` at the repo root with these sections, in this order. Omit any section that does not apply rather than padding it:
1. **Project overview** — 2-3 sentences max: what it is, the stack.
2. **Setup & commands** — exact commands to install, run, build, test, lint, typecheck. Use a table or code blocks. These must be copy-pasteable and correct.
3. **Project layout** — a short map of the key directories and what lives where.
4. **Conventions** — code style, naming, formatting/lint rules to follow, language/framework idioms specific to this repo.
5. **Commit & PR rules** — the commit message format ({{COMMIT_STYLE}}), branch naming, and anything required before opening a PR (e.g. tests green, changelog entry).
6. **Guardrails / do-not-touch** — files, dirs, secrets, generated code, or behaviors Codex must not modify without asking. Be specific.
7. **Verification checklist** — the exact steps Codex should run to self-verify a change before declaring it done.

Writing rules:
- Be terse and imperative. Bullet points over paragraphs. No "you are an expert" filler.
- Only state things you actually confirmed from the repo or from my answers. If something is genuinely unknown, leave a clearly-marked `TODO(owner): ...` line instead of inventing a command — a wrong build command is worse than a flagged gap.
- Keep the root file lean; if a subdirectory has materially different rules, tell me to create a nested `AGENTS.md` there instead of bloating the root.

After writing the file, output a 5-line summary of what you put in it and list any `TODO(owner)` gaps I still need to fill in.
FAQ · 常見問題

「Codex AGENTS.md 產生器:把專案規則寫成 Codex 看得懂的指引檔」這組提示詞要怎麼用?

這組 prompt 專為 OpenAI Codex 設計。把 prompt 內 5 個方括號 [變數] 換成你自己的內容,貼進 OpenAI Codex 執行即可。難度為入門,新手可以直接套用。

「Codex AGENTS.md 產生器:把專案規則寫成 Codex 看得懂的指引檔」是免費的嗎?

完整 prompt 免費開放閱讀,不用註冊;可保存瀏覽器收藏,登入後可一鍵複製與留言。

用 OpenAI Codex 依這組 prompt 生成的成果可以商用嗎?

prompt 文字本身你可自由使用與修改。但 AI 生成物(圖/音樂/影片/文字)的商用授權,取決於你在 OpenAI Codex 使用的方案與其官方服務條款,請以該工具的授權規範為準。

RELATED你可能也需要

PRO01
TUTORIALSuno v5.5FEATURED
r/SunoAI (anonymous studio engineer)2026-06-12

Suno 工程師思維:4 步驟做出不像 AI 的歌

5.0(1)

Studio engineer 視角拆解 Suno 致命弱點(油炸 vocals、高頻 artifact)+ 4 步驟 DAW workflow + Suno Studio 修音 prompt

高階
Read

免費02
TUTORIALClaude 4.5 SonnetFEATURED
r/ClaudeAI2026-05-14

5 個 6 月 stuck 下來的 Claude 每週 workflow

提案產生器 / 會議處理器 / 內容再利用 / 週五回顧 / 收工 reset — 試了 40 個只有這 5 個沒被丟掉、各省 30+ 分鐘 / 次。

進階
Read

PRO03
TUTORIALClaude 4.5 SonnetFEATURED
r/PromptEngineering2026-05-14

7 個跨 model A/B 測過的 prompt 技巧(不是 vibes)

六個月在 Claude / GPT-4 / Gemini 上用人工 rater A/B 測 200+ prompt 後寫的。包含 persona+constraint stacking / anti-example / role reversal QA / cognitive scaffold / emotional priming / uncertainty CoT / steelman first。

高階
Read

免費04
TUTORIALChatGPTFEATURED
r/ChatGPTPromptGenius2026-05-14

5 個信任檢查單行 prompt(沒有 role-play)

一年的 role-play system prompt + 14-step framework 後總結:真正改變品質的是 5 個單行 prompt。沒有 role、沒有 markdown、沒有「you are an expert」。

入門
Read

免費 · 全文開放閱讀

完整 prompt 已經開放.

免登入閱讀全文、保存瀏覽器收藏;登入後可一鍵複製與留言討論。不用信用卡。

不想註冊?

留個 email,下次有新 prompt 會寄一封簡短摘要給你。退訂一鍵、不轉賣。

每週一期,新上架提示詞 + 模型測試心得。每封信底部都有一鍵取消訂閱。

或訂 RSS feed(30 秒一次的人味選擇)

COMMENTS · 討論區0 則
登入 後可留言。還沒帳號?註冊
目前沒有留言。第一個說說你的經驗。
EMBED · 嵌入 blog / Note一行 iframe HTML、貼進文章即顯示此 prompt 卡片+

適合:部落格、Medium、Notion 公開頁、Substack — 任何支援 iframe / HTML 嵌入的地方。對方點「看完整」會回到本站、是 prompt 庫的免費 backlink。

<iframe src="https://prompt.luvai.net/embed/codex-agents-md-author" width="100%" height="380" frameborder="0" style="border:1px solid #e0dcd0;border-radius:4px;" loading="lazy" title="PromptCraft Embed"></iframe>
預覽 embed →380px tall · responsive width
發現這個 prompt 過時 / 跑不動 / 有錯字? 回報給我們 →