opena2a shield

Unified security orchestration for AI coding assistants. Tamper-evident event log, policy evaluation, runtime monitoring, session identification, integrity verification, and LLM-powered analysis.

Usage

opena2a shield <subcommand> [options]

Quick Start

# Initialize Shield in your project
opena2a shield init
 
# Check what AI assistants are running
opena2a shield session
 
# View security events
opena2a shield log --severity medium
 
# Generate a posture report
opena2a shield report
 
# Run integrity verification
opena2a shield selfcheck

Capabilities

Shield operates in three modes: monitor (default) logs and surfaces events,enforce blocks denied commands via shell hooks, and baseline learning observes agent behavior across sessions to suggest policy rules when behavior stabilizes.

CapabilityDescriptionStatus
Credential scanningDetects hardcoded API keys (Anthropic, OpenAI, AWS, Google, GitHub)Active
Scope drift detectionFinds keys that silently access unintended services (DRIFT-001, DRIFT-002)Active
Tamper-evident event logSHA-256 hash-chained log -- any modification breaks the chainActive
Policy evaluationAllow/deny rules for processes, credentials, network, filesystem, MCP serversActive
Session identificationDetects which AI assistant is running via environment and process signalsActive
Config integritySigns config files and detects unauthorized modificationsActive
ARP bridgeImports runtime protection events from HackMyAgent ARPActive
Posture scoring0-100 security score based on active tools, policy, hooks, credentialsActive
LLM intelligencePolicy suggestions, anomaly explanations, incident triageOpt-in
Integrity selfcheckVerifies policy, shell hooks, event chain, process, artifact signaturesActive
Lockdown modeEnters lockdown on integrity failure; requires explicit recoveryActive
Adaptive baselinesLearns per-agent behavior, tracks stability across sessions, suggests policiesActive
Enforcement modeShell hooks check policy and block denied commands in enforce modeActive
HTML posture reportInteractive dark-theme report with severity chart, filters, agent activityActive

Subcommands

SubcommandDescription
init11-step security setup: environment scan, policy generation, shell hooks, genesis event (contrast with read-only opena2a init)
statusTool availability, policy mode, shell integration, integrity state
logQuery the tamper-evident event log with filters (severity, source, agent, time)
selfcheckRun integrity checks: policy hash, shell hook, event chain, process binary, artifact signatures
policyShow loaded security policy (mode, rule counts, agent overrides)
evaluateEvaluate an action against the loaded policy (ALLOWED, BLOCKED, MONITORED)
monitorImport ARP runtime events into Shield log and display runtime stats
reportGenerate a security posture report with severity breakdown and agent activity
sessionDetect current AI coding assistant (Claude Code, Cursor, Copilot, Windsurf)
recoverExit lockdown mode after integrity failures, with optional verification
suggestLLM-powered policy suggestions based on observed agent behavior
explainLLM-powered anomaly explanations with risk factors and recommended actions
triageLLM-powered incident classification: false-positive, suspicious, confirmed-threat
baselineManage per-agent behavioral baselines with stability tracking and phase transitions

Subcommand Details

shield init

11-step security setup that detects project type, scans for credentials, discovers AI assistants, MCP servers, and OAuth sessions, generates a YAML policy file, installs shell hooks, and writes a genesis event to the tamper-evident log. Unlike the read-only opena2a init assessment,shield init actively configures security infrastructure in your project.

opena2a shield init
opena2a shield init --dir ./my-agent
opena2a shield init --format json

shield log

Query the tamper-evident event log with filters. Each event is SHA-256 hash-chained to the previous.

opena2a shield log # Last 20 events
opena2a shield log --count 50 # Last 50 events
opena2a shield log --severity high # High+ severity
opena2a shield log --source arp # ARP events only
opena2a shield log --agent claude-code # Filter by agent
opena2a shield log --since 7d --format json # JSON output

shield selfcheck

Runs five integrity checks and returns an overall status: healthy, degraded, or compromised.

