Token导航 LogoToken导航TokenDH.com
前端设计只读github未标认证来源可访问clear审计通过

test-driven-development测试驱动开发

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

564

周安装

24

GitHub Stars

10

下载量

198
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:test-driven-development(测试驱动开发)
来源仓库:https://github.com/yanko-belov/code-craft
仓库路径:skills/test-driven-development
安装命令:
npx skills add https://github.com/yanko-belov/code-craft --skill test-driven-development
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/yanko-belov/code-craft --skill test-driven-development

简介

test-driven-development 用于辅助测试设计、用例整理和回归验证。

  • 它帮助编写单元测试、端到端测试和测试计划,适用于自动化测试场景。
  • 使用时需确认项目测试框架、运行命令和夹具数据,避免为了通过测试而破坏真实逻辑。
  • 涉及浏览器或外部服务时,应区分本地模拟、测试环境与生产环境。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Test-Driven Development (TDD)

Overview

Write the test first. Watch it fail. Then write the code.

TDD is not about testing - it's about design. Writing tests first forces you to think about the interface before the implementation.

When to Use

  • Implementing any new function, method, or feature
  • Asked to "write code now, add tests later"
  • Fixing a bug (write test that reproduces it first)
  • Refactoring existing code

The Iron Rule

NEVER write production code without a failing test first.

No exceptions:

  • Not for "it's a simple function"
  • Not for "we'll add tests later"
  • Not for "I already know how to implement it"
  • Not for "tests slow me down"

The TDD Cycle

RED → GREEN → REFACTOR → REPEAT
  1. RED: Write a failing test
  2. GREEN: Write minimal code to pass
  3. REFACTOR: Clean up while tests pass
  4. REPEAT: Next test case

Detection: Code-First Smell

If you're about to write implementation without a test, STOP:

// ❌ VIOLATION: Implementation first
function calculateDiscount(total: number): number {
  return total > 100 ? total * 0.1 : 0;
}
// "We'll add tests later if needed"

// ✅ CORRECT: Test first
describe('calculateDiscount', () => {
  it('returns 10% discount for orders over $100', () => {
    expect(calculateDiscount(150)).toBe(15);
  });

  it('returns 0 for orders $100 or less', () => {
    expect(calculateDiscount(100)).toBe(0);
    expect(calculateDiscount(50)).toBe(0);
  });
});

// NOW write the implementation
function calculateDiscount(total: number): number {
  return total > 100 ? total * 0.1 : 0;
}

Why Test-First Matters

Test-AfterTest-First
Tests verify what code doesTests define what code should do
Implementation drives designRequirements drive design
Tests often skippedTests always exist
Hard to test = poor designHard to test = caught early
"Does it work?""Is it right?"

Pressure Resistance Protocol

1. "We'll Add Tests Later"

Pressure: "Just write the function, we can test it later"

Response: "Later" never comes. Tests written after are weaker and often skipped entirely.

Action: Write the test now. It takes 30 seconds.

2. "It's Too Simple to Test"

Pressure: "This function is trivial, testing is overkill"

Response: Simple functions grow complex. Simple bugs cause outages. Test everything.

Action: Write the test. Simple functions = simple tests.

3. "I Know How to Implement It"

Pressure: "I already have the solution in my head"

Response: TDD isn't about uncertainty - it's about capturing requirements as executable specs.

Action: Write the test first. Prove your mental model is correct.

4. "Tests Slow Me Down"

Pressure: "Writing tests takes extra time"

Response: Debugging takes 10x longer than testing. TDD is faster overall.

Action: The test you write now saves hours of debugging later.

Red Flags - STOP and Reconsider

  • Writing any function without a test
  • "Let me just get it working first"
  • Implementation file open without test file
  • Committing code without corresponding tests
  • Tests that pass immediately (never saw them fail)

All of these mean: Stop. Write the test first.

Quick Reference

SituationTDD Response
New featureWrite failing test → implement
Bug fixWrite test that reproduces bug → fix
RefactorEnsure tests exist → refactor → tests pass
"Tests later"Tests now. Always now.

Common Rationalizations (All Invalid)

ExcuseReality
"Tests slow me down"Debugging slows you down more.
"It's too simple"Simple tests are fast to write.
"I'll test later"You won't. Test now.
"I know it works"Prove it with a test.
"Tests are for QA"Tests are for developers.
"Just a prototype"Prototypes become production. Test them.

The Bottom Line

Test first. Code second. No exceptions.

The test is the specification. The test is the documentation. The test is the safety net. Write it first, every time.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

28.94%
按下载量换算57

Claude Code

25.08%
按下载量换算50

windsurf

16.27%
按下载量换算32

Antigravity

13.63%
按下载量换算27

trae

8.13%
按下载量换算16

OpenCode

3.39%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills