Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xSteph Pentest ai agents Claude Code Permission Gate

From Leeroopedia
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

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

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment