CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

c8

$ c8 社区开源 低风险
bcoe · 代码托管与研发协同 · ISC · macos / linux / windows

c8 通过 NODE_V8_COVERAGE 直接采集原生 V8 代码覆盖率,无需 Babel/Istanbul AST 插桩开销,并借助 Istanbul 报告器输出 --reporter=json、--reporter=json-summary 与 --reporter=text 文本摘要,支持 --check-coverage 门禁检查。

FCRS-1.0 综合评分
81 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
npm install -D c8
CLI vs MCP 选型建议 仅 CLI 可用

本地 Node.js V8 覆盖率包装器,直接包裹 node、mocha 或 node --test 执行。

Agent 友好度体检单

✓ 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
— 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 21 / 25

完全非交互,支持 --reporter=json、--reporter=json-summary 与 --check-coverage 门禁退出码。

  • Native --reporter=json and --reporter=json-summary
  • --check-coverage returns non-zero on threshold failure
安全与权限边界 20 / 25

本地无认证运行;包裹测试命令执行,默认仅在 coverage/ 目录写报告(可通过 --reports-dir 指定)。

  • Bounded local file writes under coverage/
安装与运行摩擦 13 / 15

轻量级 npm / npx 包,无原生编译绑定,兼容 macOS、Linux 与 Windows 上的 Node.js 12+。

  • Zero native compiler bindings; pure Node.js wrapper
能力覆盖与边际价值 12 / 15

零插桩高速采集 V8 覆盖率,非常适合配合 node --test、mocha、ava 与脚本工具。

  • Leverages Node.js built-in V8 profiler without code transforms
维护与来源背书 7 / 10

由 Benjamin Coe(bcoe/c8)维护,ISC 协议开源,常与 node --test 及 mocha 配合使用。

  • Standard V8 coverage CLI in the Node.js ecosystem
文档与可验证性 8 / 10

README 与 --help 对参数及 .c8rc.json 配置描述简洁明了。

  • Clear flag reference in --help and README

安全边界、鉴权与放权指南

鉴权方式
无需鉴权
凭证存储位置

无需凭证;仅在本地 coverage/ 目录写入临时 V8 覆盖率 JSON 文件。

潜在副作用
只读查询 本地写入
费用与配额提示

ISC 开源 Node.js CLI,完全免费。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# c8 Agent Rules
- Combine `--reporter=json-summary` with `--reporter=text` for compact machine-readable totals.
- Use `--clean` (default) or `c8 report` when inspecting existing V8 coverage output.
- Pass `--all` only when uncovered files should count toward project totals.

Agent 高频安全命令配方

只读查询(安全推荐)

将已有 V8 覆盖率数据导出为 JSON 摘要
npx c8 report --reporter=json-summary

读取已采集的 V8 覆盖率数据并生成精简的 coverage-summary.json,无需重跑测试。

受控写入与预演

开启 V8 覆盖率运行测试并校验阈值
npx c8 --reporter=text --reporter=json-summary --check-coverage --lines 80 node --test

在 V8 覆盖率下执行 Node 内置测试运行器,写入 coverage/coverage-summary.json,并在行覆盖低于 80% 时失败退出。

核心优势

  • + 基于 Node.js 原生 V8 覆盖率,无 AST/Babel 插桩性能损耗。
  • + --reporter=json-summary 生成体积小巧的 JSON 汇总,方便 Agent 校验。
  • + --check-coverage 可直接校验行、分支与函数覆盖率阈值。

注意事项与踩坑点

  • ! JSON 报告默认写入 coverage/ 目录而非直接输出至标准输出。
  • ! TypeScript 或转译代码的映射精度依赖 --enable-source-maps 或完整 source map。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI