cover

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Cover — Test Suite Generator

Cover — 测试套件生成器

Generate comprehensive test suites for existing code with real-service integration testing and automated failure healing.
为现有代码生成全面的测试套件,支持真实服务集成测试和失败用例自动修复。

Quick Start

快速开始

bash
/ork:cover authentication flow
/ork:cover --model=opus payment processing
/ork:cover --tier=unit,integration user service
/ork:cover --real-services checkout pipeline
bash
/ork:cover authentication flow
/ork:cover --model=opus payment processing
/ork:cover --tier=unit,integration user service
/ork:cover --real-services checkout pipeline

Argument Resolution

参数解析

python
SCOPE = "$ARGUMENTS"  # e.g., "authentication flow"
python
SCOPE = "$ARGUMENTS"  # 示例:"authentication flow"

Flag parsing

标志解析

MODEL_OVERRIDE = None TIERS = ["unit", "integration", "e2e"] # default: all three REAL_SERVICES = False
for token in "$ARGUMENTS".split(): if token.startswith("--model="): MODEL_OVERRIDE = token.split("=", 1)[1] SCOPE = SCOPE.replace(token, "").strip() elif token.startswith("--tier="): TIERS = token.split("=", 1)[1].split(",") SCOPE = SCOPE.replace(token, "").strip() elif token == "--real-services": REAL_SERVICES = True SCOPE = SCOPE.replace(token, "").strip()

---
MODEL_OVERRIDE = None TIERS = ["unit", "integration", "e2e"] # 默认:三个层级都包含 REAL_SERVICES = False
for token in "$ARGUMENTS".split(): if token.startswith("--model="): MODEL_OVERRIDE = token.split("=", 1)[1] SCOPE = SCOPE.replace(token, "").strip() elif token.startswith("--tier="): TIERS = token.split("=", 1)[1].split(",") SCOPE = SCOPE.replace(token, "").strip() elif token == "--real-services": REAL_SERVICES = True SCOPE = SCOPE.replace(token, "").strip()

---

Step -0.5: Effort-Aware Coverage Scaling (CC 2.1.76)

步骤-0.5:基于工作量的覆盖率调整(CC 2.1.76)

Scale test generation depth based on
/effort
level:
Effort LevelTiers GeneratedAgentsHeal Iterations
lowUnit only1 agent1 max
mediumUnit + Integration2 agents2 max
high (default)Unit + Integration + E2E3 agents3 max
Override: Explicit
--tier=
flag or user selection overrides
/effort
downscaling.
根据
/effort
级别调整测试生成的深度:
工作量级别生成的测试层级Agent数量最大修复迭代次数
仅单元测试1个Agent1次
单元测试 + 集成测试2个Agent2次
(默认)单元测试 + 集成测试 + E2E测试3个Agent3次
覆盖规则: 显式的
--tier=
标志或用户选择会覆盖
/effort
的降级设置。

Step -1: MCP Probe + Resume Check

步骤-1:MCP探测与续检查

python
undefined
python
undefined

Probe MCPs (parallel):

并行探测MCP:

ToolSearch(query="select:mcp__memory__search_nodes") ToolSearch(query="select:mcp__context7__resolve-library-id")
Write(".claude/chain/capabilities.json", { "memory": <true if found>, "context7": <true if found>, "skill": "cover", "timestamp": now() })
ToolSearch(query="select:mcp__memory__search_nodes") ToolSearch(query="select:mcp__context7__resolve-library-id")
Write(".claude/chain/capabilities.json", { "memory": <true if found>, "context7": <true if found>, "skill": "cover", "timestamp": now() })

Resume check:

续检查:

Read(".claude/chain/state.json")
Read(".claude/chain/state.json")

If exists and skill == "cover": resume from current_phase

如果存在且skill == "cover": 从当前阶段续

Otherwise: initialize state

否则: 初始化状态


---

---

Step 0: Scope & Tier Selection

