Install
Ancha needs Node.js 24 or later.
Check the install with
ancha --version. It prints 0.1.4.
The three commands
Run every command from the project root, whereancha.yaml lives.
ancha doctor --json checks the setup between steps 1 and 2. It runs the agent once and confirms it reached each tool. A tool the agent did not call is a warning, not a failure, and doctor exits 0.
Every command ends with next: <exact command> in text, and with a next list in JSON. Follow it.
To prove a fix, save the failing run, change the agent, and compare:
0 means every check passed and no scene and no check got worse than before.
How your agent reaches the tools
Ancha starts the agent with tool URLs and fake credentials in environment variables, for exampleSLACK_API_URL and SLACK_BOT_TOKEN. The agent must use them instead of real service URLs. ancha connect <tool> --lang ts (or --lang py) prints SDK settings for a tool. See Environment variables for the full list.
The agent runs as a process on this computer with this computer’s network. Its environment holds a base set (PATH, HOME, locale and the like), Ancha’s variables and the tools’ variables. Anything else from the shell, such as a provider key, reaches it only through agent.pass_env in ancha.yaml or --pass-env NAME. For a sealed run, set agent.execution: { mode: container, image: node:24-slim } in ancha.yaml; it needs Docker. See ancha run.
JSON output
Add--json to any command for machine-readable output on stdout, or set ANCHA_JSON=1, which acts as --json on every command.
ancha run --json,ancha wait --jsonandancha logs --jsonprint newline-delimited JSON (NDJSON): one event per line, ending withrun_finished. Do not parse stdout as a single JSON object.- Every other command prints one JSON object.
- Errors print one object with an
errorkey, and the process exits with the code in the table below. ancha schema <kind> --jsonprints the JSON Schema ofancha.yaml, scene files and these outputs:run_started,run_finished,explain,world_up,checkanderror.
Error
ancha run --json, in order:
ancha run --json (failing run)
Retrying safely
If your command can time out, giveancha run an --idempotency-key <key>. Running it again with the same key returns the same run instead of starting another, with replayed: true. While the first run is still going, the retry fails with SESSION_CONFLICT and a hint to ancha wait <id>. Use a new key for a new run. ancha run --detach --json returns a run ID at once; follow it with ancha logs <id> --follow --json, which exits with the run’s exit code.
Exit codes
When several apply,
3 wins over 4, and 4 wins over 1. ancha explain exits 0 even when it lists failures, so read the exit code of ancha run.
Read a verdict
Therun_finished summary holds the verdict. These fields matter most:
Read it in this order:
- Exit
2or3: fix the setup or retry. Do not change the agent yet. agentIssuesis not empty: the agent crashed or timed out.ancha explainshows the end ofagent.log.failuresis not empty: compareexpectedwithactual, then read the trace. Many bugs only appear with the world’s data, so read the evidence before guessing from the code.coverageGapsis not empty: the replica answered with an error because it does not implement that call. Checkancha twins coverage <tool>before you change working code.agentEnvironment.withheldis not zero and the agent needs one of those variables, such as a provider key: pass it with--pass-env NAMEoragent.pass_env.
Rules for coding agents
- Fix the agent’s code. Do not edit
ancha.yaml, the scenes or their checks to make a run pass. The exception is a check that is wrong for the real API, such as a method the official SDK never sends: tell the user, show the evidence fromancha explainand the vendor’s documentation, and change it only with their agreement. - Never point the agent at real SaaS URLs, and never give it real credentials.
- Never give the agent under test the scenes, checks, seeds or reference companions (
oracle.mjs,null.mjs). - Use
--compareagainst a saved baseline to prove a fix. Never compare a run with itself. - Keep
--jsonon every command, and read the exit code.
The starter scene only proves the agent can reach each tool. Replace it with a scene that checks real work. Its checks accept any HTTP method (
* /api/*.* for Slack), so an agent built on an official SDK passes them as it is.Hosted workspace
If the user has an Ancha workspace,ancha login asks them to approve this computer once in the browser; ask them to do it. A signed-in ancha run still runs the agent and its worlds on this computer, and its first line names the workspace. ancha run --upload sends the finished run to that workspace, where the console shows it. ANCHA_SERVER_URL, server.url in ancha.yaml or --server-url put the worlds in the workspace instead, and --local keeps a command on this computer. ancha whoami --json shows which workspace commands use. In CI, ANCHA_SERVER_URL and ANCHA_API_KEY replace the login, and ancha run --local --upload keeps the worlds on the runner and sends the results to the workspace. See Hosted workspace and Results in your workspace.
Your own harness
To start the agent yourself, start a world instead of a run:ancha world trace --env <envId> --json shows the calls so far. See World lifecycle. ancha world gen "<description>" --json writes a world file from a description; it needs OPENROUTER_API_KEY. See ancha world gen.
What ancha init writes for coding agents
See
ancha init.
Prompt for your coding agent
Paste this into Claude Code, Codex, Cursor or another coding agent, in the repo of the agent you want to test:Prompt
Discover the CLI
ancha --helpis one page;ancha advancedlists the rest;ancha --help --jsonprints every command and flag as one JSON tree.ancha <command> --helpprints one command’s flags and defaults.ancha schema --jsonprints every schema;ancha docs <topic>prints the bundled guide.- CLI reference documents every command in 0.1.4.
- Errors lists every error code.