Problem
The scanning engine (src/scanner/engine.ts, src/scanner/detectors.ts) is currently coupled to the Claude Code hook protocol (stdin JSON envelope, hook-specific exit codes/response shape). The actual detection logic is generic and valuable independent of Claude Code — the same engine could back similar guardrails for Cursor, GitHub Copilot, Windsurf, or any other AI coding tool with an equivalent hook/extension point. This also hedges the platform risk called out in the product audit: if Anthropic ships native secret-redaction in Claude Code, the underlying scanning engine still has value elsewhere.
Proposal
Extract the core scanner (config loading, detectors, engine, allowlists, redaction) into a standalone, protocol-agnostic package/CLI:
privacy-guard-core scan --stdin
Taking raw text on stdin (or as an argument) and returning scan results as JSON, independent of any specific hook envelope. The existing Claude Code hook (scripts/prompt-guard.js) becomes a thin adapter that reads the Claude Code stdin envelope, extracts the prompt, calls the core scanner, and formats the hook-specific response.
Acceptance criteria
Problem
The scanning engine (
src/scanner/engine.ts,src/scanner/detectors.ts) is currently coupled to the Claude Code hook protocol (stdin JSON envelope, hook-specific exit codes/response shape). The actual detection logic is generic and valuable independent of Claude Code — the same engine could back similar guardrails for Cursor, GitHub Copilot, Windsurf, or any other AI coding tool with an equivalent hook/extension point. This also hedges the platform risk called out in the product audit: if Anthropic ships native secret-redaction in Claude Code, the underlying scanning engine still has value elsewhere.Proposal
Extract the core scanner (config loading, detectors, engine, allowlists, redaction) into a standalone, protocol-agnostic package/CLI:
Taking raw text on stdin (or as an argument) and returning scan results as JSON, independent of any specific hook envelope. The existing Claude Code hook (
scripts/prompt-guard.js) becomes a thin adapter that reads the Claude Code stdin envelope, extracts the prompt, calls the core scanner, and formats the hook-specific response.Acceptance criteria
scan --stdinCLI mode exists and is documentedscripts/prompt-guard.jsis refactored to be a thin wrapper around the core scanner (no behavior change for existing Claude Code users)