Token导航 LogoToken导航

Agent Skill · 研究检索

tdd-guide(TDD 指南)

tdd-guide 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

tdd-guide 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 34,331。

总安装 2,235周安装 96GitHub Stars 103下载 783核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:tdd-guide(TDD 指南)
来源仓库:https://github.com/borghei/claude-skills
仓库路径:skills/tdd-guide
安装命令:
npx skills add https://github.com/borghei/claude-skills --skill tdd-guide
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/borghei/claude-skills --skill tdd-guide

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

提供测试驱动开发(TDD)全流程指导与自动化反馈机制。支持覆盖率统计、失败测试分析与优先级排序建议。适用于提升代码质量与开发效率的工程实践场景。tdd-guide 属于研究检索类 Skill,可作为该场景下的辅助能力补充。输出格式适配终端、Markdown 或 JSON 多种环境。

建议结合具体项目指标设定合理的测试阈值标准。

来源仓库内路径:skills/tdd-guide

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/borghei/claude-skills --skill tdd-guide;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

tdd-guide 怎么安装?

在终端执行 npx skills add https://github.com/borghei/claude-skills --skill tdd-guide。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

tdd-guide 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

tdd-guide 需要什么权限?

权限级别是操作浏览器。该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

tdd-guide 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

tdd-guide 用的人多吗?

公开数据是累计安装 2,235 次,近一周安装 96 次,下载 783 次,GitHub 103 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

tdd-guide 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
tdd-guide

TDD 指南 · 本页

2,235103操作浏览器未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

TDD Guide

The agent guides red-green-refactor TDD workflows, generates framework-specific test stubs from requirements, parses coverage reports to identify prioritized gaps, and calculates test quality metrics including smell detection and assertion density. Supports Jest, Pytest, JUnit, Vitest, and Mocha.

Quick Start

# Generate test cases from requirements (Python API)
from test_generator import TestGenerator, TestFramework
gen = TestGenerator(framework=TestFramework.PYTEST, language="python")
cases = gen.generate_from_requirements(requirements)

# Analyze coverage gaps from LCOV report
from coverage_analyzer import CoverageAnalyzer
analyzer = CoverageAnalyzer()
analyzer.parse_coverage_report(content, "lcov")
gaps = analyzer.identify_gaps(threshold=80.0)

# Guide TDD cycle
from tdd_workflow import TDDWorkflow
wf = TDDWorkflow()
wf.start_cycle("User can reset password via email")

Core Workflows

Workflow 1: TDD a New Feature

  1. Write a failing test for the feature requirement (RED phase)
  2. Call validate_red_phase() -- confirms test exists and fails
  3. Write minimal code to make the test pass (GREEN phase)
  4. Call validate_green_phase() -- confirms all tests pass
  5. Refactor while keeping tests green (REFACTOR phase)
  6. Call validate_refactor_phase() -- confirms tests still pass after cleanup
  7. Validation checkpoint: Each cycle completes in under 10 minutes; zero test smells introduced

Workflow 2: Analyze Coverage Gaps

  1. Generate coverage report: npm test -- --coverage or pytest --cov
  2. Detect format with detect_format() and parse with parse_coverage_report()
  3. Run identify_gaps(threshold=80.0) to get prioritized file list (P0/P1/P2)
  4. Generate test stubs for P0 files (business-critical, lowest coverage)
  5. Validation checkpoint: Line coverage >= 80%; branch coverage >= 70%; zero P0 gaps in critical paths

Workflow 3: Generate Tests from Requirements

  1. Structure requirements as user stories with acceptance criteria
  2. Call generate_from_requirements() with target framework
  3. Review generated test cases for completeness (happy path, error, edge cases)
  4. Generate test file with generate_test_file()
  5. Validation checkpoint: Each acceptance criterion has at least one test; all tests compile

Tools

ToolPurpose
test_generator.pyGenerate test cases from requirements/specs
coverage_analyzer.pyParse LCOV/JSON/XML reports, find gaps
tdd_workflow.pyGuide red-green-refactor cycles
framework_adapter.pyConvert tests between frameworks
fixture_generator.pyGenerate test data and mocks with seeds
metrics_calculator.pyCalculate complexity and test quality
format_detector.pyAuto-detect language and framework
output_formatter.pyFormat output for CLI/desktop/CI

Anti-Patterns

  • Tests that pass immediately -- a test with no real assertion or assert True skips the RED phase; every test must fail before implementation
  • Testing implementation details -- coupling tests to internal method names makes refactoring break tests; test behavior and outputs, not internals
  • Non-deterministic fixtures -- random data without a seed produces different failures across CI runs; always pass seed=<int> to FixtureGenerator
  • Skipping the refactor phase -- GREEN code that works but is messy accumulates; refactoring is not optional in TDD
  • Coverage theater -- writing tests that hit lines without meaningful assertions; use metrics_calculator.py to detect low assertion density
  • Conditional test logic -- if/else inside tests masks failures; each test should have a single clear path

Troubleshooting

ProblemCauseSolution
Generated tests pass immediately (no RED phase)Test has no real assertion or asserts a trivially true valueEnsure every test contains an assertion against the actual unit under test; remove placeholder assert True stubs before running
Coverage report fails to parseReport format does not match the expected LCOV, JSON, or XML structureRun format_detector.py first to verify the detected format; convert non-standard reports (e.g., Clover) to Cobertura XML
Framework adapter produces wrong import styleSource and target framework were swapped, or language/framework mismatchVerify the framework and language arguments match your project; use detect_framework() on existing test code to auto-detect
Fixture generator produces non-deterministic dataNo random seed was supplied, so each run yields different valuesPass seed=<int> to FixtureGenerator() for reproducible fixtures across CI runs
Metrics calculator reports 0 test functionsTest code uses an unsupported naming convention (e.g., spec_ prefix)Rename tests to follow test_* / it() / @Test conventions, or extend the regex patterns in _count_test_functions()
TDD workflow validates GREEN phase but tests still fail locallyTest result dict passed to validate_green_phase() has status not set to "passed"Ensure your test runner output is normalized to {"status": "passed"} or {"status": "failed"} before passing it in
Coverage gaps list is empty despite low overall coverageAll individual files meet the threshold even though the aggregate does notLower the threshold argument in identify_gaps() or inspect per-file coverage with get_file_coverage()

Success Criteria

  • Test-first ratio above 80% -- at least 4 out of every 5 features begin with a failing test before any implementation code is written.
  • Red-green-refactor cycle under 10 minutes -- each TDD micro-cycle (write failing test, make it pass, refactor) completes within a single focused interval.
  • Line coverage at or above 80% -- measured by coverage_analyzer.py against LCOV/JSON/XML reports, with branch coverage at or above 70%.
  • Test quality score at or above 75/100 -- as reported by metrics_calculator.py, combining assertion density, isolation, naming quality, and absence of test smells.
  • Zero P0 coverage gaps in critical paths -- business-critical modules (auth, payments, data persistence) have no files flagged P0 by identify_gaps().
  • Test smell count of zero for high-severity items -- no missing_assertions, sleepy_test, or conditional_test_logic smells detected at high severity.
  • Fixture reproducibility across CI -- all generated fixtures use a fixed seed and produce identical output on every pipeline run.

Scope & Limitations

This skill covers:

  • Unit test generation, scaffolding, and stub creation for Jest, Pytest, JUnit, Vitest, and Mocha
  • Static coverage report parsing (LCOV, JSON/Istanbul, XML/Cobertura) with gap identification and prioritized recommendations
  • Red-green-refactor workflow guidance with phase validation and cycle tracking
  • Test quality assessment including complexity analysis, isolation scoring, naming quality, and test smell detection

This skill does NOT cover:

  • Integration, end-to-end, or performance test generation -- see senior-qa for E2E patterns and senior-devops for load testing
  • Runtime test execution or live coverage measurement -- scripts perform static analysis only; you must run your test suite externally
  • Visual/snapshot testing or browser-based test workflows -- use Playwright, Cypress, or Storybook for UI-level testing
  • Security-focused test generation (fuzz testing, penetration testing) -- see senior-security and senior-secops skills

Integration Points

