unity-cli-skill
AGENTS.md43 starsChanged 53 days agoApache-2.0View on GitHub
Cross-agent guidance for working in this repository. This is the canonical project instruction file for Codex and other coding agents; CLAUDE.md imports it so shared rules are maintained in one place. unity-cli is a pure skill containing a thin, pure-stdlib Python CLI for driving the Unity Editor/Player through the C# Console HTTP service (com.zh1zh1.csharpconsole). There are no external dependencies or build step. It is installed with npx skills add niqibiao/unity-cli-skill --copy; the bundled CLI runs in place from skills/unity-cli/scripts/cli/. Every…
- Commits and pushes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Every skill invokes the CLI at the skill's own base directory.
- Very specific: line 29
Use --json on command, list-commands, and batch, whose useful payload is structured data.
- Very specific: line 35
Follow skills/unity-cli/SKILL.md for the mandatory scratch-file location and full operational rules.
- Very specific: line 52
Prefer cs command whenever a built-in framework command covers the task.
- Distinctive: line 155
Run the pure-stdlib unit suite after CLI changes:
- Distinctive: line 179
Commit the release changes.
- Very specific: line 180
Create local tag vX.Y.Z.
- Distinctive: line 188
Prefer focused changes and keep agent-facing instructions concise.
- Distinctive: line 190
Never use git push without explicit user confirmation.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Cross-agent guidance for working in this repository. This is the canonical project
instruction file for Codex and other coding agents; CLAUDE.md imports it so shared
rules are maintained in one place.
Project overview
unity-cli is a pure skill containing a thin, pure-stdlib Python CLI for driving the
Unity Editor/Player through the C# Console HTTP service
(com.zh1zh1.csharpconsole). There are no external dependencies or build step. It is
installed with npx skills add niqibiao/unity-cli-skill --copy; the bundled CLI runs
in place from skills/unity-cli/scripts/cli/.
Invoking the CLI
Every skill invokes the CLI at the skill's own base directory. Run this form without changing directory:
python "<SKILL_DIR>/scripts/cli/cs.py" <command> [args]<SKILL_DIR> is the absolute base directory supplied when the skill loads. Do not
pass --project for normal use: find_project_root() walks up from both the current
working directory and the CLI's committed location (__file__) to find an Assets/
ProjectSettings/root.--project <path>is only an explicit override.
Use --json on command, list-commands, and batch, whose useful payload is
structured data. Other subcommands print an equivalent text form; add --json to
exec only when its structured envelope is specifically needed.
C# code for exec goes in a raw .cs file via --file. Structured parameters for
command and batch go in a JSON file via --input; never pass either inline.
Follow skills/unity-cli/SKILL.md for the mandatory scratch-file location and full
operational rules.
Lifecycle and setup
- Pre-setup:
setupandstatususe only the bundled stdlib CLI. - Post-setup: the full CLI is available after
com.zh1zh1.csharpconsoleis installed and Unity resolves it.
cs setup writes the shared, version-controlled Packages/manifest.json when the
package is missing or --update is used. Explain the exact source and obtain user
approval before running a write-producing setup. When the package is already present,
setup only checks the CLI/package major.minor versions. Other commands locate and
cache the resolved package lazily, so setup is a convenience rather than a gate.
Command-first principle
Prefer cs command whenever a built-in framework command covers the task. Use
cs list-commands --domain <domain> --tier core --json for the first discovery in
an agent session. This performs one live fingerprint comparison and fetches only a
missing or changed package-owned registry partition. Use --offline for subsequent
domain or exact-ID queries in the same agent session, and query advanced only
when needed. Use --refresh only when the user explicitly asks to update the
command list. Then check project custom commands and the snippet library before
falling back to ad-hoc cs exec.
Built-in and custom requests are preflighted from the resolved package-owned contract before HTTP dispatch. Unknown arguments, missing requirements, invalid types/ranges, ambiguous selectors, empty mutations, deny-policy actions, and missing explicit session ids fail without executing Unity.
Command map
| Command | Phase | Purpose |
cs setup | pre | Install/version-check the Unity package |
cs status | pre | Package, connection, and version status |
cs exec --file FILE | post | Execute raw C# as a fallback |
cs command --input FILE --json | post | Run one framework command |
cs batch --input FILE --json | post | Run multiple commands in one request |
cs health | post | Check service health |
cs doctor | pre/post | Read-only reliability diagnosis with findings |
cs wait-ready [--timeout N] | pre/post | Wait until the service is genuinely ready |
cs refresh [--wait TIMEOUT] [--exit-playmode] | post | Refresh assets and compile |
cs test [playmode] [--filter NAME] [--wait TIMEOUT] | post | Run Unity Test Framework tests and wait for results |
cs compile-set <ZIP|URL> / --skip | post | Decide what a player build's submissions compile against |
cs pull PATH [--mode runtime] [-o FILE] | post | Retrieve a file from the process being addressed |
cs logs [PATH] [--mode runtime] [--background] | post | Follow a log file on the process being addressed; --background collects to a file until the target exits |
cs list-commands --offline … --json | pre/post | Discover the validated cache or generated built-in fallback |
cs list-commands … --json | post | Compare and progressively inspect the installed package registry |
cs catalog sync / cs catalog list | post | Maintain the custom-command catalog |
cs snippets … | post | Browse, run, and maintain reusable snippets |
Architecture
Agent harness
└─ skills/unity-cli/SKILL.md (routing and operating rules)
└─ scripts/cli/cs.py (argparse and handlers)
├─ registry_resolver.py (fingerprint, cache, generated fallback)
├─ command_discovery.py / command_preflight.py
└─ core_bridge.py (dynamic csharpconsole_core import)
└─ HTTP service in Unity Editor/PlayerThe CLI does not bundle csharpconsole_core. It resolves it from the installed Unity
package so client and service versions stay aligned:
- A
file:dependency inPackages/manifest.json. Library/PackageCache/com.zh1zh1.csharpconsole@*/Editor/ExternalTool~/console-client/.
ConsoleSession wires the core client, command protocol, configuration, output,
response parser, and HTTP transport into the CLI operations. Transport failures are
retried once after one second to tolerate Unity domain reloads.
Version and machine-local state
- The version source is
skills/unity-cli/scripts/cli/VERSION; keep it in lockstep with release tagvX.Y.Z. version_check.pyonly checks compatibility.cs.pypins a plain git package source to the newest tag on the CLI'smajor.minorline when setup writes the manifest;file:sources, explicit fragments, and failed tag queries are left unpinned.- Package path, Registry Snapshot/fingerprints, and snippet usage statistics live
in a per-project user cache
(
%LOCALAPPDATA%\unity-cli\<project-key>\on Windows or$XDG_CACHE_HOME/unity-cli/<project-key>/elsewhere), never in the project tree. - The committed custom-command catalog and snippet audit remain project state; see the skill references for their exact locations.
Repository structure
skills/unity-cli/SKILL.md Skill entry and routing
skills/unity-cli/references/*.md Topic-specific operating guidance
skills/unity-cli/scripts/cli/cs.py CLI dispatcher
skills/unity-cli/scripts/cli/command_discovery.py
skills/unity-cli/scripts/cli/command_preflight.py
skills/unity-cli/scripts/cli/catalog_store.py
skills/unity-cli/scripts/cli/registry_*.py
skills/unity-cli/scripts/cli/routing_overlay.json
skills/unity-cli/scripts/cli/core_bridge.py
skills/unity-cli/scripts/cli/paths.py Per-project cache paths
skills/unity-cli/scripts/cli/VERSION Release version
dev/tests/*.py Unit suite
dev/tests/_paths.py Where the skill sits, stated once
dev/evals/ Routing eval harness and oracles
dev/fixtures/ Pinned registry snapshot the suite reads
dev/refresh_local_fixture.py Regenerates that snapshotEverything under skills/unity-cli/ ships; there are no slash commands.
npx skills add copies that directory verbatim and honours no ignore file, so
the suite, the evals and their fixtures live in dev/ instead, and nothing
shipped may name them -- dev/tests/test_shipped_tree_is_self_contained.py
holds that line.
Testing
Run the pure-stdlib unit suite after CLI changes:
python -B -m unittest discover -s dev/tests -p "test_*.py" -vThere is no build or dependency-install step.
The suite stubs csharpconsole_core, so it cannot see the package's API move.
test_core_contract.py closes that seam by binding every call core_bridge.py
makes against a real core, and skips when it cannot find one. Point it at a
package to keep the gate live while working on both repositories:
export UNITY_CLI_CORE_DIR=/path/to/com.zh1zh1.csharpconsole/Editor/ExternalTool~/console-clientRelease process
For a requested X.Y.Z release:
- Rename the pending
CHANGELOG.mdsection to## [X.Y.Z] - YYYY-MM-DD, then add a fresh## [Unreleased]above it. - Set
skills/unity-cli/scripts/cli/VERSIONto bareX.Y.Z. - Commit the release changes.
- Create local tag
vX.Y.Z.
.github/workflows/release.yml extracts the matching changelog section for release
notes. Never push commits or tags without explicit user confirmation.
Conventions
- Preserve pure stdlib Python; do not add dependencies or a build step.
- Prefer focused changes and keep agent-facing instructions concise.
- Machine-local state must never be written into the project tree.
- Never use
git pushwithout explicit user confirmation.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

