This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Clawdstrike is a runtime security enforcement system for AI agents. It provides policy-driven security checks at the tool boundary between agent runtimes and their executed actions. The project is Rust-first with multi-language support (TypeScript, Python, WebAssembly).
Design Philosophy: Fail-closed. Invalid policies reject at load time; errors during evaluation deny access.
Formal Verification: The policy engine's core decision logic is formally verified via a Lean 4 specification (formal/lean4/ClawdStrike/) and Z3/Logos policy analysis (clawdstrike-logos). Differential tests (formal-diff-tests) compare the spec against the Rust implementation using property-based testing.
# Build
cargo build --workspace
# Test
cargo test --workspace # All tests
cargo test -p clawdstrike # Single crate
cargo test test_name # Single test
# Lint & Format
cargo fmt --all
cargo clippy --workspace -- -D warnings
# Full CI locally
mise run ci # or: cargo fmt --all -- --check && cargo clippy --workspace -- -D warnings && cargo test --workspace
# Documentation
cargo doc --no-deps --all-features
mdbook build docs
# TypeScript packages
npm install --workspace=packages/sdk/hush-ts
npm run build --workspace=packages/sdk/hush-ts
npm test --workspace=packages/sdk/hush-ts
# Python
pip install -e packages/sdk/hush-py[dev]
pytest packages/sdk/hush-py/tests
# CLI
cargo install --path crates/services/hush-cli
clawdstrike check --action-type file --ruleset strict ~/.ssh/id_rsa
# Formal Verification
hush policy verify <policy.yaml> # Z3 policy verification
cargo test -p formal-diff-tests # Differential tests (spec vs impl)
cd formal/lean4/ClawdStrike && lake build # Build Lean 4 spec and check proofsRust Crates (crates/):
hush-core- Cryptographic primitives (Ed25519, SHA-256, Keccak-256, Merkle trees, canonical JSON RFC 8785)clawdstrike- Main library: guards, policy engine, receiptsspine- Signed envelopes, checkpoints, NATS transport, Merkle proofshush-cli- CLI binary (commands:clawdstrike,hush)spine-cli- Spine protocol CLI toolshushd- HTTP daemon for centralized enforcement (broker capability authority)clawdstrike-broker-protocol- Wire types, capability signing/verification, completion bundlesclawdstrike-brokerd- Local sidecar: capability validation, secret injection, provider executioncontrol-api- Control API service (early-stage)eas-anchor- Ethereum Attestation Service anchoringhush-proxy- Network proxy utilitieshush-wasm- WebAssembly bindingshush-ffi- C ABI foreign function interface for C#/Go/C bindingshush-certification- Compliance templateshush-multi-agent- Multi-agent orchestrationhush-native- Native Python extension (inpackages/sdk/hush-py/hush-native)tetragon-bridge- Tetragon gRPC to Spine bridgehubble-bridge- Cilium Hubble to Spine bridge
TypeScript Packages (packages/):
hush-ts- Core TypeScript SDK (@clawdstrike/sdk)clawdstrike-policy- Canonical policy engine (TS)clawdstrike-adapter-core- Base adapter interface- Framework adapters:
clawdstrike-openclaw,clawdstrike-vercel-ai,clawdstrike-langchain,clawdstrike-claude,clawdstrike-openai,clawdstrike-opencode clawdstrike-broker-client- Typed client for broker capability issuance and proxied execution- Engine bridges:
clawdstrike-hush-cli-engine,clawdstrike-hushd-engine
Python: packages/sdk/hush-py
- Guard - A security check implementing the
Guardtrait (sync) orAsyncGuardtrait (async) - Policy - YAML configuration (schema v1.5.0, backward-compatible with v1.1.0) with
extendsfor inheritance - Receipt - Ed25519-signed attestation of decision, policy, and evidence
- HushEngine - Facade orchestrating guards and signing
ForbiddenPathGuard- Blocks sensitive filesystem pathsPathAllowlistGuard- Allowlist-based path access controlEgressAllowlistGuard- Controls network egress by domainSecretLeakGuard- Detects secrets in file writesPatchIntegrityGuard- Validates patch safetyShellCommandGuard- Blocks dangerous shell commands before executionMcpToolGuard- Restricts MCP tool invocationsPromptInjectionGuard- Detects prompt injectionJailbreakGuard- 4-layer detection (heuristic + statistical + ML + optional LLM-judge)ComputerUseGuard- Controls CUA actions for remote desktop sessionsRemoteDesktopSideChannelGuard- Side-channel controls for clipboard, audio, drive mapping, file transferInputInjectionCapabilityGuard- Restricts input injection capabilities in CUA environmentsSpiderSenseGuard- Hierarchical threat screening (Yu et al. 2026): embedding-based cosine similarity + optional LLM deep path
Policies are YAML files with schema version 1.5.0 (backward-compatible with 1.1.0). They support inheritance via extends:
- Built-in rulesets:
permissive,default,strict,ai-agent,cicd,ai-agent-posture,remote-desktop,remote-desktop-permissive,remote-desktop-strict,spider-sense - Local file references
- Remote URLs
- Git refs
Location: rulesets/ directory contains built-in policies.
The secret broker is a brokered egress tier that interposes between AI agents and external APIs, ensuring agents never touch raw credentials.
Components: hushd (capability authority) → clawdstrike-brokerd (local sidecar) → upstream provider APIs
Policy: broker: block in policy YAML defines per-provider rules with exact_paths, methods, secret_ref, require_intent_preview, max_executions, and approval_required_risk_levels.
Capability lifecycle: Issue (hushd signs Ed25519 capability) → Preview/Approve (optional operator gate) → Execute (brokerd injects secret, calls upstream) → Evidence (brokerd reports back to hushd) → Bundle (signed completion proof).
Security model: Fail-closed. Capabilities are time-bounded, path-scoped, optionally DPoP sender-constrained. DNS pinning prevents SSRF rebinding. Header deny-list blocks injection. Admin bearer token protects brokerd mutations. Evidence validated against issued capabilities. Delegation tokens checked against shared revocation store.
Secret backends: file (JSON/YAML on disk), env (environment variables), http (external vault API).
Operator surfaces (control-console): Mission Control (capabilities + previews + approval), Wallet (inventory + replay + freeze), Theater (live event stream).
Policy Load → Guard Instantiation → Action Check → Per-Guard Evaluation
→ Aggregate Verdict → Receipt Signing → Audit Logging
- Commit messages: Follow Conventional Commits -
feat(scope):,fix(scope):,docs:,test:,refactor:,perf:,chore: - Clippy: Must pass with
-D warnings(treat warnings as errors) - Property testing: Use
proptestfor cryptographic and serialization code - MSRV: Rust 1.93
Cargo.toml- Workspace root with all crate definitionsmise.toml- Task runner configurationdeny.toml- cargo-deny license/advisory configrulesets/*.yaml- Built-in security policiesdocs/- mdBook documentation sourceformal/lean4/ClawdStrike/- Lean 4 formal specification and proofsformal/lean4/ClawdStrike/ClawdStrike/Spec/Properties.lean- Theorem statements (P1-P13)formal/lean4/ClawdStrike/ClawdStrike/Core/- Hand-written spec (Verdict, Aggregate, Merge, Cycle, Eval)formal/lean4/ClawdStrike/ClawdStrike/Impl/- Aeneas-generated Lean from Rust source (do not edit)crates/tests/formal-diff-tests/- Differential tests (proptest: spec vs implementation)crates/libs/clawdstrike-logos/- Logos/Z3 policy-to-formula compilation and verification