Communitygithub.com

s&box CLI

專為 s&box 遊戲引擎(Facepunch Studios,Source 2)設計的 AI Agent 原生 CLI 工具。提供 14 個群組、79 個以上的指令,可直接操作 `.scene`、`.prefab`、`.vmat`、`.sound`、`Input.config`、`Collision.config` 等 JSON 檔案,生成慣用的 C# 元件,並即時監控專案的資源圖譜。

s&box CLI 是什麼?

此技能為 s&box 遊戲引擎提供了一個 AI Agent 原生的命令列介面(CLI),讓開發者與 AI 助手(如 Claude Code、Cursor、Codex)能直接操作遊戲專案的底層資產。它支援 79 個以上指令,分為 14 個功能群組,包括專案管理、場景編輯、預製物件(Prefab)操作、C# 程式碼生成、輸入配置、碰撞設定、材質與音效管理、在地化、資產管理與重構、以及專用伺服器啟動等。核心優勢在於,大多數指令直接讀寫專案中的 JSON 檔案(如 `.scene`、`.prefab`、`.vmat`、`.sound`、`Input.config`、`Collision.config`),無需啟動 s&box 編輯器即可進行批次修改。此工具支援透過 `--json` 參數輸出結構化 JSON,方便 AI Agent 解析與串接指令。此外,它也提供了互動式 REPL 模式,適合手動操作與除錯。安裝方式簡單,只需透過 pip 安裝 GitHub 上的套件,並確保 Python 3.10 以上與 Steam 上的 s&box 即可。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/HKUDS/CLI-Anything/tree/main/skills/cli-anything-sbox

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

s&box CLI 是做什麼的?

專為 s&box 遊戲引擎(Facepunch Studios,Source 2)設計的 AI Agent 原生 CLI。提供 79 個以上的指令,橫跨 14 個群組。可直接操作 .scene、.prefab、.vmat、.sound、Input.config、Collision.config 等 JSON 檔案,生成慣用的 C# 元件,並即時監控專案的資產圖譜。

安裝

pip install git+https://github.com/HKUDS/CLI-Anything.git#subdirectory=sbox/agent-harness

需求條件

  • Python 3.10+
  • 透過 Steam 安裝的 s&box - 會自動偵測,或設定 SBOX_PATH 環境變數指向自訂安裝目錄。
  • 多數指令完全作用於專案的 JSON 檔案上 - 不需要正在執行中的 s&box。

全域選項

--json          輸出機器可讀的 JSON 格式(給 Agent 使用時請務必加上)
--project PATH  指定專案目錄(若省略,會從目前工作目錄的 .sbproj 自動偵測)

指令群組

project - 管理 s&box 專案

cli-anything-sbox project new --name MyGame --output-dir ./MyGame
cli-anything-sbox --json project info
cli-anything-sbox project config --max-players 32 --tick-rate 64
cli-anything-sbox --json --project ./MyGame project add-package facepunch.libsdf
cli-anything-sbox --json --project ./MyGame project remove-package facepunch.libsdf
# 檢查:損壞的資產參考、重複的 GUID、格式錯誤的 Input.config
cli-anything-sbox --json --project ./MyGame project validate
cli-anything-sbox --project ./MyGame project validate --no-inputs --no-guids

scene - 操作 .scene 檔案

cli-anything-sbox scene new --name gameplay -o ./Assets/scenes/gameplay.scene
cli-anything-sbox --json scene info ./scene.scene
cli-anything-sbox --json scene list ./scene.scene
cli-anything-sbox scene add-object ./scene.scene Enemy --position "100,0,0" --components "model,box_collider,rigidbody" --tags "enemy"
cli-anything-sbox scene remove-object ./scene.scene --name Enemy
cli-anything-sbox scene add-component ./scene.scene <object-guid> Sandbox.PointLight
cli-anything-sbox scene remove-component ./scene.scene <object-guid> --component-type Sandbox.Rigidbody
cli-anything-sbox --json scene modify-object ./scene.scene --guid <guid> --name NewName --position "200,0,0"
cli-anything-sbox --json scene clone-object ./scene.scene --name Enemy --new-name EnemyCopy --position "300,0,0"
cli-anything-sbox --json scene get-object ./scene.scene --name Sun
cli-anything-sbox scene set-property ./scene.scene --fixed-update-freq 64 --timescale 0.5
cli-anything-sbox scene set-navmesh ./scene.scene --enabled --agent-height 72 --agent-radius 16
cli-anything-sbox --json scene list-presets
cli-anything-sbox --json scene modify-component ./scene.scene <object-guid> <component-guid> --properties '{"Damage":50}'

