一键导入
test-audit
Test coverage analysis to ensure adequate testing, Storybook coverage, and test quality.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Test coverage analysis to ensure adequate testing, Storybook coverage, and test quality.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Comprehensive static code analysis to enforce architectural patterns, conventions, and code quality standards.
Architecture dependency analysis to ensure proper feature isolation and composition root pattern.
Comprehensive documentation generation through automated codebase analysis, pattern detection, and diagram creation.
Dependency health analysis to detect outdated packages and unused dependencies.
Safe minor dependency updates with validation (lint/test/build) and automatic rollback on failure.
Security vulnerability analysis to detect hardcoded secrets, dangerous patterns, and unsafe code practices.
| name | test-audit |
| description | Test coverage analysis to ensure adequate testing, Storybook coverage, and test quality. |
Analyze test coverage in your codebase to ensure:
Rule: Maintain at least 60% test coverage baseline for business logic.
Analyzes:
Coverage Calculation:
.test.ts(x) or .spec.ts(x) filesExample:
Coverage Summary
--------------------------------------------------------------------------------
Total source files: 150
Test files: 95 (63%)
Story files: 45 (30%)
Tested files: 105
Untested files: 45
Coverage estimate: ~70%
✅ Test coverage is 70% (>= 60% threshold)
Recommendations:
.test.ts(x) files for business logicCheck: check_test_coverage.mjs
Rule: Maintain at least 40% story coverage for UI components.
Analyzes:
Detection:
components/ or ui/ directories.stories.ts(x) files to componentsExample:
Story Coverage Summary
--------------------------------------------------------------------------------
Total components: 60
Story files: 28
Components without stories: 32
Story coverage: ~47%
✅ Story coverage is 47% (>= 40% threshold)
Benefits of Storybook:
Recommendations:
.stories.ts(x) for reusable UI componentsCheck: check_story_coverage.mjs
Rule: Test files should not contain TODO/FIXME/HACK comments.
Why: Incomplete tests indicate gaps in coverage and technical debt.
Detects:
Violations:
// ❌ WRONG - TODO in test file
test('should handle edge case', () => {
// TODO: Implement this test
});
// ❌ WRONG - FIXME indicates broken test
test('should update user', () => {
// FIXME: This test is flaky
});
// ✅ CORRECT - Complete tests only
test('should handle edge case', () => {
const result = handleEdgeCase(input);
expect(result).toBe(expected);
});
// ✅ CORRECT - Use test.skip for intentionally skipped tests
test.skip('should handle future feature', () => {
// Test for future implementation
});
Impact:
Recommendations:
Check: check_test_todos.mjs
node ./.claude/skills/test-audit/scripts/run_all_checks.mjs
# Test coverage check
node ./.claude/skills/test-audit/scripts/check_test_coverage.mjs
# Storybook coverage check
node ./.claude/skills/test-audit/scripts/check_story_coverage.mjs
# Test TODOs check
node ./.claude/skills/test-audit/scripts/check_test_todos.mjs
To save a comprehensive markdown report of all checks:
node ./.claude/skills/test-audit/scripts/generate_report.mjs
Output: reports/{YYYY-MM-DD_HH-MM}/test-audit-report.md
Report includes:
Environment variable:
# Custom report directory
export REPORT_DIR="reports/my-custom-timestamp"
node ./.claude/skills/test-audit/scripts/generate_report.mjs
Usage patterns:
# Option 1: Console output only (default)
node ./.claude/skills/test-audit/scripts/run_all_checks.mjs
# Option 2: Console output + Save report
node ./.claude/skills/test-audit/scripts/generate_report.mjs
# Option 3: Specific check only
node ./.claude/skills/test-audit/scripts/check_test_coverage.mjs
Report structure:
reports/
└── 2025-11-01_14-30/ # Includes hours and minutes for multiple runs per day
├── test-audit-report.md # This skill's report
├── security-audit-report.md # Security audit (separate)
├── code-audit-report.md # Code quality audit (separate)
├── arch-audit-report.md # Architecture audit (separate)
└── ... # Other reports
Each check produces:
Example output:
Test Coverage Check
================================================================================
Coverage Summary
--------------------------------------------------------------------------------
Total source files: 150
Test files: 95 (63%)
Story files: 45 (30%)
Tested files: 105
Untested files: 45
Coverage estimate: ~70%
✅ Test coverage is 70% (>= 60% threshold)
================================================================================
Summary: Coverage at 70%
reports/{timestamp}/test-audit-report.md (only when generating reports)reports/ directory