改权限档先用 codex sandbox 离线试命令

不启 agent、不花 token。按平台选 macos / linux / windows。macOS 用 --log-denials;企业档加 --include-managed-config。

codex sandbox 用和 agent 相同的 OS 沙箱跑一条命令。别名 codex debug;平台还有 seatbelt / landlock。它只测文件系统和网络边界,不测会不会弹出批准框。

# Linux / WSL2(需要 bubblewrap)
codex sandbox linux -- echo "sandbox permits echo"
codex sandbox linux -P project-edit -- npm test

# macOS:结束后打印 Seatbelt 拒绝
codex sandbox macos --log-denials -- curl https://example.com
codex sandbox macos --allow-unix-socket /var/run/docker.sock -- docker ps

# Windows 原生沙箱
codex sandbox windows -P project-edit -- dir

-- 后面整段转发给沙箱。测命名权限档用 -P / --permission-profile(安全页有时写成 --permissions-profile)。-C 和工作区解析都要求同时给权限档。企业 requirements.toml 要叠进去时:

codex sandbox linux -P project-edit --include-managed-config -- npm test

网页搜索、Apps、MCP、浏览器不走这层。命令被拦了先看这一条,再去开 danger-full-access

来源