RepoRefit / 开发者工具
RepoRefit CLI
在你自己的电脑上运行与网页检查器相同的检查,适合大型项目、脚本和 AI 编程代理。不上传任何内容,也不发出网络请求。
安装
需要 Node.js 20 或更高版本。用 npm 安装一次,或用 npx 免安装运行。
npm install -g github:reporefit/action
reporefit scan
# or without installing
npx -y github:reporefit/action scan这些命令直接从官方仓库 github.com/reporefit/action 安装。RepoRefit 尚未发布到 npm 注册表,在本页说明之前,请不要从 npm 安装名为 reporefit 的包。
快速开始
在项目文件夹中运行。省略命令时,会对当前文件夹执行 scan。
npx -y github:reporefit/action scan # check the current folder
npx -y github:reporefit/action scan ./my-app --tool secrets --fail-on high
npx -y github:reporefit/action fix > reporefit-fix-plan.md
npx -y github:reporefit/action report --out ./reports
npx -y github:reporefit/action badge
npx -y github:reporefit/action compare ./before ./after
npx -y github:reporefit/action help命令
| 命令 | 作用 |
|---|---|
scan [folder] | 运行检查,按严重程度逐行列出发现,最后给出汇总。 |
fix [folder] | 生成可粘贴到 Claude Code、Codex 等助手中的 AI 修复指令(Markdown)。 |
report [folder] | 生成 reporefit-report.md 和 reporefit-report.json(与网页下载格式相同)。 |
badge [folder] | 生成只含数字的 README 徽章 SVG。 |
compare <before> <after> | 比较项目的两个副本:各规则的发现数和 Claude Code 的预计 Token 数。 |
rules | 列出规则 ID 及其说明页面链接。 |
help, version | 显示带文档链接的用法,或 CLI、引擎和规则版本。 |
选项
| 选项 | 含义 |
|---|---|
--tool <id> | all(默认)、tokens、markdown、secrets、dependencies、mcp、agent-rules、duplicates、architecture 或 deploy。 |
--format text|json|md | scan 的输出格式:text(默认)、json、md。 |
--out <path> | 写入文件(scan、fix、badge)或文件夹(report)。 |
--lang en|ko|ja|zh-Hans | 消息和报告的语言。 |
--fail-on high|medium|low|none | 存在不低于该严重程度的发现时退出码为 1。默认 none。 |
--ignore <glob> | gitignore 语法的额外忽略规则,可重复使用。 |
--no-gitignore | 不应用根目录的 .gitignore 和 .reporefitignore(与网页的文件夹选择范围相同)。 |
--max-files <n> | 列出 n 个文件后停止(默认 50,000),结果标记为部分检查。 |
--max-read-mb <n> | 读取 n MiB 文本后停止(默认 512),结果标记为部分检查。 |
--quiet | 隐藏进度行(仅在终端中显示)。 |
Windows、macOS、Linux
- Windows:在 PowerShell 或 Windows 终端中运行,路径可用 \ 或 /。
- macOS、Linux:任意 shell 都可以。不想全局安装时使用
npx -y github:reporefit/action。 - 不会跟随符号链接和连接点,检查不会离开你选择的文件夹。
退出码
| 代码 | 含义 |
|---|---|
0 | 没有不低于 --fail-on 的发现(或 --fail-on none)。 |
1 | 至少有一个不低于 --fail-on 的发现。 |
2 | 选项错误,或无法读取文件夹。 |
130 | 按 Ctrl+C 中止,不输出部分结果。 |
大型项目
CLI 只在规则需要时读取文件,每个文件最多读取一次。不会进入 .git、node_modules 和常见的构建、缓存文件夹。会应用根目录的 .gitignore 和 .reporefitignore,也可以用 --ignore 添加规则。
达到上限时,报告会说明并列出未读取的范围。部分检查绝不会显示为全部通过。
# .reporefitignore (gitignore syntax, read in addition to the root .gitignore)
fixtures/
**/*.snap
docs/generated/实测(2026-12-01,Windows 11,Node 24):30,500 个文件用时 16 秒,内存约 250 MB。更大的项目也能在上述上限内运行,但未经实测。
供 AI 编程代理使用
Claude Code、Codex 等代理可以运行 CLI 并读取 --format json。JSON 包含模式版本,以及每个发现的规则 ID、严重程度、置信度、文件和行号、已遮蔽的证据、建议的修复和验证方法。请用退出码判断通过或失败。
reporefit scan --format json --quiet > reporefit.json
# exit code: 0 ok, 1 findings at or above --fail-on, 2 usage/read error, 130 cancelled隐私
CLI 只读取你电脑上的文件,不上传任何内容,也不发出网络请求。依赖漏洞查询(OSV)只在网页检查器中、且在你同意后使用。