用途:SpecStory Guard 是一个预提交防护工具,扫描 .specstory/history 中的潜在密钥,发现后阻止提交,直到密钥被移除或脱敏。适用于 AI 编码会话可能无意记录 API 密钥、环境变量、私钥、令牌或配置示例凭据的场景。
主要能力:安装 git pre-commit 钩子;每次提交扫描 .specstory/history 文件;检测常见密钥模式,包括 AWS 密钥(AKIA...、aws_secret_access_key)、API 令牌(Bearer ...、token: ...)、私钥(-----BEGIN RSA PRIVATE KEY-----)、GitHub 令牌(ghp_...、github_pat_...)以及通用密钥(password=、secret=、api_key=);发现后阻止提交并输出脱敏预览。
使用方式:支持斜杠命令 /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 目录;检测基于模式匹配,可能产生误报,需用允许列表调整;纯 Python 实现,无外部依赖;扫描通常对数百文件在 1 秒内完成。其他平台、收费或价格信息暂未提供。