步骤0:范围与层级选择

python
AskUserQuestion(
  questions=[
    {
      "question": "What test tiers should I generate?",
      "header": "Test Tiers",
      "options": [
        {"label": "Full coverage (Recommended)", "description": "Unit + Integration (real services) + E2E", "markdown": "```\nFull Coverage\n─────────────\n  Unit            Integration       E2E\n  ┌─────────┐    ┌─────────────┐  ┌──────────┐\n  │ AAA     │    │ Real DB     │  │Playwright│\n  │ Mocks   │    │ Real APIs   │  │Page obj  │\n  │ Factory │    │ Testcontain │  │A11y      │\n  └─────────┘    └─────────────┘  └──────────┘\n  3 parallel test-generator agents\n```"},
        {"label": "Unit + Integration", "description": "Skip E2E, focus on logic and service boundaries", "markdown": "```\nUnit + Integration\n──────────────────\n  Unit tests for business logic\n  Integration tests at API boundaries\n  Real services if docker-compose found\n  Skip: browser automation\n```"},
        {"label": "Unit only", "description": "Fast isolated tests for business logic", "markdown": "```\nUnit Only (~2 min)\n──────────────────\n  AAA pattern tests\n  MSW/VCR mocking\n  Factory-based data\n  Coverage gap analysis\n  Skip: real services, browser\n```"},
        {"label": "Integration only", "description": "API boundary and real-service tests", "markdown": "```\nIntegration Only\n────────────────\n  API endpoint tests (Supertest/httpx)\n  Database tests (real or in-memory)\n  Contract tests (Pact)\n  Testcontainers if available\n```"},
        {"label": "E2E only", "description": "Playwright browser tests", "markdown": "```\nE2E Only\n────────\n  Playwright page objects\n  User flow tests\n  Visual regression\n  Accessibility (axe-core)\n```"}
      ],
      "multiSelect": false
    },
    {
      "question": "Healing strategy for failing tests?",
      "header": "Failure Handling",
      "options": [
        {"label": "Auto-heal (Recommended)", "description": "Fix failing tests up to 3 iterations"},
        {"label": "Generate only", "description": "Write tests, report failures, don't fix"},
        {"label": "Strict", "description": "All tests must pass or abort"}
      ],
      "multiSelect": false
    }
  ]
)
Override TIERS based on selection. Skip this step if
--tier=
flag was provided.

python
AskUserQuestion(
  questions=[
    {
      "question": "我应该生成哪些测试层级?",
      "header": "测试层级",
      "options": [
        {"label": "全面覆盖(推荐)", "description": "单元测试 + 集成测试(真实服务) + E2E测试", "markdown": "```\n全面覆盖\n─────────────\n  单元测试            集成测试       E2E测试\n  ┌─────────┐    ┌─────────────┐  ┌──────────┐\n  │ AAA     │    │ 真实数据库  │  │Playwright│\n  │ 模拟桩  │    │ 真实API     │  │页面对象  │\n  │ 工厂模式│    │ Testcontain │  │无障碍测试│\n  └─────────┘    └─────────────┘  └──────────┘\n  3个并行测试生成Agent\n```"},
        {"label": "单元测试 + 集成测试", "description": "跳过E2E测试,专注于逻辑和服务边界", "markdown": "```\n单元测试 + 集成测试\n──────────────────\n  针对业务逻辑的单元测试\n  API边界的集成测试\n  若找到docker-compose则使用真实服务\n  跳过:浏览器自动化\n```"},
        {"label": "仅单元测试", "description": "针对业务逻辑的快速隔离测试", "markdown": "```\n仅单元测试(约2分钟)\n──────────────────\n  AAA模式测试\n  MSW/VCR模拟\n  工厂模式测试数据\n  覆盖率缺口分析\n  跳过:真实服务、浏览器\n```"},
        {"label": "仅集成测试", "description": "API边界和真实服务测试", "markdown": "```\n仅集成测试\n────────────────\n  API端点测试(Supertest/httpx)\n  数据库测试(真实或内存型)\n  契约测试(Pact)\n  若可用则使用Testcontainers\n```"},
        {"label": "仅E2E测试", "description": "Playwright浏览器测试", "markdown": "```\n仅E2E测试\n────────\n  Playwright页面对象\n  用户流程测试\n  视觉回归测试\n  无障碍测试(axe-core)\n```"}
      ],
      "multiSelect": false
    },
    {
      "question": "失败测试的修复策略?",
      "header": "失败处理",
      "options": [
        {"label": "自动修复(推荐)", "description": "修复失败的测试,最多3次迭代"},
        {"label": "仅生成", "description": "编写测试,报告失败,但不修复"},
        {"label": "严格模式", "description": "所有测试必须通过,否则终止"}
      ],
      "multiSelect": false
    }
  ]
)
根据用户选择覆盖TIERS设置。如果已提供
--tier=
标志,则跳过此步骤。

