Enable `--restricted` for untrusted repos, CI, and shared agents
Claude Code v2.1.248 adds--restricted/CLAUDE_CODE_RESTRICTED=1, stripping command/code tools and WebFetch unless named in --tools, keeping file tools in-cwd, refusing bypassPermissions, and ignoring user/project/local settings. Pair it with agent experimental.cacheTtl and labeled self-hosted runners.Why this loop
v2.1.248’s --restricted flag is the concrete control for sessions that must not run commands/code or WebFetch, cannot bypassPermissions, and must ignore user/project/local settings while still using in-cwd file tools. Use it as the default for untrusted checkouts, PR bots, and shared machines so a repo cannot weaken policy via local settings. Long-running custom agents should set frontmatter experimental.cacheTtl to "5m" or "1h" when no subagent TTL is configured; this release also fixed hourly prompt-cache misses after OAuth refresh and --resume cache misses when ScheduleWakeup changed in overage. Self-hosted fleets should stop registering as hostname and pass --client-label / SELF_HOSTED_RUNNER_CLIENT_LABEL. After upgrade, /doctor and /status now explain managed-settings load failures (Bedrock/Vertex/third-party or custom ANTHROPIC_BASE_URL). /web-setup now warns when the GitHub CLI token lacks workflow scope. Do not infer the two omitted changelog items.
Proposed actions
- For untrusted checkouts and CI, start Claude Code with
claude --restricted(orCLAUDE_CODE_RESTRICTED=1). Do not usebypassPermissions. Only restore command/code tools orWebFetchby naming them in--tools. - In each custom agent’s frontmatter, set
experimental.cacheTtl: "1h"for long-lived agents orexperimental.cacheTtl: "5m"for short ones so per-agent prompt-cache TTL applies when no subagent TTL is configured. - Register self-hosted runners with a stable label instead of hostname:
claude self-hosted-runner --client-label team-ci-linux(orSELF_HOSTED_RUNNER_CLIENT_LABEL=team-ci-linux). - After installing v2.1.248, run
/doctorthen/statusand fix the new server-managed settings load-failure line if present (Bedrock/Vertex/third-party provider or customANTHROPIC_BASE_URL). - Re-run
/web-setupand, if warned, grant the GitHub CLI token theworkflowscope so pushes to very large repositories are not rejected.
Agent prompt
Paste into your agent or query via MCP (get_agent_prompt) — free, no extra AI costPaste into Claude Code / CLAUDE.md task
DevAgentRadar → Claude Code
You are helping me adopt a real coding-assistant change. Work only from the facts below. Do not invent features.
Context
Assistant: Claude Code
Proposal: Enable --restricted for untrusted repos, CI, and shared agents
Summary: Claude Code v2.1.248 adds --restricted/CLAUDE_CODE_RESTRICTED=1, stripping command/code tools and WebFetch unless named in --tools, keeping file tools in-cwd, refusing bypassPermissions, and ignoring user/project/local settings. Pair it with agent experimental.cacheTtl and labeled self-hosted runners.
Primary source: https://github.com/anthropics/claude-code/releases/tag/v2.1.248
Why it matters
v2.1.248’s --restricted flag is the concrete control for sessions that must not run commands/code or WebFetch, cannot bypassPermissions, and must ignore user/project/local settings while still using in-cwd file tools. Use it as the default for untrusted checkouts, PR bots, and shared machines so a repo cannot weaken policy via local settings. Long-running custom agents should set frontmatter experimental.cacheTtl to "5m" or "1h" when no subagent TTL is configured; this release also fixed hourly prompt-cache misses after OAuth refresh and --resume cache misses when ScheduleWakeup changed in overage. Self-hosted fleets should stop registering as hostname and pass --client-label / SELF_HOSTED_RUNNER_CLIENT_LABEL. After upgrade, /doctor and /status now explain managed-settings load failures (Bedrock/Vertex/third-party or custom ANTHROPIC_BASE_URL). /web-setup now warns when the GitHub CLI token lacks workflow scope. Do not infer the two omitted changelog items.
Suggested actions
- For untrusted checkouts and CI, start Claude Code with
claude --restricted(orCLAUDE_CODE_RESTRICTED=1). Do not usebypassPermissions. Only restore command/code tools orWebFetchby naming them in--tools. - In each custom agent’s frontmatter, set
experimental.cacheTtl: "1h"for long-lived agents orexperimental.cacheTtl: "5m"for short ones so per-agent prompt-cache TTL applies when no subagent TTL is configured. - Register self-hosted runners with a stable label instead of hostname:
claude self-hosted-runner --client-label team-ci-linux(orSELF_HOSTED_RUNNER_CLIENT_LABEL=team-ci-linux). - After installing v2.1.248, run
/doctorthen/statusand fix the new server-managed settings load-failure line if present (Bedrock/Vertex/third-party provider or customANTHROPIC_BASE_URL). - Re-run
/web-setupand, if warned, grant the GitHub CLI token theworkflowscope so pushes to very large repositories are not rejected.
Config surfaces this release may change
- subagent definitions (high confidence) — check your repo before applying
- hooks (high confidence) — check your repo before applying
- background and headless runs — check your repo before applying
- settings files — check your repo before applying
- MCP servers — check your repo before applying
- skills — check your repo before applying
After you finish
Do not report this as applied to DevAgentRadar. You cannot write the visitor's loop.
Tell the human: open https://devagentradar.com/proposals/claude-code-v2-1-248-enable-restricted-for-untrusted-repos-ci-and-shared and mark Applied, Skipped, or Failed. Proposal id: d62c89ae-911b-4c73-a279-0b9b441deb46
Your job
- Restate the change in one sentence.
- Propose a minimal plan for my repo (or a throwaway pilot).
- Implement only what I approve; prefer small diffs and tests.
- Call out risks (permissions, breaking APIs, cost).
Start by confirming you understood the proposal.
Your loop
This browser · no sign-in · not shared as “you”After you run the prompt
Only you can mark this. Agents cannot write your loop.
Your decision stays on this device. A public tally appears after a few votes.