The Hook Pipeline
Agent prepares a Bash command
Your AI agent constructs a shell command to execute — for example,
git reset --hard — and passes it to the Bash tool.PreToolUse hook fires
Before the Bash tool executes anything, CC Safety Net intercepts the call. This happens at the hook layer, which runs before the permission system and before the OS ever sees the command.
Semantic analysis
CC Safety Net parses the command into its components — executable, subcommand, flags, and arguments — and analyzes the intent of the operation. See Semantic Analysis below for details.
Semantic Analysis
CC Safety Net uses semantic analysis rather than simple string matching. This distinction matters in practice. When a command arrives, it is parsed into its structural components:- Executable — the base program (
git,rm,find, etc.) - Subcommand — the operation being requested (
checkout,reset,push, etc.) - Flags — options that modify behavior (
--hard,-f,-r, etc.) - Arguments — the targets the command acts on (file paths, branch names, refs, etc.)
| Command | Intent | Outcome |
|---|---|---|
git checkout -b feature | Creates a new branch | Allowed |
git checkout -- file | Discards uncommitted changes in a file | Blocked |
git checkout. A pattern-matching approach either blocks both or neither. Semantic analysis distinguishes them and makes the right call in each case — protecting you from accidental data loss without blocking everyday workflows.
Shell Wrapper Detection
Wrapping a destructive command in a shell invocation doesn’t hide it from CC Safety Net. Shell wrappers likebash -c '...' are recursively unwrapped and the inner command is subjected to the same semantic analysis. This unwrapping goes up to 10 levels deep.
Interpreter One-Liner Detection
Destructive commands can also be hidden inside interpreter one-liners. By default, CC Safety Net analyzes the content of one-liners passed to Python, Node, Ruby, and Perl for embedded destructive operations:CC_SAFETY_NET_PARANOID_INTERPRETERS=1 to block all interpreter one-liners outright — regardless of their content.
Block Output Format
When CC Safety Net blocks a command, the agent receives a structured response as the tool result. A typical block message looks like this:Audit Logging
Every blocked command is written to a structured log file for later review:| Field | Description |
|---|---|
ts | ISO 8601 timestamp of when the command was blocked |
command | The full command string as received |
segment | The specific segment that triggered the block (may differ for wrapped commands) |
reason | The human-readable reason for blocking |
cwd | The working directory at the time of the call |
