真源:/home/box/archives/org/2026-09-17-claude-code-unattended.md · 抓取日 2026-09-17 · 正文由 scripts/sync_reports.py 从 md sync,勿手改本页 SYNC 区当真源
- 调研日(Asia/Shanghai):2026-09-17
- 口径:只记官方 docs / changelog 里出现过的 flag 与 JSON key;没找到写「不知道」,不发明 workaround。
- Grok CLI 一次性 live pass:
~/.grok/bin/grok --no-auto-update --reasoning-effort xhigh -m grok-4.6 --always-approve,exit 0(约 465s,2026-09-17 00:32 CST)。其后主证据以官方页为准。 - 舰队约束(非 Claude 官方):不 merge PR,除非用户明确说 merge;prod deploy 与花钱必须人;repo 代码在 CA 配额充足时优先 Cursor Cloud Agent。
Sources (path/url + date)
官方(优先)
次级(已标注)
| 页 | URL | 日期 / 等级 |
|---|---|---|
| GitHub README | https://github.com/anthropics/claude-code | 抓取 2026-09-17;安装说明,无 YOLO / bypass 细节 |
Issue: Add --yolo alias | https://github.com/anthropics/claude-code/issues/34467 | 次级;标题即证明 YOLO 不是官方 flag |
Issue: [Bug] YOLO mode prompting | https://github.com/anthropics/claude-code/issues/42898 | 次级;社区把 skip-permissions 叫 YOLO |
| Issue: Notifications in auto-accept/yolo | https://github.com/anthropics/claude-code/issues/30233 | 次级;closed 2026-03-31 |
1 Permission switches (exact flags/keys + official quotes)
官方 没有 名叫 YOLO / --yolo 的 CLI flag 或 settings key。官方 skip-all 是 --dangerously-skip-permissions 与 bypassPermissions。What's New W13(2026-03-23–27)把 auto mode 写成 “the middle ground between approving every file write and running with --dangerously-skip-permissions”。GitHub #34467 是社区请求把 --yolo 做成 alias(次级)。
1.1 CLI flags(CLI reference,抓取 2026-09-17)
| Flag | 官方含义(摘) |
|---|---|
--permission-mode <mode> | Begin in a specified permission mode. Accepts default, acceptEdits, plan, auto, dontAsk, bypassPermissions, or manual as an alias for default(manual 需 v2.1.200+)。Overrides defaultMode from settings. -p 未指定时内置起点是 default。 |
--dangerously-skip-permissions | “Skip permission prompts. Equivalent to --permission-mode bypassPermissions.” |
--allow-dangerously-skip-permissions | “Add bypassPermissions to the Shift+Tab mode cycle without starting in it.” |
--allowedTools / --allowed-tools | “Tools that execute without prompting for permission.” 语法同 permission rules。限制可用工具用 --tools,不是这个 flag。 |
--disallowedTools / --disallowed-tools | Deny rules。裸工具名会从 context 移除;Bash(rm *) 只拦匹配调用。 |
--permission-prompts none | v2.1.259+。“Set who answers permission prompts in print mode… Pass none when nobody can answer, and Claude Code denies them instead.” |
--permission-prompt-tool | 非交互里用 MCP 工具回答权限提示。 |
--restricted | v2.1.248+。评测/共享机;**refuses bypassPermissions**,且不读 user/project settings。 |
--enable-auto-mode | Removed in v2.1.111。改用 --permission-mode auto。 |
官方推荐的无人值守容器形(permission-modes Common setups):
claude -p "<prompt>" --dangerously-skip-permissions
隔离要求原文:“Required: a container, VM, or the sandbox runtime; on Linux and macOS, run it as a non-root user”。同一段:“In this -p run, the few calls that would still prompt are denied instead”。
CI 精确 allowlist 形:
claude -p "run the test suite" --permission-mode dontAsk --allowedTools "Bash(npm test)" "Read"
Hands-off(仍有 classifier)形:
claude --permission-mode auto
# 或 -p:
claude -p "fix all lint errors" --permission-mode auto
# 无人回答权限时(v2.1.259+):
claude -p "Update the dependency pins and run the tests" --permission-mode auto --permission-prompts none
更少 prompt、不要 classifier 时:Manual + sandbox auto-allow(claude --permission-mode default,然后 /sandbox 选 auto-allow,或 sandbox.enabled: true;sandbox.autoAllowBashIfSandboxed 默认 true)。
1.2 settings.json keys(settings-reference,抓取 2026-09-17)
没有 顶层 key 叫 permissionMode。正确嵌套是 permissions.defaultMode。
{
"permissions": {
"allow": ["Bash(npm run *)", "Bash(git commit *)"],
"ask": ["Bash(git push *)"],
"deny": ["Read(./.env)", "Read(./.env.*)", "Read(./secrets/**)", "Bash(curl *)"],
"additionalDirectories": ["../docs/"],
"blockReadsOutsideWorkingDirectories": true,
"defaultMode": "auto",
"disableBypassPermissionsMode": "disable"
},
"disableAutoMode": "disable",
"skipDangerousModePermissionPrompt": true,
"skipAutoPermissionPrompt": true,
"sandbox": {
"enabled": true,
"autoAllowBashIfSandboxed": true
}
}
| Key | 类型 / 取值 | 官方要点 |
|---|---|---|
permissions.allow | string[] | 匹配则不问。规则格式 Tool 或 Tool(specifier)。项目 .claude/settings.json 的 allow 要 workspace trust 才生效。 |
permissions.ask | string[] | 即使 acceptEdits / bypass 也仍 prompt。dontAsk 下匹配则 deny 而不是问。 |
permissions.deny | string[] | 所有 mode 都拦,包括 bypassPermissions。求值顺序:deny → ask → allow;specificity 不改顺序。--allowedTools 不能 覆盖 deny。 |
permissions.defaultMode | "default" | "acceptEdits" | "plan" | "auto" | "dontAsk" | "bypassPermissions" | "manual" | **auto 与 bypassPermissions 从 project/local 文件不生效**,要写 ~/.claude/settings.json 或 managed。Cloud session 只认 acceptEdits/plan/default/auto。 |
permissions.disableBypassPermissionsMode | "disable" | 拒绝 --dangerously-skip-permissions。 |
disableAutoMode / permissions.disableAutoMode | "disable" | 从 Shift+Tab 去掉 auto。 |
permissions.blockReadsOutsideWorkingDirectories | bool | v2.1.257+。所有 mode(含 bypass)文件工具拒读工作目录外。 |
skipDangerousModePermissionPrompt | bool | User/local/managed。跳过首次 bypass 责任对话框。仓库不可替你跳。 |
sandbox.enabled | bool | macOS / Linux / WSL2。 |
sandbox.autoAllowBashIfSandboxed | bool,默认 true | 沙箱内 Bash 不问(deny 与 content-scoped ask 仍生效)。 |
autoMode.environment / autoMode.allow / soft_deny / hard_deny | object | 告诉 classifier 信任哪些 repo/bucket/domain。 |
规则求值原文(permissions):“Rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity doesn't change the order.”
allow 对 bypass 无效 原文(permission-modes):“Allow rules have no effect in bypassPermissions.” 所以 --allowedTools 约束不了 bypass;要拦工具用 deny / --disallowedTools。
1.3 Permission modes 对照(permission-modes,抓取 2026-09-17)
| Mode | 不问就跑什么 | 官方 “Best for” |
|---|---|---|
default(UI:Manual) | 只读 | Reviewing every action / sensitive |
acceptEdits | 读 + 工作目录内文件编辑 + mkdir/touch/rm/rmdir/mv/cp/sed | Iterating locally |
plan | 读;auto 可用时 classifier 批准的命令 | Explore before changing |
auto | 几乎一切,classifier 后台审 | Long tasks, reducing prompt fatigue |
dontAsk | 读 + 已 allow 的工具;其余本会 prompt 的 直接 deny | Locked-down CI and scripts |
bypassPermissions | 几乎一切 | Isolated containers and VMs only |
Pro/Max/Team 交互会话内置起点:auto(W32,Starting August 14, 2026;CLI 需 v2.1.228+ macOS/Linux/WSL,Windows v2.1.233+)。**claude -p / Agent SDK 内置仍是 default(Manual)**,所以脚本必须显式传 --permission-mode。
交互切 mode:CLI Shift+Tab。dontAsk 不进 cycle,只能 --permission-mode dontAsk。bypassPermissions 只有启动时用了 bypass 相关 flag / user defaultMode 才进 cycle。
任何 mode 都不会 auto-approve 的动作(含 bypass):explicit ask 规则;组织设为 ask 的 connector;AskUserQuestion 与 requiresUserInteraction MCP;针对 critical path 的 rm/rmdir(无 allow / PreToolUse "allow" 能批);跨 session messaging 保护;blockReadsOutsideWorkingDirectories 打开时的目录外读。
Protected paths(.git、.claude、.bashrc、.mcp.json 等)除 bypass(及部分 plan+bypass 交互)外永不 auto-approve。Critical path rm 在 bypass 下仍会 问人。
2 Headless / print / continue / notify
2.1 非交互 / print
官方叫 print mode,flag 是 -p / --print(headless + CLI reference,抓取 2026-09-17):
claude -p "Find and fix the bug in auth.py" --allowedTools "Read,Edit,Bash"
claude -p "Summarize this project" --output-format json
claude -p "Explain recursion" --output-format stream-json --verbose --include-partial-messages
| 项 | 官方事实 |
|---|---|
--output-format | text(默认)、json、stream-json。没有其它官方值。 |
| json 字段 | 文本在 .result;--json-schema 时结构化在 .structured_output;含 session_id、total_cost_usd。 |
| 退出码 | 成功 0,失败非 0。SIGTERM → 143。 |
--bare | “recommended mode for scripted and SDK calls”;跳过 hooks/skills/plugins/MCP/CLAUDE.md 自动发现。-p 将在未来默认 bare。bare 不读 OAuth/keychain,Anthropic API 要 ANTHROPIC_API_KEY。 |
-p 与 --bg | 互斥。--cloud + 任务描述也互斥;--cloud + session ID + -p 是往已有云 session 排队一条消息然后退出。 |
-p workspace trust | “Trust verification is disabled when running non-interactively with the -p flag”(security)。项目 permissions.allow 在未 trust 时 不用;stderr 会有 this workspace has not been trusted。hooks / .mcp.json 在 -p 仍可能跑——所以脚本建议 --bare 或 --setting-sources user。 |
--max-turns / --max-budget-usd | print only。预算到了停。 |
--permission-prompts none | v2.1.259+。无人值守 scheduled job 官方推荐。 |
2.2 Continue / resume(sessions + CLI,抓取 2026-09-17)
| Flag | 官方行为 |
|---|---|
claude -c / --continue | 当前目录最近一次会话。默认 跳过 -p/SDK//loop 会话;claude -p --continue 才包含它们。v2.1.257+ 可打开已结束的 background session,不能 attach 仍在跑的。 |
claude -r / --resume <id|name|jsonl绝对路径> | 指定会话。跨项目找 ID 需 v2.1.223+。 |
claude --from-pr <n|URL> | 按 PR 过滤 picker。 |
--fork-session | 与 resume/continue 合用,新 session ID。 |
--no-session-persistence | print only,不落盘、不能 resume。 |
Resume 权限 mode:终端 --continue/--resume <id> 会恢复当时 mode,但 **ended in bypassPermissions 或 plan 时不恢复 bypass/plan,要再传 flag。claude -p --resume 按新的 -p 起点(通常 Manual)**,除非同时满足:带 --permission-prompt-tool、不传 --permission-mode/--dangerously-skip-permissions、不 fork、不是 channels——才会在 plan 里 resume(v2.1.246+)。
过夜续跑官方示例(headless):
claude -p "Review this codebase for performance issues"
claude -p "Now focus on the database queries" --continue
session_id=$(claude -p "Start a review" --output-format json | jq -r '.session_id')
claude -p "Continue that review" --resume "$session_id"
/goal 可在 -p 里一次跑到条件满足(goal 页,抓取 2026-09-17):
claude -p "/goal CHANGELOG.md has an entry for every PR merged this week"
/goal 不改 permission mode。无人值守要同时开 auto。Goal 在认证失败 / 余额耗尽 / 上下文溢出 / 模型不可用时会清掉。
2.3 “做完再报我”——官方有什么
没有 名叫 “report when fully done” 的单一官方开关。可组合:
| 机制 | 官方能力 | 局限 |
|---|---|---|
-p 进程退出 + exit code | 脚本/CI 自然“做完” | 不主动推送;stdout 是结果 |
--output-format json | .result + cost | 需自己接 Slack/webhook |
preferredNotifChannel | settings-example 注释:“Ring the terminal bell for notifications, such as a finished task or a waiting permission prompt.” 官方示例值只有 "terminal_bell"。terminal-config:默认仅 Ghostty/Kitty/iTerm2 发桌面通知;其它终端设 terminal_bell。 | 其它合法枚举值 不知道(settings index 只写 “terminal bell or desktop notification”) |
Notification hook | hooks-guide:Claude 等输入/权限时跑。macOS 官方例 osascript -e 'display notification …'。matcher:permission_prompt、idle_prompt(约 60s 无输入)、agent_completed(仅 agent view 打开时)等 | agent_completed 不是任意 -p 结束 |
Stop hook | Claude 每轮结束都 fire,不是“任务全部完成”。可用 prompt-type Stop 判断是否做完 | 连续 block 默认 8 次 cap |
HTTP hook "type": "http" | POST 同一份 JSON 到 URL;allowedHttpHookUrls 可限 URL | 要自己写接收端;不是内置 Slack |
inputNeededNotifEnabled | settings index:“Get a push notification when Claude is waiting on you” | 完整取值/平台细节本次未展开全文 → 部分 不知道 |
agentPushNotifEnabled | settings index:“Let Claude send a push notification to your phone when it decides to” | 同上 |
| Mobile push | What's New W16(2026-04-13–17):“mobile push notifications that ping your phone when Claude needs you” | 是 需要你,不是 做完了 |
| Channels | 把 Telegram/Discord/CI webhook 推进正在跑的 session | research preview;要 session 开着;入站 不是出站 “done” |
| Desktop scheduled tasks | 到点发桌面通知并开新 session | 电脑醒着 + Desktop 开着 |
| Routines | 每次 run 成云 session,可打开看 transcript | 绿状态 ≠ 任务成功:“A green status … does not mean the task in your prompt succeeded.” |
claude -p "…" --cloud <session> | 往已有云 session 排队消息 | 不是完成通知 |
官方 没有 内置 Slack/email/webhook “任务全部完成再推一次” 的产品开关。要出站通知:自己写 Stop/Notification/http hook,或用 -p 的 exit + 脚本。
3 Overnight pipeline (local vs CI vs Cloud Agent) + human gates
3.1 三条官方跑道 + 一条舰队跑道
| 跑道 | 电脑能否睡 | 权限 | 官方定位 | 适合过夜到“可开 PR” |
|---|---|---|---|---|
| 本机 CLI / Desktop Local | 不能。Desktop scheduled tasks:“Tasks only run while the desktop app is running and your computer is awake. If your computer sleeps through a scheduled time, the run is skipped.” /loop 同机。 | 交互 Pro/Max/Team 默认 auto;-p 默认 Manual,必须显式 mode。bypass 仅容器。 | 本地文件、本机工具 | 笔记本合盖会断。Keep computer awake 仍挡不住合盖。 |
| Cloud session / Routines | 能。Routines:“they keep working when your laptop is closed.” | “there is no permission-mode picker and no approval prompts during a run.” Cloud 忽略 settings 里的 bypassPermissions/dontAsk。Cloud 可选 Accept edits / Plan / Auto。 | 从 GitHub clone;推 claude/ 前缀分支 | 官方 overnight 首选形态之一 |
GitHub Actions anthropics/claude-code-action@v1 | runner 上跑,与笔记本无关 | 用 claude_args 传 --allowedTools / --permission-mode dontAsk 等 | @claude 评论或 prompt 自动化 | 适合 review / 按 issue 开 PR;不替代人 merge |
| Cursor Cloud Agent | 与笔记本无关 | Cursor 产品,非 Anthropic 文档 | 舰队偏好(CA 配额充足时 repo 代码优先 CA) | 本备忘不把它写成 Claude 官方能力 |
Routines vs Desktop vs /loop 官方表(desktop-scheduled-tasks):Cloud 最短间隔 1 hour;Desktop//loop 1 minute;Cloud 不需机器开机;Desktop 要开机且 app 开着。
3.2 推荐过夜形状(官方能力 + 舰队门)
目标 = 早上有可审 PR / 云 session 产物,不是线上已发。
- Repo 代码、CA 配额够:用 Cursor Cloud Agent(舰队,非 Claude 官方)。人早上审 diff,不 merge。
- **要 Claude 云、笔记本可睡:Routines 或
claude --cloud "…"**(code.claude.com cloud + routines,抓取 2026-09-17)。prompt 写死成功标准(测试绿、开 draft PR、不要 merge、不要 prod)。环境用 Trusted network,去掉不需要的 connectors(“Claude can use every tool from an included connector, including writes, without asking”)。 - **必须摸本机文件:Desktop scheduled task 或本机
claude -p+ auto + sandbox**。合盖会 skip。不要用 bypass 除非独立 VM。 - **CI 重复活(lint/review/日报告):GitHub Actions +
dontAsk+--allowedTools精确名单**。prompt模式结果默认在 workflow log,不自动评论。
本机 -p 过夜最小形(官方拼装,非发明 flag):
claude -p --bare --permission-mode auto --permission-prompts none \
--allowedTools "Read,Edit,Bash(npm test *),Bash(git status *),Bash(git diff *),Bash(git commit *),Bash(git push *)" \
--max-budget-usd 20 \
"/goal tests pass and a draft PR is open; do not merge; do not deploy"
--permission-prompts none 需 v2.1.259+。auto 在 -p 必须显式传。classifier 会拦 merge 无人批的 PR、prod deploy、force push 等(见 §4)。
无人值守韧性(env-vars,抓取 2026-09-17):CLAUDE_CODE_RETRY_WATCHDOG=1(官方写明 “unattended sessions such as eval harnesses, CI jobs, or remote workers”);autoContinueAtUsageLimit(usage limit 重置后续跑)。
3.3 人必须守的门(官方 + 舰队)
| 门 | 必须人? | 依据 |
|---|---|---|
| Merge PR | 是 | Auto classifier 默认拦 “Merging a pull request no human has approved, approving Claude's own pull request, or disabling CI checks”(permission-modes)。舰队:未明确说 merge 就不 merge。 |
| Prod deploy / 花钱的云操作 | 是 | Classifier 拦 “Production deploys and migrations”、“Toggling… a production feature flag”、IaC destroy。舰队:prod deploy 与 spend 必须人。 |
| Usage credits / 超额 | 是 | Routines 撞日 cap 后,没开 usage credits 会拒跑;开 credits 是账号设置,属花钱。--max-budget-usd 只限 API 估算。 |
| bypass 首次责任对话框 | 是(交互一次) | 非交互不弹窗;--bg 在未接受对话框前 拒绝。root/sudo 拒绝 bypass。 |
| Workspace trust(交互) | 首次要人 | -p 不弹 trust,因此 项目 allow 规则不生效。 |
**开 PR / push 到 claude/ 分支** | 官方允许 agent 做 | Cloud/Routines 推 claude/ 前缀。Push 到他人有 PR 的分支或别人的 commit 会被拒。 |
| 审 diff、点 Create PR(云 UI) | 建议人 | Cloud:“review changes, and create a pull request”。Auto-fix 仍可能改代码,但 merge 仍是人。 |
| GitHub App 安装 / secret | 人 | Actions 要 admin。 |
官方 没有 “跑完自动 merge 并上 prod” 的推荐路径。W13 PR auto-fix 是修 CI / nits 直到绿,不是 merge。
4 Risks / official warnings
4.1 bypass / --dangerously-skip-permissions
permission-modes(抓取 2026-09-17):
“
bypassPermissionsmode disables permission prompts and safety checks so tool calls execute immediately, including writes to protected paths.”
“Only use this mode in isolated environments like containers, VMs, or dev containers without internet access, where Claude Code cannot damage your host system.”
“
bypassPermissionsoffers no protection against prompt injection or unintended actions. For background safety checks with far fewer permission prompts, use auto mode instead.”
Linux/macOS 拒绝 root/sudo,原文错误串:
--dangerously-skip-permissions cannot be used with root/sudo privileges for security reasons
首次交互会责任对话框;decline 则退出。Cloud 静默忽略仓库里的 defaultMode: "bypassPermissions" / "dontAsk"。
permissions 页:bypass 仍跳过对 .git / .claude 等保护路径的提示。
4.2 auto mode 不是安全保证
permission-modes:
“Auto mode reduces permission prompts but does not guarantee safety. Use it for tasks where you trust the general direction, not as a replacement for review on sensitive operations.”
W13(2026-03-23–27):auto 是 skip-permissions 与逐条批准的中间态。
Classifier 默认拦(节选,permission-modes):curl | bash;把敏感数据送到外部;prod deploy / migrations;云存储大规模删除;IAM/repo 权限;force push;无人批准就 merge PR;改 CI 去跑 secret;terraform destroy;把内部包安装绕到公网 registry;启动另一个 --dangerously-skip-permissions agent。默认允许:工作目录本地文件操作;按 lockfile 装依赖;push 当前仓库任意分支(含 default,v2.1.211+;内容仍受其它规则查)。
-p 无 --permission-prompt-tool 时,classifier 连挡 3 次或累计 20 次:动作不跑,进程不退出(“Claude Code doesn't stop the run”)。
4.3 误删 / 出站 / 供应链
| 风险 | 官方怎么说 |
|---|---|
| 误删 | Critical-path rm/rmdir(/、/usr、$HOME、工作目录及其父)任何 allow/hook 都不能批。bypass 仍 问人;dontAsk deny;auto 送 classifier。PowerShell Remove-Item 对系统路径/裸 * 所有 mode 直接 deny。Classifier 拦 rm -rf "$VAR" 这种变量目标(v2.1.205+)。 |
| 出站网络 | Manual 下 curl/wget 默认要批。Bash(curl *) deny 拦不住 /usr/bin/curl 或 sh -c 'curl…'(permissions “What a Bash rule doesn't match”)。要 OS 级用 sandbox network allowlist。WebFetch 预批文档域;其它要批。Windows WebDAV:\* 可绕过权限系统发网络请求(security)。 |
| Prompt injection | security:“no system is completely immune”。-p 关掉 trust verification。Web fetch 用隔离 context。最佳实践:VM;不要把不信任内容直接 pipe 给 Claude。 |
| 供应链 / MCP | “Anthropic … does not security-audit or manage any MCP server.” 仓库 .mcp.json 在 -p 不问就连。hooks 在未 trust 的 -p 仍跑。Plugin zip 曾有权限/残留文件问题(changelog 抓取日条目)。 |
| Cloud 出站 | 即使 network disabled,“Claude Code can still communicate with the Anthropic API, which may allow data to exit the VM.” Auto-fix 用你的 GitHub 身份回评论,可能触发 Atlantis//deploy。 |
| 凭证 | CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 从 Bash/hooks/MCP 子进程剥凭证,防注入外带。 |
security 页(抓取 2026-09-17)责任句:
“You're responsible for reviewing proposed code and commands for safety before approval.”
5 macOS + China proxy
Clash 端口 7897 / 7879:Claude 官方文档未出现。 舰队记忆不是 Anthropic 文档。下面只记官方网络配置。
network-config + env-vars(抓取 2026-09-17):
| 官方项 | 内容 |
|---|---|
HTTPS_PROXY / HTTP_PROXY | “Claude Code respects standard proxy environment variables.” 推荐 HTTPS。大小写都认;顺序 https_proxy, HTTPS_PROXY, http_proxy, HTTP_PROXY。也可写 settings.json 的 env。 |
NO_PROXY | 空格或逗号分隔。"*" = 全部绕过。loopback 本来就不走代理。 |
| SOCKS | “Claude Code does not support SOCKS proxies.” Clash mixed/HTTP 口可以;SOCKS 口官方不支持 CLI 主连接。Sandbox 另有 sandbox.network.socksProxyPort(沙箱流量,不是 API 主连接)。 |
| 认证 | HTTPS_PROXY=http://user:pass@host:port basic auth。NTLM/Kerberos:官方让走 LLM Gateway。 |
| 企业 MITM / 自定义 CA | 系统信任库默认会读(native installer;npm 需 Node 22.15+)。否则 NODE_EXTRA_CA_CERTS=/path/to/ca-cert.pem。CLAUDE_CODE_CERT_STORE=bundled|system。 |
| 校验 | 代理 URL 缺 http:// scheme 会启动失败。claude --debug 日志;/status 有 Proxy 行。 |
| 后台 agent | 代理变量要写 ~/.claude/settings.json 的 env,不要只 export 在 shell——supervisor 不一定继承。 |
| 必达 host | api.anthropic.com、claude.ai、claude.com、platform.claude.com、mcp-proxy.anthropic.com、downloads.claude.ai、registry.npmjs.org、code.claude.com 等(network-config 表)。TLS 检查代理要放行。 |
| 官方未写 | Clash、Surge、端口 7897、7879、系统「增强模式」、TUN。不知道 Claude 是否认 macOS 系统代理;文档只写 env vars。 |
Sandbox 相关(settings-reference):sandbox.network.httpProxyPort、socksProxyPort;macOS MITM 可能要 sandbox.enableWeakerNetworkIsolation(官方标明降低安全性)。Go 工具 TLS 失败见该页。
Verdict buckets: 可立刻用 / 有条件 / 不建议
可立刻用(官方文档完整、可今晚配)
- 交互少点:Pro/Max/Team 已默认 auto(2026-08-14 起);或
Shift+Tab。用户设置:~/.claude/settings.json→"permissions": {"defaultMode": "auto"}(不要写进 project settings)。 - 精确放行:
permissions.allow/--allowedTools "Bash(npm test *)"等;deny.env。 - 本机少 prompt 且要隔离:
sandbox.enabled: true(macOS 官方支持),保留 deny 与ask: ["Bash(git push *)"]。 - 脚本一次性任务:
claude -p … --bare --permission-mode auto --permission-prompts none(v2.1.259+)或dontAsk+ 短 allowlist。 - 做完看结果:
-p --output-format json+ 退出码;macOSNotificationhook +osascript;preferredNotifChannel: "terminal_bell"。 - 续聊:
claude -c/-p --continue/--resume $session_id。 - 笔记本可关:Routines 或
claude --cloud "…"(需 claude.ai 登录,非 API key / 非 Bedrock)。 - CI:GitHub Action +
dontAsk+--allowedTools。 - 代理:
export HTTPS_PROXY=http://127.0.0.1:<Clash的HTTP口>(具体口 官方不知道;舰队记忆 7897 然后 7879)。企业 CA:NODE_EXTRA_CA_CERTS。 - 人门:merge / prod / 花钱保持人手。Classifier 已拦无人 merge 与 prod deploy。
有条件
--dangerously-skip-permissions/bypassPermissions:仅 非 root 容器/VM/无网 devcontainer;先交互点过责任对话框才能--bg。Cloud settings 里写了也无效。defaultMode: "bypassPermissions":只能 user/managed,不能 project。/goal+ auto:条件必须能从 transcript 验证;hooks 被禁则/goal不可用。- Desktop 定时:电脑醒着 + app 开着;合盖 skip;Manual 会 stall 等批准。
- Channels 当“远程批权限 / 手机指挥本机”:research preview;session 必须开着;合盖没用。
- HTTP hook 做出站 webhook:要自建 endpoint +
allowedHttpHookUrls。 CLAUDE_CODE_RETRY_WATCHDOG=1:官方指定 unattended;会无限重试 429/529(spend limit 的 429 立即失败,v2.1.239+)。- Cursor Cloud Agent 过夜:舰队条件(配额),不是 Anthropic 文档。
- 云 session 开 PR:GitHub App 或
/web-setup;组织 IP allowlist 可能直接让云 session 认证失败。
不建议
- 本机 bypassPermissions / YOLO 过夜。 官方:只给隔离环境;无 prompt-injection 防护;可写
.git/.claude。社区 YOLO ≠ 官方 flag。 - 以为 auto 或 cloud 绿点 = 已上线。 Routines 绿 = 没基础设施错误。Merge/prod 仍要人。
- **项目 settings 里设
auto/bypassPermissions当默认。** 官方明确不生效。 - **用
--allowedTools收紧 bypass。** Allow 在 bypass 下无效。 - **只靠
Bash(curl *)deny 当网络边界。** 路径/包装绕过。 - **
-p跑不信任仓库还不加--bare。** trust 关闭,hooks/MCP 仍可能执行。 - 合盖指望 Desktop/本机 CLI 跑完。 官方会 skip。
- Routines 塞满 connectors。 默认全开且可写、不问。
- Cloud auto-fix 开在会因评论触发 deploy 的仓库。 官方点名 Atlantis 等。
- 跳过 merge / prod / 花钱人门。 舰队禁止;官方 classifier 也按这个方向拦。
Unknowns
写「不知道」= 本次官方页没找到,不发明:
- **官方 flag/key 名叫 YOLO /
--yolo/yolo:** 不存在于 CLI reference、permission-modes、settings-reference。仅 GitHub 社区 issue。 - **
preferredNotifChannel除"terminal_bell"以外的合法枚举:** settings-example 只给了这一个。是否有"desktop"/"auto"不知道。 - **
agentPushNotifEnabled/inputNeededNotifEnabled的类型、默认、是否覆盖-p:** index 有 key,全文未完整抓到。 - 内置「任务 100% 完成 → Slack/邮件/通用 webhook」产品: 没找到。只有自写 hooks 或
-p退出。 - Clash / 7897 / 7879: 官方未提。系统代理是否自动用 不知道。SOCKS 官方不支持主连接。
- **macOS 合盖 +
caffeinate能否让 CLI-p跑完:** Claude 文档没写;只写 Desktop scheduled tasks 合盖仍睡。 - Cursor Cloud Agent 与 Claude Code 权限模型对照: 非 Anthropic 文档。
- **Cloud 里
dontAsk能否用 CLI flag 打开: 文档写 cloud 忽略 settings 的 dontAsk/bypass;mode dropdown 列的是 Accept edits / Plan / Auto。flag 是否另算 不知道**。 - **changelog 页对应的精确 CLI 版本号(本机未跑
claude --version):** 不知道当前盒子上的版本。docs 引用到 v2.1.271 量级条目。 - **
Stophook 是否在成功-p退出时稳定 fire、payload 是否含“成功”布尔:** 未把 hooks reference 全文逐字段核对完毕 → 不知道;guide 只说 Stop = Claude finishes responding。
6 社区经验(经验≠官方;本席复核)
| 源 | URL | 日期 | 等级 |
|---|---|---|---|
| Granola / Jim Fisher | https://www.granola.ai/blog/dangerously-skip-permissions-is-the-only-safe-mode | 页标 May 11;抓取 2026-09-17 | 经验;标题挑衅,主张用 auth/隔离替代逐条 Yes |
| OOZOU TIL | https://oozou.com/til/run-claude-code-fully-autonomously-with-a-yolo-alias-190 | 2026-02-16 | 可复现 alias |
| GitHub #2591 | https://github.com/anthropics/claude-code/issues/2591 | 关 2026-01-04 not_planned | --yolo 官方不做 |
| GitHub #34467 | https://github.com/anthropics/claude-code/issues/34467 | 关 2026-03-25 duplicate | 同上 |
| Background Claude | https://backgroundclaude.com/blog/permission-modes | 2026-04-10 | 可复现 dontAsk+--bare 配方;auto 段过时(写 research preview / 非 Pro·Max;官方 W32 2026-08-14 起 Pro/Max/Team 交互默认 auto) |
| MorphLLM 文 | https://www.morphllm.com/claude-code-dangerously-skip-permissions | 搜索 2026-09-17 | 可复现 alias;本席 WebFetch 被 bot 墙,未打开全文 |
| Reddit r/ClaudeAI | — | 2026-09-17 | 不知道(403 后 429,停查) |
| X @paul_pbng / @bbhxwl / @hishboy | 执行器摘录 | 2026-09-17 | 本席未逐帖打开原文 → 当口头/未核 |
| Hidekazu 配方 | 执行器摘录 | 标 2026-09-07 | 本席未打开原文 → 不引用为可复现 |
可复现配置(社区,非官方新产品):
alias yolo='claude --dangerously-skip-permissions' # 经验;官方无 --yolo
claude --bare -p "…" --permission-mode dontAsk --allowedTools "Read" "Bash(npm test)"
口头/过时勿当默认:宿主机连开 YOLO;IS_SANDBOX=1 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1(未在官方 env 页核实);Background Claude 对 auto 的账号限制(已被官方 W32 覆盖)。
6 社区经验(经验≠官方;抓取 2026-09-17)
| 源 | 日期 | 可复现配置 vs 口头 | 要点 |
|---|---|---|---|
| Granola / Jim Fisher https://www.granola.ai/blog/dangerously-skip-permissions-is-the-only-safe-mode | 页标 May 11;抓取 2026-09-17 | 口头/论证 | 连点 Yes = 坐着 YOLO;真正该做的是 auth/隔离 不是多点批准。标题挑衅,方向与官方 “bypass 只放容器/VM” 同向。 |
| MorphLLM 指南 https://www.morphllm.com/claude-code-dangerously-skip-permissions | 搜索 2026;页被 bot 墙,正文以搜索摘要为准 | 可复现 alias | alias yolo='claude --dangerously-skip-permissions';YOLO 不是官方 flag。 |
| OOZOU TIL https://oozou.com/til/run-claude-code-fully-autonomously-with-a-yolo-alias-190 | 2026-02-16 | 可复现 alias | 同上 echo 进 zshrc/bashrc。 |
| GH #2591 / #34467 | 2025-06-25 开;#2591 2026-01-04 closed not_planned | 官方仓库 issue(次级) | Anthropic 拒绝 加 --yolo alias。 |
| Background Claude 博客 https://backgroundclaude.com/blog/permission-modes | 2026-04-10 | 可复现命令;部分过时 | 无人值守推 claude --bare -p … --permission-mode dontAsk + 窄 allow + --max-turns/--max-budget-usd。注意:文称 auto 不是 Pro/Max;与官方 W32(2026-08-14 起 Pro/Max/Team 默认 auto)冲突 → 以官方为准。产品文带 Cyrus 推销。 |
| X @paul_pbng https://x.com/paul_pbng/status/2091442772993777764 | 执行器摘 2026 | 口头翻车 | 连开 YOLO 约 2 周直到 git checkout .;改 allow/deny。JSON 未核到。本席未打开该帖全文。 |
| Reddit r/ClaudeAI | 2026-09-17 | — | 403 后 429,停查 / 不知道。 |
实验 env IS_SANDBOX=1 / CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1:官方 env-vars 页本次未核到 → 不进舰队默认。
真源:/home/box/archives/org/2026-09-17-claude-code-unattended.md · 抓取日 2026-09-17 · 正文由 scripts/sync_reports.py 从 md sync,勿手改本页 SYNC 区当真源