Task Management (MANDATORY)

任务管理(必填)

python
TaskCreate(
  subject=f"Cover: {SCOPE}",
  description="Generate comprehensive test suite with real-service testing",
  activeForm=f"Generating tests for {SCOPE}"
)
python
TaskCreate(
  subject=f"Cover: {SCOPE}",
  description="生成包含真实服务测试的全面测试套件",
  activeForm=f"正在为{SCOPE}生成测试"
)

Subtasks per phase

各阶段子任务

TaskCreate(subject="Discover scope and detect frameworks", activeForm="Discovering test scope") TaskCreate(subject="Analyze coverage gaps", activeForm="Analyzing coverage gaps") TaskCreate(subject="Generate tests (parallel per tier)", activeForm="Generating tests") TaskCreate(subject="Execute generated tests", activeForm="Running tests") TaskCreate(subject="Heal failing tests", activeForm="Healing test failures") TaskCreate(subject="Generate coverage report", activeForm="Generating report")

---
TaskCreate(subject="发现范围并检测框架", activeForm="正在发现测试范围") TaskCreate(subject="分析覆盖率缺口", activeForm="正在分析覆盖率缺口") TaskCreate(subject="生成测试(按层级并行)", activeForm="正在生成测试") TaskCreate(subject="执行生成的测试", activeForm="正在运行测试") TaskCreate(subject="修复失败的测试", activeForm="正在修复测试失败") TaskCreate(subject="生成覆盖率报告", activeForm="正在生成报告")

---

6-Phase Workflow

6阶段工作流

PhaseActivitiesOutput
1. DiscoveryDetect frameworks, scan scope, find untested codeFramework map, file list
2. Coverage AnalysisRun existing tests, map gaps per tierCoverage baseline, gap map
3. GenerationParallel test-generator agents per tierTest files created
4. ExecutionRun all generated testsPass/fail results
5. HealFix failures, re-run (max 3 iterations)Green test suite
6. ReportCoverage delta, test count, summaryCoverage report
阶段活动输出
1. 发现检测框架、扫描范围、查找未测试代码框架映射、文件列表
2. 覆盖率分析运行现有测试、按层级映射缺口覆盖率基线、缺口映射
3. 生成为每个层级启动并行测试生成Agent创建测试文件
4. 执行运行所有生成的测试测试通过/失败结果
5. 修复修复失败用例、重新运行(最多3次迭代)全部通过的测试套件
6. 报告覆盖率变化、测试数量、总结覆盖率报告

Phase Handoffs

阶段交付

After PhaseHandoff FileKey Outputs
1. Discovery
01-cover-discovery.json
Frameworks, scope files, tier plan
2. Analysis
02-cover-analysis.json
Baseline coverage, gap map
3. Generation
03-cover-generation.json
Files created, test count per tier
5. Heal
05-cover-healed.json
Final pass/fail, iterations used