CheckVerifies
PolicyPolicy file hash matches recorded value
Shell hookShell hook content matches expected template
Event chainEach event hash-chains to the previous
ProcessNode.js binary exists and appears legitimate
Artifact signaturesAll signed artifacts match their recorded hashes

shield monitor

Import ARP (Agent Runtime Protection) events into Shield's hash-chained log and display runtime protection stats. Events from HackMyAgent's ARP module are translated into Shield's unified event format.

opena2a shield monitor # Import + show stats
opena2a shield monitor --agent cursor # Tag imported events
opena2a shield monitor --since 7d # Stats window

shield session

Detect the current AI coding assistant session. Identifies Claude Code, Cursor, GitHub Copilot, Windsurf, Aider, and Continue via environment variables, process signals, and TTY detection.

opena2a shield session # Detect current session
opena2a shield session --verbose # Show raw signals

shield report

Generate a security posture report from event data. Includes severity breakdown, agent activity, policy violations, top actions, and optional LLM-powered narrative. Supports interactive HTML output.

opena2a shield report # Last 7 days (text)
opena2a shield report --report posture.html # Interactive HTML
opena2a shield report --since 30d # Last 30 days
opena2a shield report --analyze # Include AI narrative

shield baseline

Manage per-agent behavioral baselines. Baselines track observed actions across sessions and compute stability scores. Phases: learning (collecting) → stabilizing (fewer new behaviors) → stable (ready for policy generation).

opena2a shield baseline # List all baselines
opena2a shield baseline claude-code # Detail for agent
opena2a shield baseline --format json # JSON output

Enforcement Mode

When shield init installs shell hooks and the policy mode is set to enforce, each command is evaluated against the loaded policy before execution. Denied commands are blocked with exit code 1.

# Shell hook (zsh) automatically runs before each command:
if ! opena2a shield evaluate "$1" 2>/dev/null; then return 1; fi

LLM Intelligence (suggest, explain, triage)

Three LLM-powered subcommands provide AI analysis of security events. Requires an LLM backend (enable with opena2a config llm on). Zero network calls by default.

# Policy suggestions from observed behavior
opena2a shield suggest --agent cursor
 
# Anomaly explanations with risk factors
opena2a shield explain --severity high --count 5
 
# Incident classification and response steps
opena2a shield triage --severity medium

Options

FlagTypeDescription
--dir <path>stringTarget directory. Defaults to current working directory.
--agent <name>stringAgent name filter for log, suggest, explain, triage.
--count <n>numberEvent count for log and explain. Default: 20 (log), 1 (explain).
--since <timespec>stringTime filter: 7d, 1w, 1m, or ISO 8601 timestamp.
--severity <level>stringSeverity filter: info, low, medium, high, critical.
--source <source>stringEvent source filter (e.g., arp, secretless, shield).
--category <cat>stringEvent category filter.
--verifybooleanVerify integrity before exiting lockdown (recover).
--analyzebooleanInclude LLM-powered narrative in reports.
--report <path>stringWrite interactive HTML posture report to file.
--verbosebooleanShow additional details (e.g., raw session signals).
--format <type>text | jsonOutput format. Default: text.

Event Log Format

Shield maintains a tamper-evident event log at ~/.opena2a/shield/events.jsonl. Each event is SHA-256 hash-chained to the previous, starting from a genesis hash. Any modification to a past event breaks the chain and is detected by selfcheck.

[2026-03-02T12:00:00Z] [HIGH] process.anomaly -> curl evil.com (monitored)
[2026-03-02T12:01:00Z] [CRITICAL] prompt.threat -> injection-attempt (blocked)
[2026-03-02T12:02:00Z] [INFO] process.spawn -> /usr/bin/ls (allowed)

Exit Codes

CodeMeaning
0Success (healthy, allowed, recovered)
1Failure (compromised, lockdown, blocked, no policy, unknown subcommand)

See Also