AI Coding

Claude Code agent-loop control surface checklist

Before using Claude Code as a general worker, inspect max tool-use turns, spend caps, hooks, permissions, sandboxing, settings scope, and review handoff.

June 28, 2026·7 min read·1,519 words

Last verified: 2026-06-28.

In short: Treat the Claude Code agent loop as an operating control surface, not just a smarter chat box. Before a team expands Claude Code from coding assistant to general worker, inspect max tool-use turns, spend caps, hooks, permissions, sandboxing, settings scope, final result logging, and the human review handoff.

A current Every article about Claude Code and OpenClaw is a useful lead because it reflects how people are comparing coding-agent harnesses right now. It is not enough evidence to call Claude Code the best OpenClaw alternative, and Toolhalla is not making that claim here. The stronger source base is Anthropic's own Claude Code documentation: the Agent SDK agent-loop docs, security docs, and settings docs.

Use this checklist when Claude Code moves from "help me edit this repo" to "go perform a bounded task with tools." That move changes the review question. The important question is no longer only whether the model can produce good code. It is whether the run has boundaries that a team can inspect before, during, and after execution.

For adjacent Toolhalla controls, pair this with the agent write-permission UX checklist, the coding-agent benchmark methodology checklist, the prompt-injection deployment boundary checklist, and the AI agent sandbox guide.

What the Claude Code agent loop actually does

Anthropic describes the Claude Code Agent SDK as a way to embed Claude Code's autonomous agent loop into applications. In plain terms, the loop receives a prompt, Claude evaluates the task, asks to use tools when needed, the application executes approved tool calls, tool results are fed back to Claude, and the cycle repeats until there are no more tool calls. The run then produces a final result message.

That shape is powerful because it turns a coding assistant into a worker that can inspect files, run commands, edit code, and continue from tool results. It is also why the loop needs controls. A chat reply can be wrong. A tool-using loop can spend money, touch files, call network commands, or continue down a bad path unless the harness stops it.

The practical checklist starts with one sentence: define what the loop is allowed to do before the first tool call happens.

Bound the run before you trust the output

Start with turn limits. The Agent SDK exposes max_turns in Python and maxTurns in TypeScript. The docs say this counts tool-use turns only, not every message. That detail matters for planning: a task with many small command/file cycles can consume turns quickly, while discussion-only messages do not count the same way.

Next add a spend cap. The SDK exposes max_budget_usd and maxBudgetUsd, and the docs recommend setting a budget as a good production default. A budget cap is not an editorial review. It is a damage limiter for tasks that accidentally loop, call expensive tools, or require more model work than expected.

Then decide how the run stops. A useful worker handoff should specify:

  • the maximum tool-use turns
  • the maximum spend
  • any wall-clock timeout enforced by the wrapper
  • what final result message is saved
  • where logs, diffs, and command output are retained
  • what counts as success, partial success, or failure

If nobody can answer those questions, the team does not yet have an agent run. It has an open-ended conversation with write tools nearby.

Gate tools, writes, and network access

Permissions are the second control surface. Anthropic's security docs say Claude Code is read-only by default and requires explicit approval for sensitive or modifying actions. They also describe sandboxing, scoped write access, prompt-injection protections, and default approval requirements for network fetch commands.

Do not translate that into "safe by default for our workflow." Read-only defaults and approvals reduce risk, but they do not remove the need to decide which tools belong in a given run. For a repository task, the allowed surface may be read files, edit files under the working directory, run tests, and report a diff. For a customer-support task, the same defaults may be insufficient because the input channel can contain hostile instructions and the downstream systems may be more sensitive.

Hooks are the review point between the model's intent and the tool execution. The Agent SDK docs describe hooks as a way to intercept, modify, or block tool calls before execution. Teams should use that layer for policy that should not depend on the model remembering instructions: block writes outside allowed paths, require approval for package installation, stop network fetches unless the task explicitly needs them, and record high-risk calls for later review.

A good permission review asks:

  • Which tools are enabled for this run?
  • Which paths are readable and writable?
  • Can the agent write outside the working directory or subfolders?
  • Which commands require explicit human approval?
  • Are network commands blocked, approved case by case, or always allowed?
  • Are secrets excluded from prompt context and tool output?
  • Can a hook block a tool call even if the model asks confidently?

If the answer is "the operator will notice," the control belongs in the harness, not in wishful thinking.

Configure at the right layer

Settings are easy to under-review because they look like setup, not runtime behavior. Anthropic's settings docs describe hierarchical scopes: managed, command-line, local, project, and user. Managed settings have the highest precedence and cannot be overridden.

That precedence model matters for teams. A project setting can standardize permissions, hooks, and MCP server configuration for collaborators. A local setting can preserve personal overrides. A command-line flag can be useful for a one-off run. A managed setting is the layer for organization-level rules that should survive individual preference.

Before adopting Claude Code as a broader worker, write down which layer owns each decision:

  • organization rules: managed settings
  • repeatable team workflow: project settings
  • personal environment details: local or user settings
  • one-off run constraints: command-line flags or wrapper options
  • app-level orchestration: Agent SDK configuration

The anti-pattern is mixing durable safety policy with ad hoc local preference. If a team needs a rule for all agent runs, it should not live only in one person's shell history.

Review handoff: what a human must receive

The final result message is not enough by itself. A coding worker should hand back evidence that a reviewer can inspect without reconstructing the run from memory.

For code work, the handoff should include the diff, tests or commands run, failures that remain, files touched, and any skipped checks. For operations work, add inputs read, external systems touched, approvals requested, and rollback instructions. For higher-risk work, include trace or hook logs showing blocked calls and approved calls.

Keep one human owner for the review. Shared ownership is how agent output slips through because everyone assumes someone else checked the diff. The owner does not need to distrust every generated line, but they do need to verify that the task boundary, tool use, and final state match the request.

Buyer and team checklist

Ask these questions before expanding Claude Code beyond coding assistance:

1. What task class are we authorizing: repo edit, test run, ticket triage, data cleanup, or external workflow?

2. What are the max tool-use turns and spend cap for that class?

3. Which tool calls can execute without approval?

4. Which tool calls always require approval?

5. Are writes limited to the working directory and approved subfolders?

6. Are network fetch commands approval-required by default in our setup?

7. Which hooks can block or modify tool calls before execution?

8. Which settings layer owns team policy, and which layer is only personal preference?

9. Where are final result messages, logs, diffs, and test output stored?

10. Who reviews the result, and what rollback path exists if the agent was wrong?

This is also how to read vendor claims. A demo that shows an agent completing a task is useful. A production-ready worker should also show the control surface around the loop.

FAQ

Does max_turns count every message?

No. Anthropic's Agent SDK docs say max_turns and maxTurns count tool-use turns only. Treat that as a tool-loop limiter, not a complete conversation-length limiter.

Is sandboxing enough?

No. Sandboxing limits blast radius, and Claude Code security docs describe sandboxing and scoped write access as important controls. You still need permissions, hooks, secrets policy, network approval, logs, tests, and human review.

Should teams commit project settings?

Sometimes. Anthropic's settings docs frame project scope as useful for team-shared settings such as permissions, hooks, and MCP servers. Commit shared policy only after reviewing what it enables, and keep local secrets or personal overrides out of the shared layer.

Sources and caveats

Primary sources for the checklist are Anthropic's Agent SDK agent-loop documentation, Claude Code security documentation, and Claude Code settings documentation. The Every article, "Claude Code Is the OpenClaw Alternative You Already Have", is used only as a timely search-intent lead because the accessible public article is partly gated and does not independently prove reliability, pricing, or superiority claims.

Toolhalla has not run a fresh Claude Code benchmark for this article, has not tested the Every comparison, and is not publishing pricing claims here. The recommendation is narrower: before treating a coding agent loop as a general worker, inspect the controls that bound the loop.

Frequently Asked Questions

Does `max_turns` count every message?
No. Anthropic's Agent SDK docs say max turns and maxTurns count tool-use turns only. Treat that as a tool-loop limiter, not a complete conversation-length limiter.
Is sandboxing enough?
No. Sandboxing limits blast radius, and Claude Code security docs describe sandboxing and scoped write access as important controls. You still need permissions, hooks, secrets policy, network approval, logs, tests, and human review.
Should teams commit project settings?
Sometimes. Anthropic's settings docs frame project scope as useful for team-shared settings such as permissions, hooks, and MCP servers. Commit shared policy only after reviewing what it enables, and keep local secrets or personal overrides out of the shared layer.

🔧 Tools in This Article

All tools →

Related Guides

All guides →
#Claude Code#AI coding agents#agent loop#agent security#developer tools#agent permissions