阶段完成后交付文件关键输出
1. 发现
01-cover-discovery.json
框架、范围文件、层级计划
2. 分析
02-cover-analysis.json
基线覆盖率、缺口映射
3. 生成
03-cover-generation.json
创建的文件、各层级测试数量
5. 修复
05-cover-healed.json
最终通过/失败情况、使用的迭代次数

Phase 1: Discovery

阶段1:发现

Detect the project's test infrastructure and scope the work.
python
undefined
检测项目的测试基础设施并确定工作范围。
python
undefined

PARALLEL — all in ONE message:

并行执行 — 全部在一条消息中完成:

1. Framework detection (hook handles this, but also scan manually)

1. 框架检测(钩子会处理,但也手动扫描)

Grep(pattern="vitest|jest|mocha|playwright|cypress", glob="package.json", output_mode="content") Grep(pattern="pytest|unittest|hypothesis", glob="pyproject.toml", output_mode="content") Grep(pattern="pytest|unittest|hypothesis", glob="requirements*.txt", output_mode="content")
Grep(pattern="vitest|jest|mocha|playwright|cypress", glob="package.json", output_mode="content") Grep(pattern="pytest|unittest|hypothesis", glob="pyproject.toml", output_mode="content") Grep(pattern="pytest|unittest|hypothesis", glob="requirements*.txt", output_mode="content")

2. Real-service infrastructure

2. 真实服务基础设施

Glob(pattern="/docker-compose*.yml") Glob(pattern="/testcontainers*") Grep(pattern="testcontainers", glob="/package.json", output_mode="content") Grep(pattern="testcontainers", glob="/requirements*.txt", output_mode="content")
Glob(pattern="/docker-compose*.yml") Glob(pattern="/testcontainers*") Grep(pattern="testcontainers", glob="/package.json", output_mode="content") Grep(pattern="testcontainers", glob="/requirements*.txt", output_mode="content")

3. Existing test structure

3. 现有测试结构

Glob(pattern="/tests//.test.") Glob(pattern="/tests//.spec.") Glob(pattern="/tests//") Glob(pattern="**/test_.py")
Glob(pattern="/tests//.test.") Glob(pattern="/tests//.spec.") Glob(pattern="/tests//") Glob(pattern="**/test_.py")

4. Scope files (what to test)

4. 范围文件(要测试的内容)

If SCOPE specified, find matching source files

如果指定了SCOPE,查找匹配的源文件

Grep(pattern=SCOPE, output_mode="files_with_matches")

**Real-service decision:**
- `docker-compose*.yml` found → integration tests use real services
- `testcontainers` in deps → use testcontainers for isolated service instances
- Neither found + `--real-services` flag → error: "No docker-compose or testcontainers found. Install testcontainers or remove --real-services flag."
- Neither found, no flag → integration tests use mocks (MSW/VCR)

Load real-service detection details: `Read("${CLAUDE_SKILL_DIR}/references/real-service-detection.md")`
Grep(pattern=SCOPE, output_mode="files_with_matches")

**真实服务决策:**
- 找到`docker-compose*.yml` → 集成测试使用真实服务
- 依赖中包含`testcontainers` → 使用testcontainers创建隔离的服务实例
- 都未找到且带有`--real-services`标志 → 错误:"未找到docker-compose或testcontainers。请安装testcontainers或移除--real-services标志。"
- 都未找到且无标志 → 集成测试使用模拟桩(MSW/VCR)

加载真实服务检测详情:`Read("${CLAUDE_SKILL_DIR}/references/real-service-detection.md")`

Phase 2: Coverage Analysis

阶段2:覆盖率分析

Run existing tests and identify gaps.
python
undefined
运行现有测试并识别缺口。
python
undefined

Detect and run coverage command

检测并运行覆盖率命令

TypeScript: npx vitest run --coverage --reporter=json

TypeScript: npx vitest run --coverage --reporter=json

Python: pytest --cov=<scope> --cov-report=json

Python: pytest --cov=<scope> --cov-report=json

Go: go test -coverprofile=coverage.out ./...

Go: go test -coverprofile=coverage.out ./...

Parse coverage output to identify:

解析覆盖率输出以识别:

1. Files with 0% coverage (priority targets)

1. 覆盖率为0%的文件(优先目标)

2. Files below threshold (default 70%)

2. 低于阈值的文件(默认70%)

3. Uncovered functions/methods

3. 未覆盖的函数/方法

4. Untested edge cases (error paths, boundary conditions)

4. 未测试的边缘情况(错误路径、边界条件)


Output coverage baseline to user immediately (progressive output).

立即向用户输出覆盖率基线(渐进式输出)。

Phase 3: Generation (Parallel Agents)

阶段3:生成(并行Agent)

Spawn test-generator agents per tier. Launch ALL in ONE message with
run_in_background=true
.
python
undefined
为每个层级启动测试生成Agent。在一条消息中全部启动并设置
run_in_background=true
python
undefined

Unit tests agent

单元测试Agent

if "unit" in TIERS: Agent( subagent_type="test-generator", prompt=f"""Generate unit tests for: {SCOPE} Coverage gaps: {gap_map.unit_gaps} Framework: {detected_framework} Existing tests: {existing_test_files}
    Focus on:
    - AAA pattern (Arrange-Act-Assert)
    - Parametrized tests for multiple inputs
    - MSW/VCR for HTTP mocking (never mock fetch directly)
    - Factory-based test data (FactoryBoy/faker-js)
    - Edge cases: empty input, errors, timeouts, boundary values
    - Target: 90%+ business logic coverage""",
    isolation="worktree",
    run_in_background=True,
    max_turns=50,
    model=MODEL_OVERRIDE
)
if "unit" in TIERS: Agent( subagent_type="test-generator", prompt=f"""为以下内容生成单元测试: {SCOPE} 覆盖率缺口: {gap_map.unit_gaps} 框架: {detected_framework} 现有测试: {existing_test_files}
    重点关注:
    - AAA模式(Arrange-Act-Assert)
    - 多输入的参数化测试
    - 使用MSW/VCR进行HTTP模拟(切勿直接模拟fetch)
    - 基于工厂模式的测试数据(FactoryBoy/faker-js)
    - 边缘情况:空输入、错误、超时、边界值
    - 目标:业务逻辑覆盖率≥90%""",
    isolation="worktree",
    run_in_background=True,
    max_turns=50,
    model=MODEL_OVERRIDE
)

Integration tests agent

集成测试Agent

if "integration" in TIERS: Agent( subagent_type="test-generator", prompt=f"""Generate integration tests for: {SCOPE} Coverage gaps: {gap_map.integration_gaps} Framework: {detected_framework} Real services available: {real_service_infra}
    Focus on:
    - API endpoint tests (Supertest/httpx)
    - Database tests with {'real DB via testcontainers/docker-compose' if real_services else 'in-memory/mocked DB'}
    - Contract tests (Pact) for service boundaries
    - Zod/Pydantic schema validation at edges
    - Fresh state per test (transaction rollback or cleanup)
    - Target: all API endpoints and service boundaries""",
    isolation="worktree",
    run_in_background=True,
    max_turns=50,
    model=MODEL_OVERRIDE
)
if "integration" in TIERS: Agent( subagent_type="test-generator", prompt=f"""为以下内容生成集成测试: {SCOPE} 覆盖率缺口: {gap_map.integration_gaps} 框架: {detected_framework} 可用真实服务: {real_service_infra}
    重点关注:
    - API端点测试(Supertest/httpx)
    - 数据库测试({使用testcontainers/docker-compose的真实数据库 if real_services else 内存型/模拟数据库})
    - 服务边界的契约测试(Pact)
    - 边缘的Zod/Pydantic schema验证
    - 每个测试的全新状态(事务回滚或清理)
    - 目标:覆盖所有API端点和服务边界""",
    isolation="worktree",
    run_in_background=True,
    max_turns=50,
    model=MODEL_OVERRIDE
)

