Skip to main content
prompt GP ChatGPT

code_as_policy — Claude Code prompt for robot control

The code_as_policy Claude Code prompt defines how an agent controls a robot through its generated Robot API. The agent runs Python programs, checks tool results and inspects images before dependent actions.

MIT ★ 488 updated 2026-11-15

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/commands/code_as_policy.md
Open on GitHub

What code_as_policy does

The prompt directs the agent to control a robot through registered tools called from ordinary Python programs. It checks each call’s result, preserves the full receipt and uses returned data to verify conditions before taking dependent actions.

When the next step requires judging a new image, the program stops. The agent opens the image and decides what to run next. Robot episodes and files persist across scripts, but Python variables do not. After a connection loss, control must stop; actions must not be retried blindly.

The prompt forbids bypassing the Robot API with low-level libraries, service requests or shell commands. It also limits process termination to computations started by the agent.

What it helps with

  • control a robot through Python and registered tools
  • check tool feedback before dependent actions
  • pause a script to inspect new images
  • preserve the complete result of a robot call
  • avoid replaying actions after connection loss

Example prompts for the agent

  • Control the robot through the Robot API and check each action's result.
  • Inspect the new image, then decide on the next step.
  • Write and run a Python program to control the robot through its registered tools.

How to install code_as_policy

Manually: put the files in place

.claude/commands/code_as_policy.md

Questions about code_as_policy

How do I install code_as_policy in Claude Code?

Save the prompt as .claude/commands/code_as_policy.md.

What does code_as_policy do?

It sets rules for controlling a robot through Python programs that call its Robot API. The agent checks tool results and pauses dependent actions when it needs to assess a new image.

What does code_as_policy need to work?

It requires a generated Robot API, registered robot tools and the ability to write and run Python scripts in scratch.

Source text

code_as_policy.md · MIT
Control the robot through ordinary programs using the generated Robot API.
Use your native terminal, file editing and image-reading tools. When list_skills
and read_skill are declared, use them directly to discover and read skills; their
results expose the paths and Markdown text without a Python wrapper. Robot
observations, actions and task completion use the registered tools through code.
Tool names in prompts and skills are operation labels; consult the generated
schemas for exact names and arguments.

Write and run Python scripts in scratch. A one-call program is valid. Freely
calculate, import libraries, define helpers, branch and iterate. Combine operations
when their dependencies are already established and their continuation conditions
can be checked in code. You need not build a controller for the whole task.
Calls wait for completed feedback, even with background executor jobs.

Manage only computation processes you started. To stop a slow local computation,
prefer the native terminal tool's cancellation mechanism for its exact returned
session or job. If cancellation requires a signal, use the specific PID recorded
when you launched it and verify that it still belongs to that computation.
Do not use broad pkill/killall matches such as python or python3, or signal
shared process groups, harness services or other tasks. Your working directory
does not restrict which processes a kill command can affect. If ownership is
unclear, do not kill it. Stopping a script does not cancel robot actions already
submitted; inspect actual state before continuing and never replay them blindly.

Print each robot call's complete result with print(result). This emits JSON with
data (the full original tool payload), images (ordered file paths) and call_id.
Do not substitute a field-selected summary for the receipt. Typed properties
such as result.feedback and result.remaining_steps help code check conditions;
print(result) preserves all raw fields regardless of those projections.
result.state contains progress only; full arm/device measurements remain in
result.data["state"] when returned. Missing typed fields are None, not success
or zero. A stored receipt describes its own state version and snapshot.
For long output, save str(result) to a separate JSON file in scratch, print its
path and read omitted portions with native file tools if output is truncated.
Do not repeat a robot action to recover its output.

Check completed feedback before dependent actions. Arrival and budget checks do
not establish object identity, attachment, contact effect or release support.
When the next action needs your interpretation of new images, end the current
script after exposing its receipt. Open the relevant returned images with your
native reader, then decide and write the next program. Image paths do not display
images, and printing inside a running program does not pause it for your judgment.
Stop a dependent sequence when its helper reports failure or an uncovered state.
Use loops when available evidence supports continuation. Preserve the same
physical verification requirements as direct tool calling.
Use reported camera order and snapshot_id to identify the images. Reuse returned
views when sufficient; obtain new observations when the scene changed or evidence
is missing. Python variables and unprinted values are not model context.