# 尋找符合一個或多個篩選條件的物件(AND 結合)
cli-anything-sbox --json scene query ./scene.scene --has-component rigidbody --has-tag tower
cli-anything-sbox --json scene query ./scene.scene --name-regex "^Tower\d$" --in-bounds "0,-500,-50,1000,500,50"

# 從場景中提取所有資產參考(.vmdl, .vmat, .vsnd, .vtex, .vpcf, .prefab)
cli-anything-sbox --json scene refs ./scene.scene

# 對所有符合查詢條件的物件套用相同的修改
cli-anything-sbox --json scene bulk-modify ./scene.scene --has-tag tower --position "0,0,100" --enable

# 兩個場景之間的結構差異(新增/移除/修改的 GameObject + SceneProperties)
cli-anything-sbox --json scene diff ./old.scene ./new.scene

# 將預製物件以 GameObject 形式插入場景中
cli-anything-sbox --json scene instantiate-prefab ./level.scene ./Assets/prefabs/bullet.prefab --position "10,0,0"

prefab - 管理 .prefab 檔案

cli-anything-sbox prefab new --name Bullet -o ./Assets/prefabs/bullet.prefab --components "model,sphere_collider,rigidbody"
cli-anything-sbox --json prefab info ./Assets/prefabs/bullet.prefab
cli-anything-sbox prefab from-scene ./scene.scene <object-guid> -o ./Assets/prefabs/extracted.prefab
cli-anything-sbox --json prefab add-component ./prefab.prefab rigidbody
cli-anything-sbox prefab remove-component ./prefab.prefab --component-type Sandbox.Rigidbody
cli-anything-sbox --json prefab list

# 預製物件內部的資產參考
cli-anything-sbox --json prefab refs ./prefab.prefab

# 修改預製物件上的元件屬性(依元件型別或元件 GUID)
cli-anything-sbox --json prefab modify-component ./prefab.prefab --component-type Sandbox.Rigidbody --properties '{"Gravity":false,"MassOverride":50}'

# 兩個預製物件之間的結構差異(根物件 + 具名子物件)
cli-anything-sbox --json prefab diff ./old.prefab ./new.prefab

codegen - 產生 C# 程式碼

# 純元件
cli-anything-sbox codegen component --name PlayerController --methods OnUpdate,OnFixedUpdate -o ./Code/PlayerController.cs

# 帶有 [Property] 欄位的元件
cli-anything-sbox --json codegen component --name Tower --properties '[{"name":"Damage","type":"float","default":"25f"},{"name":"Range","type":"float","default":"500f"}]'

# 網路化元件(部分類別)附 RPC 方法骨架
cli-anything-sbox codegen component --name NetPlayer --networked --methods OnUpdate,OnFixedUpdate --rpc-methods "Fire:Broadcast,TakeDamage:Host" -o ./Code/NetPlayer.cs

# GameResource
cli-anything-sbox codegen gameresource --name TowerData --display-name "Tower Data" --extension tower -o ./Code/TowerData.cs

# 編輯器選單(Editor/ 組件)
cli-anything-sbox codegen editor-menu --name MyTools --menu-path "Editor/My Tools/Open" -o ./Editor/MyTools.cs

# 純 Razor UI 元件(.razor + .razor.scss)
cli-anything-sbox codegen razor --name HudPanel --properties '[{"name":"Score","type":"int","default":"0"}]' -o ./UI/HudPanel.razor

# 靜態類別或基底衍生類別
cli-anything-sbox codegen class --name Math2 --static -o ./Code/Math2.cs

# PanelComponent + 同層 ScreenPanel 腳手架(處理 s&box 的特殊情況,即 PanelComponent 輸入只有在兩者位於同一個 GameObject 時才起作用)。
# 產生 .razor + .razor.scss + 一段可直接貼上的 GameObject 片段,或直接附加到帶有 --scene 的場景中。
cli-anything-sbox --json codegen panel-component --name HudBar -o ./UI/HudBar.razor
cli-anything-sbox codegen panel-component --name Crosshair -o ./UI/Crosshair.razor --scene ./Assets/scenes/game.scene

input - 管理 Input.config

cli-anything-sbox --json input list
cli-anything-sbox input add --name PlaceTower --group Gameplay --keyboard mouse1 --gamepad RightTrigger
cli-anything-sbox input remove --name PlaceTower
cli-anything-sbox input set --name Attack1 --keyboard mouse1

collision - 管理 Collision.config

cli-anything-sbox --json collision list
cli-anything-sbox collision add-layer --name projectile --default Collide
cli-anything-sbox collision add-rule --layer-a projectile --layer-b solid --result Collide
cli-anything-sbox collision remove-rule --layer-a projectile --layer-b solid
cli-anything-sbox collision remove-layer --name projectile

material - 管理 .vmat 材質

cli-anything-sbox --json material new --name floor --shader complex --color-texture "textures/floor.tga" --metalness 0.3 -o ./Assets/materials/floor.vmat
cli-anything-sbox --json material info ./Assets/materials/floor.vmat
cli-anything-sbox --json material list
cli-anything-sbox --json material set ./Assets/materials/floor.vmat --metalness 0.8

sound - 管理 .sound 事件

cli-anything-sbox --json sound new --name gunshot --sounds "sounds/gun1.vsnd,sounds/gun2.vsnd" --volume 0.8 -o ./Assets/sounds/gunshot.sound
cli-anything-sbox --json sound info ./Assets/sounds/gunshot.sound
cli-anything-sbox --json sound list
cli-anything-sbox --json sound set ./Assets/sounds/gunshot.sound --volume 0.5

localization - 管理翻譯

cli-anything-sbox localization new --lang en -o ./Localization/en.json
cli-anything-sbox localization set ./Localization/en.json --key "game.title" --value "My Game"
cli-anything-sbox --json localization list ./Localization/en.json
cli-anything-sbox localization get ./Localization/en.json --key "game.title"
cli-anything-sbox localization remove ./Localization/en.json --key "game.title"
cli-anything-sbox localization bulk-set ./Localization/en.json --keys '{"ui.start":"Start","ui.quit":"Quit"}'

server - 專用伺服器

cli-anything-sbox server info
cli-anything-sbox server start --game my_game --map facepunch.flatgrass

asset - 資產管理與反向查詢

cli-anything-sbox --json asset list --type scene
cli-anything-sbox --json asset info ./Assets/scenes/minimal.scene
cli-anything-sbox asset compile ./Assets/materials/floor.vmat

# 哪些場景/預製物件參考了此資產?
cli-anything-sbox --json --project ./MyGame asset find-refs models/myteam/widget.vmdl

# 尋找未被參考的資產(按型別,或跨所有可參考型別)
cli-anything-sbox --json --project ./MyGame asset find-unused
cli-anything-sbox --json --project ./MyGame asset find-unused --type model --type material

# 重新命名資產並更新所有場景/預製物件參考(若省略副檔名則保留原始副檔名)
cli-anything-sbox --json --project ./MyGame asset rename models/team/widget.vmdl gizmo
cli-anything-sbox --project ./MyGame asset rename models/team/widget.vmdl gizmo --dry-run

# 跨目錄移動資產並更新所有參考
cli-anything-sbox --json --project ./MyGame asset move models/team/widget.vmdl models/shared/widget.vmdl

session - 狀態管理

cli-anything-sbox session status
cli-anything-sbox session undo
cli-anything-sbox session redo

test - 自動化地圖/場景生成測試框架

cli-anything-sbox test setup
cli-anything-sbox --json test run

launch - 在 s&box 編輯器中開啟專案

cli-anything-sbox launch

元件預設

29 個簡短名稱,可與 scene add-object、prefab new 等指令的 --components 參數搭配使用。每個名稱對應一個 Sandbox.* 元件型別。

預設名稱元件型別
modelSandbox.ModelRenderer
box_colliderSandbox.BoxCollider
sphere_colliderSandbox.SphereCollider
capsule_colliderSandbox.CapsuleCollider
plane_colliderSandbox.PlaneCollider
model_colliderSandbox.ModelCollider
rigidbodySandbox.Rigidbody
character_controllerSandbox.CharacterController
player_controllerSandbox.PlayerController
cameraSandbox.CameraComponent
light_directionalSandbox.DirectionalLight
light_pointSandbox.PointLight
spot_lightSandbox.SpotLight
ambient_lightSandbox.AmbientLight
sprite_rendererSandbox.SpriteRenderer
skinned_model_rendererSandbox.SkinnedModelRenderer
text_rendererSandbox.TextRenderer
line_rendererSandbox.LineRenderer
decal_rendererSandbox.DecalRenderer
trail_rendererSandbox.TrailRenderer
particle_effectSandbox.ParticleEffect
sound_pointSandbox.SoundPointComponent
nav_mesh_agentSandbox.NavMeshAgent
screen_panelSandbox.ScreenPanel
world_panelSandbox.WorldPanel
fixed_jointSandbox.FixedJoint
hinge_jointSandbox.HingeJoint
spring_jointSandbox.SpringJoint
ball_socket_jointSandbox.BallSocketJoint