E2E tests agent

E2E测试Agent

if "e2e" in TIERS: Agent( subagent_type="test-generator", prompt=f"""Generate E2E tests for: {SCOPE} Framework: Playwright Routes/pages: {discovered_routes}
    Focus on:
    - Semantic locators (getByRole > getByLabel > getByTestId)
    - Page Object Model for complex pages
    - User flow tests (happy path + error paths)
    - Accessibility tests (axe-core WCAG 2.2 AA)
    - Visual regression (toHaveScreenshot)
    - No hardcoded waits (use auto-wait)""",
    isolation="worktree",
    run_in_background=True,
    max_turns=50,
    model=MODEL_OVERRIDE
)

Output each agent's results **as soon as it returns** — don't wait for all agents. This lets users see generated tests incrementally.

> **Partial results (CC 2.1.76):** If an agent is killed (timeout, context limit), its response is tagged `[PARTIAL RESULT]`. Include partial tests but flag them in Phase 4.
if "e2e" in TIERS: Agent( subagent_type="test-generator", prompt=f"""为以下内容生成E2E测试: {SCOPE} 框架: Playwright 路由/页面: {discovered_routes}
    重点关注:
    - 语义定位器(getByRole > getByLabel > getByTestId)
    - 复杂页面的页面对象模型
    - 用户流程测试(正常路径 + 错误路径)
    - 无障碍测试(axe-core WCAG 2.2 AA)
    - 视觉回归测试(toHaveScreenshot)
    - 不使用硬编码等待(使用自动等待)""",
    isolation="worktree",
    run_in_background=True,
    max_turns=50,
    model=MODEL_OVERRIDE
)

每个Agent返回结果后立即输出——无需等待所有Agent完成。这样用户可以逐步查看生成的测试。

> **部分结果(CC 2.1.76):** 如果Agent被终止(超时、上下文限制),其响应会标记为`[PARTIAL RESULT]`。包含部分测试但在阶段4中标记。

Phase 4: Execution

阶段4:执行

Run all generated tests and collect results.
python
undefined
运行所有生成的测试并收集结果。
python
undefined

Run test commands per tier (PARALLEL if independent):

按层级运行测试命令(独立测试可并行):

Unit: npx vitest run tests/unit/ OR pytest tests/unit/

单元测试: npx vitest run tests/unit/ 或 pytest tests/unit/

Integration: npx vitest run tests/integration/ OR pytest tests/integration/

集成测试: npx vitest run tests/integration/ 或 pytest tests/integration/

E2E: npx playwright test

E2E测试: npx playwright test

Collect: pass count, fail count, error details, coverage delta

收集:通过数量、失败数量、错误详情、覆盖率变化

undefined
undefined

Phase 5: Heal Loop

阶段5:修复循环

Fix failing tests iteratively. Max 3 iterations to prevent infinite loops.
python
for iteration in range(3):
    if all_tests_pass:
        break

    # For each failing test:
    # 1. Read the test file and the source code it tests
    # 2. Analyze the failure (assertion error? import error? timeout?)
    # 3. Fix the test (not the source code — tests only)
    # 4. Re-run the fixed tests

    # Common fixes:
    # - Wrong assertions (expected value mismatch)
    # - Missing imports or setup
    # - Stale selectors in E2E tests
    # - Race conditions (add proper waits)
    # - Mock configuration errors
Load heal strategy details:
Read("${CLAUDE_SKILL_DIR}/references/heal-loop-strategy.md")
Boundary: heal fixes TESTS, not source code. If a test fails because the source code has a bug, report it — don't silently fix production code.
迭代修复失败的测试。最多3次迭代以防止无限循环。
python
for iteration in range(3):
    if all_tests_pass:
        break

    # 针对每个失败的测试:
    # 1. 读取测试文件及其测试的源代码
    # 2. 分析失败原因(断言错误?导入错误?超时?)
    # 3. 修复测试(仅修复测试,不修改源代码)
    # 4. 重新运行修复后的测试

    # 常见修复:
    # - 错误的断言(预期值不匹配)
    # - 缺少导入或设置
    # - E2E测试中的过时定位器
    # - 竞态条件(添加适当的等待)
    # - 模拟配置错误
加载修复策略详情:
Read("${CLAUDE_SKILL_DIR}/references/heal-loop-strategy.md")
边界规则:修复仅针对测试,不修改源代码。 如果测试失败是因为源代码存在bug,请报告问题——不要静默修复生产代码。

Phase 6: Report

阶段6:报告

Generate coverage report with before/after comparison.
Coverage Report: {SCOPE}
═══════════════════════════

Baseline → After
────────────────
  Unit:        67.2% → 91.3% (+24.1%)
  Integration: 42.0% → 78.5% (+36.5%)
  E2E:          0.0% → 65.0% (+65.0%)
  Overall:     48.4% → 82.1% (+33.7%)

Tests Generated
───────────────
  Unit:        23 tests (18 pass, 5 healed)
  Integration: 12 tests (10 pass, 2 healed)
  E2E:          8 tests (8 pass)
  Total:       43 tests

Heal Iterations: 2/3

Files Created
─────────────
  tests/unit/services/test_auth.py
  tests/unit/services/test_payment.py
  tests/integration/api/test_users.py
  tests/integration/api/test_checkout.py
  tests/e2e/checkout.spec.ts
  tests/e2e/pages/CheckoutPage.ts

Real Services Used: PostgreSQL (testcontainers), Redis (docker-compose)

Remaining Gaps
──────────────
  - src/services/notification.ts (0% — no tests generated, out of scope)
  - src/utils/crypto.ts (45% — edge cases not covered)

Next Steps
──────────
  /ork:verify {SCOPE}    # Grade the implementation + tests
  /ork:commit             # Commit generated tests
  /loop 10m npm test -- --coverage  # Watch coverage while coding
生成包含前后对比的覆盖率报告。
覆盖率报告: {SCOPE}
═══════════════════════════

基线 → 生成后
────────────────
  单元测试:        67.2% → 91.3% (+24.1%)
  集成测试: 42.0% → 78.5% (+36.5%)
  E2E测试:          0.0% → 65.0% (+65.0%)
  整体:     48.4% → 82.1% (+33.7%)

生成的测试数量
───────────────
  单元测试:        23个测试(18个通过,5个修复)
  集成测试: 12个测试(10个通过,2个修复)
  E2E测试:          8个测试(全部通过)
  总计:       43个测试

修复迭代次数: 2/3

创建的文件
─────────────
  tests/unit/services/test_auth.py
  tests/unit/services/test_payment.py
  tests/integration/api/test_users.py
  tests/integration/api/test_checkout.py
  tests/e2e/checkout.spec.ts
  tests/e2e/pages/CheckoutPage.ts

使用的真实服务: PostgreSQL(testcontainers)、Redis(docker-compose)

剩余缺口
──────────────
  - src/services/notification.ts(0% — 未生成测试,超出范围)
  - src/utils/crypto.ts(45% — 边缘情况未覆盖)

下一步建议
──────────
  /ork:verify {SCOPE}    # 评估实现与测试
  /ork:commit             # 提交生成的测试
  /loop 10m npm test -- --coverage  # 编码时监控覆盖率

Coverage Drift Monitor (CC 2.1.71)

覆盖率漂移监控(CC 2.1.71)

Optionally schedule weekly coverage drift detection:
python
undefined
可选择每周调度覆盖率漂移检测:
python
undefined

Guard: Skip cron in headless/CI (CLAUDE_CODE_DISABLE_CRON)

防护:在无头/CI环境中跳过定时任务(CLAUDE_CODE_DISABLE_CRON)