Files and the robot episode persist across scripts; Python variables do not.
An exception can follow partial physical execution. Catch ToolCallError to print
or save error.result before exiting; inspect actual state before recovery.
Do not blindly replay a failed script. Do not inspect simulator internals,
privileged object state, service processes or implementation sources. Do not
bypass the registered robot API with low-level control libraries, service
requests or shell commands. Connection loss is uncertain execution: stop control
and report it, never retry.

© Open-RUA · MIT · Open-RUA/uni-robot-agent

Similar prompts

Prompts catalog →
api-rate-limit-policy Samuel Berthe api-rate-limit-policy — a skill for Claude Code, Codex, Cursor, and other agents that designs the rate-limit policy a public API publishes to consumers: metering models, tier quotas, headers, and 429 behavior. CX Codex +1 10,400installs api-versioning-policy Samuel Berthe api-versioning-policy defines an API versioning and deprecation policy covering breaking changes, notice windows, and sunset timelines. Built for teams rolling out /v2 or deprecating endpoints. CX Codex +1 10,100installs cmux-socket-policy manaflow-ai The cmux-socket-policy skill sets threading, focus, and relay rules for cmux socket and CLI work. Use it when adding commands or automation that could change app focus. CX Codex +1 5,000installs platform-policy-rule-generate forcedotcom platform-policy-rule-generate — a skill for Claude Code and five other platforms that authors and deploys a PolicyRuleDefinitionSet + PolicyRuleDefinition pair for Data Cloud and Data Governance access policies. CX Codex +1 4,300installs iam-helper-for-policy-simulator official google The iam-helper-for-policy-simulator skill replays recent access logs against a proposed IAM policy, so you see who loses access before the change goes live. CX Codex +1 3,800installs privacy-policy phuryn Skill drafts a detailed privacy policy accounting for GDPR, CCPA, and other regulations. Use it when building a new product, updating data protection docs, or preparing for compliance audits. CX Codex +1 3,800installs

From the same set41

The whole set →
meta_skill The meta_skill Claude Code prompt guides agents through finding existing skills and recording lessons backed by a task. It comes into play when an agent needs to add a lesson or revise a skill. GP ChatGPT ★ 488repo stars observer The observer Claude Code prompt inspects published observations for an assigned visual question. It reports visible evidence and flags uncertainty or a useful next observation. GP ChatGPT ★ 488repo stars common The common prompt for Claude Code and ChatGPT guides agents through physical robot tasks using observations and environment instructions. It sets checks for state changes and recovery after uncertain execution. GP ChatGPT ★ 488repo stars hybrid_decision The hybrid_decision prompt for Claude Code reviews an agent’s proposed action against observations and execution history. It selects whether to continue, stop, or use an allowed correction, then sends one submit_review call. GP ChatGPT ★ 488repo stars clean The clean Claude Code prompt controls a robot arm through motion and observation commands. It guides instruction execution and checks results between actions. GP ChatGPT ★ 488repo stars system The system Claude Code prompt guides control of a dual-arm ARX X5 robot in a live RoboDojo episode. The agent consults skills, observes the scene, and checks action results before proceeding. GP ChatGPT ★ 488repo stars robodojo-return-to-start The robodojo-return-to-start Claude Code skill applies RoboDojo’s finishing posture after the general return procedure. It restores used empty arms to their initial poses and checks their clearance from the result. CX Codex +1 ★ 488repo stars deformable-material The deformable-material Claude Code skill moves selected regions of flexible material and checks their shape after release. It applies when deformation makes rigid-object poses or earlier contact coordinates unreliable. CX Codex +1 ★ 488repo stars

Project sponsors

Companies that keep this analytics open