scene list-presets 會以 JSON 格式回傳即時的預設註冊表。

Agent 使用模式

每次由 Agent 驅動的呼叫都請加上 --json 參數。透過管道傳給 jq 來在指令之間傳遞 GUID 和路徑:

# 建立專案
sbproj=$(cli-anything-sbox --json project new --name MyGame --output-dir /tmp/MyGame | jq -r '.sbproj')
cd /tmp/MyGame

# 新增一個帶有特定元件配置的塔,並取得其 GUID
guid=$(cli-anything-sbox --json scene add-object ./Assets/scenes/main.scene Tower \
    --components "model,box_collider,rigidbody" --tags "tower" \
    | jq -r '.guid')

# 產生對應的 C# 元件,並啟用網路化
cli-anything-sbox --json codegen component --name Tower --networked \
    --rpc-methods "Fire:Host" --properties '[{"name":"Damage","type":"float","default":"25f"}]' \
    -o ./Code/Tower.cs

# 批次調整場景中的所有塔
cli-anything-sbox --json scene bulk-modify ./Assets/scenes/main.scene \
    --has-tag tower --enable --position-y-add 50

# 在提交前進行驗證
cli-anything-sbox --json project validate

REPL 模式

直接執行 cli-anything-sbox(不帶任何參數)會進入一個互動式 REPL,並附有美化提示符號:

$ cli-anything-sbox
cli-anything-sbox> project info
cli-anything-sbox> scene list ./Assets/scenes/main.scene
cli-anything-sbox> codegen component --name Foo -o ./Code/Foo.cs
cli-anything-sbox> quit

環境變數

變數說明預設值
SBOX_PATHs&box 安裝目錄從 Steam 資料庫資料夾自動偵測
CLI_ANYTHING_SKILL_REPO覆寫 repl_skin 讀取 SKILL.md 的儲存庫HKUDS/CLI-Anything

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

cli-anything-adguardhome

>-

cli-anything-anygen

>-

cli-anything-audacity

>-

cli-anything-blender

>-

cli-anything-browser

Browser automation CLI using DOMShell MCP server. Maps Chrome

cli-anything-calibre

>-

cli-anything-ccswitch

CLI interface for CC Switch — manage AI coding tool configurations from the terminal

cli-anything-chromadb

>-

cli-anything-cloudanalyzer

Command-line interface for CloudAnalyzer — Agent-friendly harness for CloudAnalyzer, a QA platform for mapping, localization, and perception outputs. Supports 27 commands across 8 groups: point cloud evaluation, trajectory evaluation, ground segmentation QA, config-driven quality gates, baseline evolution, processing, visualization, and interactive REPL.

cli-anything-cloudcompare

Command-line interface for CloudCompare — Agent-friendly harness for CloudCompare, the open-source 3D point cloud and mesh processing software. Supports 41 commands across 9 groups: project management, session control, point cloud operations (subsample, filter, segment, analyze), mesh operations, distance computation (C2C, C2M), transformations (ICP, matrix), export (LAS/LAZ/PLY/PCD/OBJ/STL/E57), and interactive REPL.

cli-anything-comfyui

>-

cli-anything-dify-workflow

Wrapper for the Dify workflow DSL CLI. Create, inspect, validate, edit, and export Dify workflow files through a CLI-Anything harness.

cli-anything-drawio

>-

cli-anything-eez-studio

Use EEZ Studio from the command line: inspect and modify native .eez-project files, edit LVGL screens/widgets, manage SCPI commands, and invoke the real EEZ Studio backend for LVGL builds.

cli-anything-eth2-quickstart

>-

cli-anything-exa

>-

cli-anything-firefly-iii

Firefly III CLI - Personal finance management via CLI-Anything

cli-anything-freecad

Complete CLI harness for FreeCAD parametric 3D CAD modeler (258 commands). Covers ALL workbenches: Part (29 primitives + boolean + mirror + loft + sweep), Sketcher (26 cmds: geometry + constraints + editing), PartDesign (38 cmds: pad/pocket/groove/fillet/chamfer/patterns/hole/datum), Assembly (11 cmds), Mesh (16 cmds), TechDraw (15 cmds: views + dimensions + PDF/SVG), Draft (33 cmds: 2D shapes + arrays + transforms), FEM (12 cmds), CAM/CNC (10 cmds), Surface (6 cmds), Spreadsheet (7 cmds), Import (13 formats), Export (17 formats), Measure (12 cmds), Materials (21 presets). Headless FreeCAD export to STEP/IGES/STL/OBJ/DXF/PDF/glTF/3MF.

cli-anything-gimp

>-

cli-anything-godot

>-

相關技能