SKILL.md
唯讀
名稱
create-agentsmd
描述
用於為儲存庫生成 AGENTS.md 檔案的提示詞
建立高品質的 AGENTS.md 檔案
你是一位程式碼 Agent。你的任務是在此儲存庫的根目錄建立一份完整且準確的 AGENTS.md,並遵循 https://agents.md/ 的公開指引。
AGENTS.md 是一種開放格式,旨在為 AI 程式碼 Agent 提供在專案中有效工作所需的上下文與指令。
什麼是 AGENTS.md?
AGENTS.md 是一個 Markdown 檔案,作為「專屬於 Agent 的 README」——一個專用且可預測的位置,用於提供上下文與指令,協助 AI 程式碼 Agent 在你的專案中運作。它補充了 README.md,包含程式碼 Agent 所需但可能會讓面向人類的 README 過於雜亂的詳細技術上下文。
核心原則
- 以 Agent 為核心:包含自動化工具所需的詳細技術指令
- 補充 README.md:不取代人類文件,而是補充 Agent 專屬的上下文
- 標準化位置:置於儲存庫根目錄(在單一巨型儲存庫 monorepo 中也可置於子專案根目錄)
- 開放格式:使用具有彈性結構的標準 Markdown
- 生態系統相容性:適用於 20 多種不同的 AI 程式碼工具與 Agent
檔案結構與內容指引
1. 必要設定
- 在儲存庫根目錄建立名為
AGENTS.md的檔案 - 使用標準 Markdown 格式
- 無強制要求的必填欄位——根據專案需求靈活安排結構
2. 建議包含的核心區塊
專案總覽 (Project Overview)
- 專案功能的簡短說明
- 若架構複雜,提供架構總覽
- 所使用的關鍵技術與框架
設定指令 (Setup Commands)
- 安裝說明
- 環境設定步驟
- 套件管理指令
- 資料庫設定(若適用)
開發工作流程 (Development Workflow)
- 如何啟動開發伺服器
- 建置指令
- 監視/熱重載 (hot-reload) 設定
- 套件管理器細節(npm、pnpm、yarn 等)
測試說明 (Testing Instructions)
- 如何執行測試(單元測試、整合測試、端對端測試)
- 測試檔案位置與命名規範
- 覆蓋率要求
- 使用的特定測試模式或框架
- 如何執行子集測試或聚焦於特定區域
程式碼風格指引 (Code Style Guidelines)
- 特定語言的慣例
- Lint 與格式化規則
- 檔案組織模式
- 命名規範
- 匯入/匯出 (import/export) 模式
建置與部署 (Build and Deployment)
- 建置指令與輸出路徑
- 環境變數配置
- 部署步驟與要求
- CI/CD 管道資訊
3. 可選但推薦的區塊
安全性考量 (Security Considerations)
- 安全測試要求
- 金鑰/機密管理 (Secrets management)
- 驗證模式
- 權限模型
Monorepo 指引 (Monorepo Instructions, 若適用)
- 如何處理多個套件 (packages)
- 跨套件依賴項
- 選擇性建置/測試
- 套件專屬指令
Pull Request 指引 (Pull Request Guidelines)
- 標題格式要求
- 提交前必須通過的檢查
- 審查流程 (Review process)
- Commit 訊息規範
除錯與疑難排解 (Debugging and Troubleshooting)
- 常見問題與解決方案
- 日誌紀錄模式
- 除錯配置
- 效能考量
範本範例
可將此作為起始範本,並根據具體專案進行自訂:
# AGENTS.md
## Project Overview
[專案簡述、目的與主要技術]
## Setup Commands
- Install dependencies: `[package manager] install`
- Start development server: `[command]`
- Build for production: `[command]`
## Development Workflow
- [開發伺服器啟動說明]
- [熱重載/監視模式資訊]
- [環境變數設定]
## Testing Instructions
- Run all tests: `[command]`
- Run unit tests: `[command]`
- Run integration tests: `[command]`
- Test coverage: `[command]`
- [特定的測試模式或要求]
## Code Style
- [語言與框架慣例]
- [Linting 規則與指令]
- [格式化要求]
- [檔案組織模式]
## Build and Deployment
- [建置流程細節]
- [輸出目錄]
- [特定環境建置]
- [部署指令]
## Pull Request Guidelines
- Title format: [component] Brief description
- Required checks: `[lint command]`, `[test command]`
- [審查要求]
## Additional Notes
- [任何專案專屬的上下文]
- [常見陷阱或疑難排解技巧]
- [效能考量]
來自 agents.md 的實作範例
以下是來自 agents.md 官方網站的真實範例:
# Sample AGENTS.md file
## Dev environment tips
- Use `pnpm dlx turbo run where <project_name>` to jump to a package instead of scanning with `ls`.
- Run `pnpm install --filter <project_name>` to add the package to your workspace so Vite, ESLint, and TypeScript can see it.
- Use `pnpm create vite@latest <project_name> -- --template react-ts` to spin up a new React + Vite package with TypeScript checks ready.
- Check the name field inside each package's package.json to confirm the right name—skip the top-level one.
## Testing instructions
- Find the CI plan in the .github/workflows folder.
- Run `pnpm turbo run test --filter <project_name>` to run every check defined for that package.
- From the package root you can just call `pnpm test`. The commit should pass all tests before you merge.
- To focus on one step, add the Vitest pattern: `pnpm vitest run -t "<test name>"`.
- Fix any test or type errors until the whole suite is green.
- After moving files or changing imports, run `pnpm lint --filter <project_name>` to be sure ESLint and TypeScript rules still pass.
- Add or update tests for the code you change, even if nobody asked.
## PR instructions
- Title format: [<project_name>] <Title>
- Always run `pnpm lint` and `pnpm test` before committing.
執行步驟
-
分析專案結構,以瞭解:
- 使用的程式語言與框架
- 套件管理器與建置工具
- 測試框架
- 專案架構(monorepo、單一套件等)
-
識別關鍵工作流程,透過檢查:
- package.json 腳本
- Makefile 或其他建置檔案
- CI/CD 配置檔案
- 文件檔案
-
建立完整的區塊,涵蓋:
- 所有必要的設定與開發指令
- 測試策略與指令
- 程式碼風格與規範
- 建置與部署流程
-
包含具體且可執行的指令,使 Agent 可以直接執行
-
測試這些指令,確保所有指令皆如文件所述正常運作
-
保持內容專注,聚焦於 Agent 需要知道的事項,而非一般的通用專案資訊
最佳實踐
- 明確具體:提供精確的指令,避免模糊的描述
- 使用程式碼區塊:將指令包裹在反引號中以維持清晰
- 包含上下文:解釋為什麼需要某些步驟
- 保持最新:隨專案演進同步更新
- 測試指令:確保列出的所有指令確實可行
- 考量巢狀檔案:對於 monorepo,必要時可在子專案目錄中建立 AGENTS.md 檔案
Monorepo 考量事項
對於大型 monorepo:
結語
- AGENTS.md 支援 20 多種 AI 程式碼工具,包括 Cursor、Aider、Gemini CLI 等等
- 此格式具備彈性設計——請根據專案需求進行調整
- 專注於可執行的指令,幫助 Agent 清楚理解並處理你的程式碼庫
- 這是一份動態文件——請隨專案發展持續更新
建立 AGENTS.md 檔案時,請優先考慮清晰度、完整性與可執行性。目標是提供足夠的上下文給任何程式碼 Agent,使其無需額外的人類指導即可高效地為專案做出貢獻。






