Grok WorldGrok Build CLI field station
訊號已鎖定
NAV

GROK BUILD CLI / 04

編寫 project rules,並驗證 Claude Code 相容性

只有在載入檔案與 precedence 可見時,相容性才有實際價值。讓 rules 精簡、可版本管理且可測試。

CHANNELREPOSITORY 上下文 / 中階 / 11 MIN
來源核對日期2026-07-26
ORIGINOFFICIAL DOCS / PRIMARY

把穩定 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。grok import subcommand 用於 Claude Code sessions;asset discovery 本身不需要 import 這些檔案。

grok inspect

# 需要時匯入相容的 Claude Code session history
grok 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