Lv.1 0 XP

Headless Claude Code — Tool Restriction and Configuration

Core 6 min +25 XP
💡
THE ANALOGY

A remote-controlled drone vs a piloted plane. The drone follows programmed constraints exactly — you can't course-correct in real time. Precise upfront configuration is critical: restrict what it can do to what it should do.

⚠️ EXAM TRAP — The Wrong Answer People Choose

Giving headless Claude Code all tools for flexibility. In non-interactive mode, you cannot intervene if Claude calls file_delete when it shouldn't. Restrict to minimum necessary.

KEY POINTS
1 --allowedTools: explicit whitelist of permitted tools for this invocation only.
2 --disallowedTools: explicit blacklist — useful when you want most tools except specific dangerous ones.
3 Timeouts are critical for all headless runs — unconstrained runs block pipelines.
4 Idempotent operations: headless jobs should be safe to re-run without double processing.
5 --env for configuration — pass settings without hardcoding credentials in commands.