SkillIntegrationData Flow
senior-qaGenerated test stubs feed into QA review workflows; QA coverage standards inform threshold settingstest_generator.py output → QA review → approved test suite
code-reviewerMetrics calculator output provides quantitative data for code review checklistsmetrics_calculator.py quality report → code review scoring
senior-fullstackScaffolded projects include test infrastructure; TDD guide generates tests for scaffolded modulesproject_scaffolder.py output → test_generator.py input
senior-devopsCoverage reports from CI pipelines are parsed by coverage analyzer; recommendations feed back into pipeline gatesCI coverage artifact → coverage_analyzer.py → pass/fail gate
senior-securityEdge-case fixtures for auth and API scenarios complement security-focused test plansfixture_generator.py auth/API edge cases → security test plan
tech-stack-evaluatorFramework detection informs stack evaluation; test quality metrics feed into technology assessmentformat_detector.py analysis → stack evaluation input

Tool Reference

1. test_generator.py

Purpose: Generate test cases from requirements, user stories, and API specs, then produce framework-specific test stubs and complete test files.

Module: TestGenerator class

Usage:

from test_generator import TestGenerator, TestFramework, TestType

gen = TestGenerator(framework=TestFramework.PYTEST, language="python")
cases = gen.generate_from_requirements(requirements, test_type=TestType.UNIT)
stub = gen.generate_test_stub(cases[0])
file_content = gen.generate_test_file("my_module", cases)
suggestions = gen.suggest_missing_scenarios(existing_tests, code_analysis)

Constructor Parameters:

ParameterTypeRequiredDescription
frameworkTestFrameworkYesTarget framework: JEST, VITEST, PYTEST, JUNIT, MOCHA
languagestrYesProgramming language: typescript, javascript, python, java

Key Methods:

MethodParametersReturns
generate_from_requirements(requirements, test_type)requirements: dict with user_stories, acceptance_criteria, api_specs; test_type: TestType enum (default UNIT)List[Dict] of test case specs
generate_test_stub(test_case)test_case: single test case dictstr -- framework-specific test stub code
generate_test_file(module_name, test_cases)module_name: str; test_cases: optional list (uses stored cases if omitted)str -- complete test file with imports
suggest_missing_scenarios(existing_tests, code_analysis)existing_tests: list of test name strings; code_analysis: dict with error_handlers, conditional_branches, input_validationList[Dict] of suggested test scenarios

Output Formats: Python dict/list (test case specifications), string (generated code).

Example:

requirements = {
    "user_stories": [{"action": "login", "given": ["valid credentials"], "when": "submit form", "then": "redirect to dashboard"}],
    "api_specs": [{"method": "POST", "path": "/auth/login", "requires_auth": False, "required_params": ["email", "password"]}]
}
gen = TestGenerator(framework=TestFramework.JEST, language="typescript")
cases = gen.generate_from_requirements(requirements)
print(gen.generate_test_file("auth_service", cases))

2. coverage_analyzer.py

Purpose: Parse coverage reports in LCOV, JSON (Istanbul/nyc), and XML (Cobertura) formats. Calculate summary metrics, identify files below threshold, and generate prioritized recommendations.

Module: CoverageAnalyzer class

Usage:

from coverage_analyzer import CoverageAnalyzer

analyzer = CoverageAnalyzer()
data = analyzer.parse_coverage_report(report_content, format_type="lcov")
summary = analyzer.calculate_summary()
gaps = analyzer.identify_gaps(threshold=80.0)
recs = analyzer.generate_recommendations()
file_detail = analyzer.get_file_coverage("src/auth.ts")
detected = analyzer.detect_format(raw_content)

Constructor Parameters: None.

Key Methods:

MethodParametersReturns
parse_coverage_report(report_content, format_type)report_content: str; format_type: "lcov", "json", "xml", "cobertura"Dict of per-file coverage data
calculate_summary()NoneDict with line_coverage, branch_coverage, function_coverage, totals
identify_gaps(threshold)threshold: float (default 80.0)List[Dict] of files below threshold with priority P0/P1/P2
generate_recommendations()NoneList[Dict] of prioritized recommendations
get_file_coverage(file_path)file_path: strDict with per-file line/branch/function coverage
detect_format(content)content: strstr -- "lcov", "json", or "xml"

Output Formats: Python dict/list. Use output_formatter.py for terminal/markdown/JSON rendering.

Example:

with open("coverage/lcov.info") as f:
    content = f.read()
analyzer = CoverageAnalyzer()
fmt = analyzer.detect_format(content)
analyzer.parse_coverage_report(content, fmt)
summary = analyzer.calculate_summary()
# {'line_coverage': 76.5, 'branch_coverage': 62.3, ...}
gaps = analyzer.identify_gaps(threshold=80.0)
# [{'file': 'src/auth.ts', 'line_coverage': 45.0, 'priority': 'P0', ...}]

3. tdd_workflow.py

Purpose: Guide users through red-green-refactor TDD cycles with phase validation, workflow state tracking, and refactoring suggestions.

Module: TDDWorkflow class

Usage:

from tdd_workflow import TDDWorkflow

wf = TDDWorkflow()
guidance = wf.start_cycle("User can reset password via email")
red_result = wf.validate_red_phase(test_code, test_result={"status": "failed"})
green_result = wf.validate_green_phase(impl_code, {"status": "passed"})
refactor_result = wf.validate_refactor_phase(original, refactored, {"status": "passed"})
phase_guide = wf.get_phase_guidance()
summary = wf.generate_workflow_summary()

Constructor Parameters: None.

Key Methods:

MethodParametersReturns
start_cycle(requirement)requirement: str -- user story or feature descriptionDict with phase, instruction, checklist, tips
validate_red_phase(test_code, test_result)test_code: str; test_result: optional dict with status keyDict with phase_complete, validations, next instruction
validate_green_phase(implementation_code, test_result)implementation_code: str; test_result: dict with status keyDict with phase_complete, validations, refactoring_suggestions
validate_refactor_phase(original_code, refactored_code, test_result)original_code: str; refactored_code: str; test_result: dict with status keyDict with phase_complete, cycle_complete, next steps
get_phase_guidance(phase)phase: optional TDDPhase enum (uses current phase if omitted)Dict with goal, steps, common mistakes, tips
generate_workflow_summary()Nonestr -- markdown summary of current state and completed cycles

Output Formats: Python dict (validation results), string (summary).

Example:

wf = TDDWorkflow()
wf.start_cycle("Add email validation to signup form")
result = wf.validate_red_phase("def test_invalid_email():\n    assert validate('bad') == False", {"status": "failed"})
# {'phase_complete': True, 'next_phase': 'GREEN', ...}

4. framework_adapter.py

Purpose: Provide multi-framework support with adapters for Jest, Vitest, Pytest, unittest, JUnit, TestNG, Mocha, and Jasmine. Generate framework-specific imports, test suites, test functions, assertions, and setup/teardown hooks.

Module: FrameworkAdapter class

Usage:

from framework_adapter import FrameworkAdapter, Framework, Language

adapter = FrameworkAdapter(framework=Framework.JEST, language=Language.TYPESCRIPT)
imports = adapter.generate_imports()
suite = adapter.generate_test_suite_wrapper("AuthService", test_content)
test_fn = adapter.generate_test_function("should reject invalid email", body, "Validates email format")
assertion = adapter.generate_assertion("result", "true", "true")
hooks = adapter.generate_setup_teardown(setup_code="db = create_test_db()", teardown_code="db.close()")
detected = adapter.detect_framework(existing_code)

Constructor Parameters:

ParameterTypeRequiredDescription
frameworkFrameworkYesJEST, VITEST, PYTEST, UNITTEST, JUNIT, TESTNG, MOCHA, JASMINE
languageLanguageYesTYPESCRIPT, JAVASCRIPT, PYTHON, JAVA

Key Methods:

MethodParametersReturns
generate_imports()Nonestr -- framework-specific import statements
generate_test_suite_wrapper(suite_name, test_content)suite_name: str; test_content: strstr -- complete test suite wrapping content
generate_test_function(test_name, test_body, description)test_name: str; test_body: str; description: str (default "")str -- complete test function
generate_assertion(actual, expected, assertion_type)actual: str; expected: str; assertion_type: "equals", "not_equals", "true", "false", "throws" (default "equals")str -- assertion statement
generate_setup_teardown(setup_code, teardown_code)setup_code: str (default ""); teardown_code: str (default "")str -- setup/teardown hooks
detect_framework(code)code: strFramework enum or None

Output Formats: String (generated code).

Example:

adapter = FrameworkAdapter(Framework.PYTEST, Language.PYTHON)
print(adapter.generate_imports())
# import pytest
print(adapter.generate_assertion("calculate_total(items)", "150.0", "equals"))
# assert calculate_total(items) == 150.0

5. fixture_generator.py

Purpose: Generate realistic test data, boundary values, edge-case scenarios, and mock objects for various domains (auth, payment, form, API, file upload).

Module: FixtureGenerator class

Usage:

from fixture_generator import FixtureGenerator

gen = FixtureGenerator(seed=42)
boundaries = gen.generate_boundary_values("int", {"min": 0, "max": 255})
edge_cases = gen.generate_edge_cases("auth")
mocks = gen.generate_mock_data(schema, count=5)
fixture_content = gen.generate_fixture_file("users", mocks, format="json")

Constructor Parameters:

ParameterTypeRequiredDescription
seedint or NoneNoRandom seed for reproducible output (default None)

Key Methods:

MethodParametersReturns
generate_boundary_values(data_type, constraints)data_type: "int", "string", "array", "date", "email", "url"; constraints: optional dict (min, max, min_length, max_length, min_size, max_size)List of boundary values
generate_edge_cases(scenario, context)scenario: "auth", "payment", "form", "api", "file_upload"; context: optional dict (required for "form" with fields key)List[Dict] of edge case scenarios
generate_mock_data(schema, count)schema: dict mapping field names to {"type":...} defs; count: int (default 1)List[Dict] of mock objects
generate_fixture_file(fixture_name, data, format)fixture_name: str; data: any; format: "json", "python", "yaml" (default "json")str -- fixture file content

Supported Schema Field Types: string, int, float, bool, email, date, array.

Output Formats: Python list/dict (data), string (file content in JSON/Python/YAML).

Example:

gen = FixtureGenerator(seed=123)
schema = {
    "id": {"type": "int", "min": 1, "max": 9999},
    "email": {"type": "email"},
    "active": {"type": "bool"}
}
users = gen.generate_mock_data(schema, count=3)
print(gen.generate_fixture_file("test_users", users, format="json"))

6. metrics_calculator.py

Purpose: Calculate comprehensive test and code quality metrics including cyclomatic/cognitive complexity, testability scoring, test quality assessment (assertions, isolation, naming, smells), and execution analysis.

Module: MetricsCalculator class

Usage:

from metrics_calculator import MetricsCalculator

calc = MetricsCalculator()
all_metrics = calc.calculate_all_metrics(source_code, test_code, coverage_data, execution_data)
complexity = calc.calculate_complexity(source_code)
test_quality = calc.calculate_test_quality(test_code)
execution = calc.analyze_execution_metrics(execution_data)
summary = calc.generate_metrics_summary()

Constructor Parameters: None.

Key Methods:

MethodParametersReturns
calculate_all_metrics(source_code, test_code, coverage_data, execution_data)source_code: str; test_code: str; coverage_data: optional dict; execution_data: optional dictDict with complexity, test_quality, coverage, execution
calculate_complexity(code)code: strDict with cyclomatic_complexity, cognitive_complexity, testability_score, assessment
calculate_test_quality(test_code)test_code: strDict with total_tests, total_assertions, avg_assertions_per_test, isolation_score, naming_quality, test_smells, quality_score
analyze_execution_metrics(execution_data)execution_data: dict with tests list (each having duration, status, optional failure_rate)Dict with total_tests, timing stats, slow_tests, flaky_tests, pass_rate
generate_metrics_summary()Nonestr -- human-readable markdown summary

Output Formats: Python dict (metrics data), string (markdown summary).

Example:

calc = MetricsCalculator()
complexity = calc.calculate_complexity(open("src/auth.py").read())
# {'cyclomatic_complexity': 8, 'cognitive_complexity': 12, 'testability_score': 82.0, 'assessment': 'Medium complexity - moderately testable'}
quality = calc.calculate_test_quality(open("tests/test_auth.py").read())
# {'quality_score': 78.5, 'test_smells': [], ...}

7. format_detector.py

Purpose: Automatically detect programming language, testing framework, coverage report format, and project structure from code content or file paths.

Module: FormatDetector class

Usage:

from format_detector import FormatDetector