if env CLAUDE_CODE_DISABLE_CRON is set, run a single check instead

如果设置了环境变量CLAUDE_CODE_DISABLE_CRON,改为运行单次检查

CronCreate( schedule="0 2 * * 0", prompt="Weekly coverage drift check for {SCOPE}: npm test -- --coverage. If coverage >= baseline → CronDelete. If coverage drops > 5% → alert with regression details and recommendation." )

---
CronCreate( schedule="0 2 * * 0", prompt="{SCOPE}的每周覆盖率漂移检查: npm test -- --coverage. 如果覆盖率≥基线 → 删除定时任务. 如果覆盖率下降>5% → 发送告警,包含回归详情和建议." )

---

Key Principles

核心原则

  • Output limits (CC 2.1.77+): Opus 4.6 defaults to 64k output tokens (128k upper bound). For large test suites, chunk generation across multiple agent turns if output approaches the limit.
  • Tests only — never modify production source code, only generate test files
  • Real services when available — prefer testcontainers/docker-compose over mocks for integration tests because mock/prod divergence causes silent failures in production
  • Parallel generation — spawn one test-generator agent per tier in ONE message
  • Heal, don't loop forever — max 3 iterations, then report remaining failures
  • Progressive output — show results as each agent completes
  • Factory over fixtures — use FactoryBoy/faker-js for test data, not hardcoded values
  • Mock at network level — MSW/VCR, never mock fetch/axios directly

  • 输出限制(CC 2.1.77+): Opus 4.6默认输出令牌上限为64k(最高128k)。对于大型测试套件,如果输出接近限制,可跨多个Agent轮次分块生成。
  • 仅生成测试 — 绝不修改生产源代码,仅生成测试文件
  • 优先使用真实服务 — 集成测试优先使用testcontainers/docker-compose而非模拟桩,因为模拟与生产环境的差异会导致生产中的静默失败
  • 并行生成 — 在一条消息中为每个层级启动一个测试生成Agent
  • 修复但不过度循环 — 最多3次迭代,然后报告剩余失败
  • 渐进式输出 — 每个Agent完成后立即显示结果
  • 工厂模式优先于固定装置 — 使用FactoryBoy/faker-js生成测试数据,而非硬编码值
  • 在网络层模拟 — 使用MSW/VCR,绝不直接模拟fetch/axios

Related Skills

相关技能

  • ork:implement
    — generates tests during implementation (Phase 5); use
    /ork:cover
    after for deeper coverage
  • ork:verify
    — grades existing tests 0-10; chain:
    implement → cover → verify
  • testing-unit
    /
    testing-integration
    /
    testing-e2e
    — knowledge skills loaded by test-generator agents
  • ork:commit
    — commit generated test files
  • ork:implement
    — 在实现过程中生成测试(阶段5);之后使用
    /ork:cover
    获得更深度的覆盖率
  • ork:verify
    — 为现有测试评分0-10;流程衔接:
    implement → cover → verify
  • testing-unit
    /
    testing-integration
    /
    testing-e2e
    — 测试生成Agent加载的知识技能
  • ork:commit
    — 提交生成的测试文件

References

参考资料

Load on demand with
Read("${CLAUDE_SKILL_DIR}/references/<file>")
:
FileContent
real-service-detection.md
Docker-compose/testcontainers detection, service startup, teardown
heal-loop-strategy.md
Failure classification, fix patterns, iteration budget
coverage-report-template.md
Report format, delta calculation, gap analysis

Version: 1.0.0 (March 2026) — Initial release
按需加载:
Read("${CLAUDE_SKILL_DIR}/references/<file>")
:
文件内容
real-service-detection.md
Docker-compose/testcontainers检测、服务启动、销毁
heal-loop-strategy.md
失败分类、修复模式、迭代预算
coverage-report-template.md
报告格式、变化计算、缺口分析

版本: 1.0.0(2026年3月) — 初始版本