Implementation:0xSteph Pentest ai agents Claude Code Permission Gate
| Knowledge Sources | |
|---|---|
| Domains | Security, Safety, External_Tool |
| Last Updated | 2026-10-22 12:00 GMT |
Overview
External tool providing the per-command user approval gate for Tier 2 agent execution, provided by the Claude Code CLI.
Description
The Claude Code Permission Gate is the second layer of the two-layer safety model in pentest-ai-agents. Layer 1 is prompt-level scope enforcement (the scope-guard block embedded in all Tier 2 agents). Layer 2 is Claude Code's built-in per-command permission prompt: before any Bash command executes, Claude Code displays the full command to the user and waits for explicit approval (`[y/n]`).
This is an External Tool Doc: it documents how an external tool (Claude Code CLI) is used within this repo's workflow, not a function or class in the repo itself.
Usage
- Automatic gating: Every Bash command composed by a Tier 2 agent triggers the permission gate automatically — no configuration needed.
- User as final checkpoint: The user sees the full command, its explanation, and OPSEC tag before deciding to approve or deny.
- Denial handling: If the user denies, the agent aborts the command and does not retry.
Code Reference
Source Location
- Repository: pentest-ai-agents (documentation)
- File: docs/TIER2-EXECUTION.md (Layer 2 description)
- External Tool: Claude Code CLI
Signature
# The permission gate is built into Claude Code's Bash tool:
# 1. Agent composes a Bash command (with scope validation, OPSEC tag)
# 2. Claude Code displays the command to the user
# 3. User approves [y] or denies [n]
# 4. If approved: command executes, output returned to agent
# 5. If denied: agent receives denial, aborts, does not retry
Import
# Install Claude Code CLI:
npm install -g @anthropic-ai/claude-code
# The permission gate is automatic for all Bash tool calls.
# No import or configuration needed in agent definitions.
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| Bash command | text | Yes | Full command string from agent |
| User approval | interaction | Yes | [y/n] prompt response |
Outputs
| Name | Type | Description |
|---|---|---|
| Execution result | stdout/stderr | Command output if approved |
| Denial | abort | Command aborted if denied |
Usage Examples
Two-Layer Safety Flow
# Layer 1: Prompt-Level Scope Enforcement (scope-guard)
# Agent validates: "Target 10.10.1.50 is within scope 10.10.0.0/24 ✓"
# Agent composes: nmap -sT -sV --min-rate 100 --max-rate 1000 10.10.1.50
# Agent tags: [MODERATE] TCP connect scan with service detection
# Agent explains: "This scan will discover open ports and services..."
# Layer 2: Claude Code Permission Gate
# Claude Code displays the full command and asks:
# "Run this command? [y/n]"
# User sees: nmap -sT -sV --min-rate 100 --max-rate 1000 10.10.1.50
# User approves: y
# Command executes, output returned to agent for analysis.
Related Pages
Implements Principles
Related Implementations
- Implementation:0xSteph_Pentest_ai_agents_Scope_Guard provides Layer 1 (prompt-level scope enforcement)
- All Tier 2 agents trigger this gate for every Bash command