detector = FormatDetector()
language = detector.detect_language(code)
framework = detector.detect_test_framework(test_code)
cov_format = detector.detect_coverage_format(report_content)
input_info = detector.detect_input_format(raw_input)
file_info = detector.extract_file_info("/src/auth.service.ts")
test_name = detector.suggest_test_file_name("auth.service.ts", "jest")
patterns = detector.identify_test_patterns(test_code)
project = detector.analyze_project_structure(file_path_list)
env = detector.detect_environment()

Constructor Parameters: None.

Key Methods:

MethodParametersReturns
detect_language(code)code: strstr -- "typescript", "javascript", "python", "java", "unknown"
detect_test_framework(code)code: strstr -- "jest", "vitest", "pytest", "unittest", "junit", "mocha", "unknown"
detect_coverage_format(content)content: strstr -- "lcov", "json", "xml", "unknown"
detect_input_format(input_data)input_data: strDict with format, language, framework, content_type
extract_file_info(file_path)file_path: strDict with file_name, extension, language, is_test, purpose
suggest_test_file_name(source_file, framework)source_file: str; framework: strstr -- suggested test file name
identify_test_patterns(code)code: strList[str] of detected patterns (AAA, Given-When-Then, etc.)
analyze_project_structure(file_paths)file_paths: list of strDict with primary_language, test_ratio, suggested_framework
detect_environment()NoneDict with environment, output_preference

Output Formats: String (detection result), Python dict (detailed analysis).

Example:

detector = FormatDetector()
print(detector.detect_language("const add = (a: number, b: number): number => a + b;"))
# "typescript"
print(detector.suggest_test_file_name("UserService.java", "junit"))
# "UserserviceTest.java"
print(detector.identify_test_patterns("// Arrange\nsetup()\n// Act\nresult = run()\n// Assert\nassert result"))
# ['AAA (Arrange-Act-Assert)']

8. output_formatter.py

Purpose: Context-aware output formatting for different environments (Desktop/markdown, CLI/terminal, API/JSON). Supports progressive disclosure, token-efficient summary reports, and output truncation.

Module: OutputFormatter class

Usage:

from output_formatter import OutputFormatter

fmt = OutputFormatter(environment="cli", verbose=False)
cov_output = fmt.format_coverage_summary(summary, detailed=True)
rec_output = fmt.format_recommendations(recommendations, max_items=5)
test_output = fmt.format_test_results(results, show_details=True)
report = fmt.create_summary_report(coverage, metrics, recommendations)
should_detail = fmt.should_show_detailed(data_size=50)
truncated = fmt.truncate_output(long_text, max_lines=30)

Constructor Parameters:

ParameterTypeRequiredDescription
environmentstrNoTarget environment: "desktop", "cli", "api" (default "cli")
verboseboolNoInclude detailed output (default False)

Key Methods:

MethodParametersReturns
format_coverage_summary(summary, detailed)summary: dict; detailed: bool (default False)str -- formatted coverage (markdown/terminal/JSON based on environment)
format_recommendations(recommendations, max_items)recommendations: list of dicts; max_items: optional intstr -- formatted recommendations grouped by priority
format_test_results(results, show_details)results: dict with total_tests, passed, failed, skipped, failed_tests; show_details: bool (default False)str -- formatted test results
create_summary_report(coverage, metrics, recommendations)coverage: dict; metrics: dict; recommendations: liststr -- token-efficient summary (<200 tokens)
should_show_detailed(data_size)data_size: intbool -- whether to show detailed output
truncate_output(text, max_lines)text: str; max_lines: int (default 50)str -- truncated text with remaining-lines indicator

Output Formats: String in markdown (desktop), plain text (CLI), or JSON (API) depending on environment setting.

Example:

fmt = OutputFormatter(environment="desktop", verbose=True)
print(fmt.format_coverage_summary({"line_coverage": 82.5, "branch_coverage": 71.0, "function_coverage": 90.0}))
# ## Test Coverage Summary
# ### Overall Metrics
# - **Line Coverage**: 82.5%
# ...

平台分布

Codex

34.11%
按下载量换算267

Claude

28.89%
按下载量换算226

Cursor

18.8%
按下载量换算147

Gemini CLI

9.47%
按下载量换算74

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills