用途:SpecStory Guard 是一个 Git pre-commit 守卫护栏,专门扫描 .specstory/history 目录中的潜在密钥,发现后阻止提交,直到密钥被移除或脱敏。适用于 AI 编程会话可能无意中记录敏感数据的场景,例如粘贴进对话的 API 密钥、命令输出中的环境变量、错误信息中的私钥或令牌、配置示例中的凭据。
主要能力:安装仓库级 Git pre-commit 钩子;每次提交时扫描 .specstory/history 文件;识别常见密钥模式(AWS 密钥、Bearer 令牌、RSA 私钥、GitHub 令牌、password=/secret=/api_key= 等通用密钥);发现即阻止提交;以脱敏预览方式报告发现位置(文件名与行号)。无外部依赖(纯 Python)。
使用方式:可通过斜杠命令 /specstory-guard(安装钩子)、/specstory-guard install、/specstory-guard scan、/specstory-guard check(scan 别名)、/specstory-guard uninstall 操作。也可直接运行脚本: python skills/specstory-guard/scripts/guard.py install python skills/specstory-guard/scripts/guard.py scan --root . python skills/specstory-guard/scripts/guard.py uninstall 可用环境变量设置允许列表(逗号分隔的正则表达式): SPECSTORY_GUARD_ALLOWLIST='example-key,PLACEHOLDER_.*,test-token' python skills/specstory-guard/scripts/guard.py scan --root .
发现密钥后的处理:按报告的行号打开文件,将密钥替换为 [REDACTED] 或删除该行,重新扫描确认,然后提交。
限制:扫描目标为 .specstory/history 目录;允许列表项按正则表达式解析,误报可通过它缓解。其他定价、平台支持等细节暂未提供。