Claude Code Computer Use
Run Claude Code as a bounded UI-control agent that observes screenshots, takes one action, re-checks state, and repeats until success or stop conditions.
For browser tasks, follow the browser-control contract for context ownership and authentication. Keep browser automation isolated and headless by default; never attach to personal/default Chrome or use its profile or cookies. Use visible browser automation only when the current task explicitly requests it and a separate task-owned context is verified.
Required loop
- Restate the user goal in one sentence.
- Define a max step budget (default 20).
- For each step, do exactly one UI action.
- After each action, capture a fresh screenshot.
- Verify expected change before continuing.
- Stop on success, ambiguity, or budget exhaustion.
Tool contract to enforce
Require these tool primitives (or closest equivalents):
screenshot()click(x,y)/double_click(x,y)type(text)/key(combo)scroll(delta)- Optional:
ocr(region)/accessibility_tree()
Never take multiple UI actions in a single reasoning step.
Safety policy
- Allowlist app/site scope before starting.
- Ask before destructive actions (delete, send, purchase, publish, submit).
- If target is unclear for 2 consecutive steps, pause and ask human.
- Log every step with: intention, action, result.
Claude Code invocation pattern
Use non-interactive Claude Code mode for deterministic logs:
claude --print --permission-mode bypassPermissions "<task prompt>"
Task prompt template:
You are controlling a UI via tools.
Goal: <goal>
Allowed scope: <apps/sites>
Max steps: <N>
Rules:
- One action per step.
- After each action, screenshot and verify.
- If uncertain for 2 steps, stop and ask.
- Ask before destructive actions.
Return a step log and final status: success | blocked | needs-human.
Completion criteria
Declare completion only when:
- Goal state is visible in screenshot evidence, or
- You are blocked and provide the exact blocker + required human input.
Always return concise evidence:
- Final status
- Last 3 step logs
- Screenshot/file references (if available)