{"slug": "how-to-let-claude-code-codex-or-cursor-build-a-robot-simulation", "title": "How to let Claude Code, Codex or Cursor build a robot simulation", "summary": "A developer walkthrough shows how to wire the open-source Alloy physics engine into coding agents like Claude Code, Codex and Cursor so they can build and run robot simulations autonomously. Alloy ships agent-oriented docs and an MCP server exposing scene, build, run, state, check and render operations, and every error carries a message plus a fix so agents can self-correct. The author recommends calling sim.check()[\"ok\"] after each run, since a frozen or broken world can still look calm in a render.", "body_md": "Coding agents are good at writing Python, but robot simulation is a hard place for them: scenes fail in confusing ways, the first run compiles for minutes, and a simulation that quietly blew up can look like a success. This walkthrough sets up [Alloy](https://github.com/argonrobotics-ai/alloy), an open-source physics engine for robot learning, so an agent like Claude Code, Codex or Cursor can build and run simulations on its own, either through plain Python or through an MCP server.\n\n```\npip install alloy-engine\n```\n\nThe package ships its docs, examples and a quick start written for agents. An agent can find them itself:\n\n```\npython -m alloy.docs          # prints three paths: the docs, the examples and AGENTS.md\npython -m alloy.docs agents   # prints AGENTS.md, a quick start for agents\n```\n\nA good first prompt is simply: \"Install alloy-engine, run `python -m alloy.docs agents`, and build me a scene where a robot arm pours water into a cup.\"\n\nAlloy includes an MCP server, so the agent gets operations such as `scene`, `build`, `run`, `state`, `check` and `render` as tools instead of writing code. For Claude Code:\n\n```\nclaude mcp add alloy -- alloy mcp\n```\n\nOther MCP clients (Cursor, Codex and so on) take the same command, `alloy mcp`, as a local stdio server.\n\nTwo habits make agent-built simulations reliable: read the error's fix, and check the world after every run.\n\n``` python\nimport alloy\n\nscene = alloy.Scene(dt=0.01)\nscene.add_ground()\nscene.add_box(\"block\", size=(0.05, 0.05, 0.05), pos=(0, 0, 0.1))\ntry:\n    scene.add_box(\"thin\", size=(0.05, 0.05))          # a typical agent mistake\nexcept alloy.AlloyAPIError as e:\n    print(e.message)\n    print(e.fix)\nsim = alloy.build(scene, device=\"cpu\")\nsim.run(0.5)\nprint(sim.check()[\"ok\"], round(float(sim.state(world=0)[\"block.pos\"][2]), 3))\nsize needs 3 finite numbers, got (0.05, 0.05)\npass size=(..., ..., ...) in m\nTrue 0.025\n```\n\nEvery error carries a `message` and a `fix` that names what to pass, so the agent can correct itself without guessing. After the run the block rests on the ground with its centre at 0.025 m, and `sim.check()[\"ok\"]` is `True`.\n\n`sim.check()[\"ok\"]` after every run: a frozen, broken world looks calm in a render.", "url": "https://wpnews.pro/news/how-to-let-claude-code-codex-or-cursor-build-a-robot-simulation", "canonical_source": "https://dev.to/pranay_argon/how-to-let-claude-code-codex-or-cursor-build-a-robot-simulation-4fnk", "published_at": "2026-11-20 08:01:08+00:00", "updated_at": "2026-11-20 08:12:38.777518+00:00", "lang": "en", "topics": ["robotics", "ai-agents", "agent-protocols", "ai-tools", "developer-tools"], "entities": ["Alloy", "Claude Code", "Codex", "Cursor", "argonrobotics-ai"], "also_reported_by": [], "takeaway": "Expose a simulation engine to coding agents through an MCP server with structured errors carrying a message and a fix, and gate every run on sim.check()[\"ok\"] because a frozen world still renders cleanly.", "recommendation": {"advice": "Give coding agents tool-level simulation operations and errors with an explicit fix field, then verify each run with sim.check()[\"ok\"] before trusting the result.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/how-to-let-claude-code-codex-or-cursor-build-a-robot-simulation", "markdown": "https://wpnews.pro/news/how-to-let-claude-code-codex-or-cursor-build-a-robot-simulation.md", "text": "https://wpnews.pro/news/how-to-let-claude-code-codex-or-cursor-build-a-robot-simulation.txt", "jsonld": "https://wpnews.pro/news/how-to-let-claude-code-codex-or-cursor-build-a-robot-simulation.jsonld"}}