| name | locking-down-claude |
| description | Secure non-interactive Claude/SDK calls: pinned tools, prompts, permissions. |
locking-down-claude
Rule: every programmatic Claude callsite sets four flags. Skip any one and a future edit silently widens the surface.
First: prefer the lib helper — don't hand-roll the flags
🚨 For Node scripts / hooks, use spawnAiAgent from @socketsecurity/lib-stable/ai/spawn with a tier from the AI_PROFILE ladder in @socketsecurity/lib-stable/ai/profiles. It enforces the four flags at the type level (SpawnAiAgentOptions requires tools / disallow / permissionMode), translates them per-agent (claude / codex / gemini / opencode), and owns --no-session-persistence, --add-dir, and the 529-overload retry. Hand-rolling a spawn('claude', [...flags]) is how the flag set drifts — and the prefer-async-spawn lint rule flags the raw spawn anyway.
import { AI_PROFILE } from '@socketsecurity/lib-stable/ai/profiles'
import { spawnAiAgent } from '@socketsecurity/lib-stable/ai/spawn'
const { exitCode, stdout } = await spawnAiAgent({
...AI_PROFILE.read,
: ,
: repoRoot,
: * * ,
})