把穩定 instruction 放進 AGENTS.md
在 repository root 建立 AGENTS.md,記錄每個任務都適用的 architecture boundary、build/test command、coding convention 與安全規則。只有 subtree 確實不同時才加入 nested AGENTS.md。
Grok 會從 repository root 走到 working directory;衝突時較深層 rule 優先。短而具體的規則,比塞進 context 的大型手冊更容易遵循與審查。
- 寫出可執行的 verification commands。
- 標明 generated 或 protected paths。
- 解釋 architecture constraints,不放暫時任務細節。
以證據從 Claude Code 遷移
xAI 官方文件表示,Grok 可在 native .grok assets 之外,自動讀取 Claude Code instruction files、marketplaces、plugins、skills、MCPs、agents 與 hooks。應把它表述為有來源的 compatibility claim,並驗證實際 repository,不要假設每個 extension 行為完全相同。
文件列出的 instruction sources 包含 CLAUDE.md、Claude.md、CLAUDE.local.md 與 .claude/rules,而且 asset discovery 不需要任何 import。CLI reference 另列出用於 Claude Code sessions 的 grok import,但已安裝的 Grok Build 1.0.67 不認得這個 subcommand;寫進 script 前先執行 grok help import 確認。
grok inspect
# grok import 列在文件中,但 1.0.67 沒有此指令;先確認
grok help import 加入單次 rule,不污染 repository
只屬於當次執行的窄範圍 instruction 可用 --rules。不要輕率使用 system-prompt override;替換 system prompt 的影響遠大於追加 constraint。
修改檔案或 compatibility settings 後再次執行 inspect。逐一查看回報路徑與大約 token cost,並從來源解決重複或衝突 instruction。
grok --rules "Always use TypeScript. Prefer functional components."
grok inspect