跳轉到主要內容
使用 cli-config.json 檔案設定 Agent CLI。

檔案位置

類型平台路徑
全域macOS/Linux~/.cursor/cli-config.json
全域Windows$env:USERPROFILE\.cursor\cli-config.json
專案全部<project>/.cursor/cli.json
只有權限可以在專案層級調整。其他所有 CLI 設定都必須在全域層級設定。
可用環境變數覆寫:
  • CURSOR_CONFIG_DIR:自訂目錄路徑
  • XDG_CONFIG_HOME(Linux/BSD):使用 $XDG_CONFIG_HOME/cursor/cli-config.json

結構定義

必填欄位

欄位型別說明
versionnumber設定結構定義版本(目前:1
editor.vimModeboolean啟用 Vim 鍵盤快捷鍵(預設:false
permissions.allowstring[]允許的操作(詳見 Permissions
permissions.denystring[]禁止的操作(詳見 Permissions

選用欄位

欄位型別說明
modelobject已選定的模型設定
hasChangedDefaultModelboolean由 CLI 管理的預設模型覆寫旗標

範例

最小化設定

{
  "version": 1,
  "editor": { "vimMode": false },
  "permissions": { "allow": ["Shell(ls)"], "deny": [] }
}

開啟 Vim 模式

{
  "version": 版本 1,
  "editor": { "vimMode": true },
  "permissions": { "allow": ["Shell(ls)"], "deny": [] }
}

設定權限

{
  "version": 版本: 1,
  "editor": { "vimMode": false },
  "permissions": {
    "allow": ["Shell(ls)", "Shell(echo)"],
    "deny": ["Shell(rm)"]
  }
}
參考 Permissions 以了解可用的權限類型與範例。

疑難排解

設定錯誤:先把該檔案移開,然後重新啟動:
mv ~/.cursor/cli-config.json ~/.cursor/cli-config.json.bad
變更無法保存:確保 JSON 有效且具備寫入權限。有些欄位由 CLI 管理,可能會被覆寫。

注意事項

  • 純 JSON 格式(不含註解)
  • CLI 會自動修復缺失的欄位
  • 損毀的檔案會先備份為 .bad,再重新建立
  • 權限條目必須為精確字串(詳見 Permissions
I