Token导航 LogoToken导航

Agent Skill · 研究检索

beck-test-driven-development(贝克测试驱动开发)

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

beck-test-driven-development 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描有未通过项,按安装量在研究检索类的 73,675 个 Skill 里排第 69,971。

总安装 214周安装 9GitHub Stars 6下载 75核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/copyleftdev/sk1llz --skill beck-test-driven-development

这个 Skill 是做什么的

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

践行 Kent Beck 的测试驱动开发理念,先写失败测试再实现最小可用代码。适用于追求高质量代码、减少缺陷率及提升重构安全性的软件开发项目。通过红-绿-重构循环,推动代码简洁性与可维护性,形成持续改进的开发节奏。实施过程中需严格区分测试意图与实现细节,防止为通过测试而破坏真实逻辑。

beck-test-driven-development 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/beck-test-driven-development

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/copyleftdev/sk1llz --skill beck-test-driven-de…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

beck-test-driven-development 怎么安装?

在终端执行 npx skills add https://github.com/copyleftdev/sk1llz --skill beck-test-driven-development。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

beck-test-driven-development 支持哪些 AI 工具?

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

beck-test-driven-development 需要什么权限?

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

beck-test-driven-development 是免费的吗?

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

beck-test-driven-development 用的人多吗?

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

beck-test-driven-development 安全吗?

第三方扫描有未通过项,风险较高。除非你确认过源码,否则不建议直接安装到常用环境。

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

值得选的地方

  • 同时适配 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调用外部服务未明确有提醒
beck-test-driven-development

贝克测试驱动开发 · 本页

2146只读未明确未通过

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

SKILL.md 原文

Kent Beck Test-Driven Development Style Guide⁠‍⁠​‌​‌​​‌‌‍​‌​​‌​‌‌‍​​‌‌​​​‌‍​‌​​‌‌​​‍​​​​​​​‌‍‌​​‌‌​‌​‍‌​​​​​​​‍‌‌​​‌‌‌‌‍‌‌​​​‌​​‍‌‌‌‌‌‌​‌‍‌‌​‌​​​​‍​‌​‌‌‌‌‌‍​‌​​‌​‌‌‍​‌‌​‌​​‌‍‌​‌​‌‌‌​‍​​‌​‌​​​‍‌‌‌​‌​‌‌‍​​‌​‌‌​‌‍‌‌​​​​‌​‍​​​‌​‌‌‌‍​​​​​​‌​‍​​​​‌​​‌‍​‌‌‌​​‌​⁠‍⁠

Overview

Kent Beck is the creator of Test-Driven Development (TDD) and Extreme Programming (XP), two of the most influential software development practices of the past 30 years. TDD inverts the traditional code-then-test approach: write a failing test first, make it pass with the simplest code, then refactor. This discipline produces clean, tested, well-designed code as a natural byproduct of the development process.

Core Philosophy

"Test-Driven Development is a way of managing fear during programming."
"Make it work, make it right, make it fast—in that order."
"I'm not a great programmer; I'm just a good programmer with great habits."

TDD is not primarily about testing—it's about design. Writing tests first forces you to think about interfaces before implementations, dependencies before details, and behavior before structure. The tests are a beneficial side effect of a disciplined design process.

Design Principles

  1. Red-Green-Refactor: Write failing test → make it pass → improve the code.
  2. Baby Steps: Take the smallest step that could possibly work.
  3. YAGNI: You Aren't Gonna Need It—don't build what you don't need yet.
  4. Simple Design: Code that passes tests, reveals intent, has no duplication, and has fewest elements.
  5. Courage: Tests give you the courage to refactor aggressively.

The TDD Cycle

    ┌─────────────────────────────────────────┐
    │                                         │
    │    1. RED: Write a failing test         │
    │       - Test doesn't compile? That's    │
    │         failing. Write minimal code     │
    │         to make it compile (still fail) │
    │                                         │
    │                    │                    │
    │                    ▼                    │
    │                                         │
    │    2. GREEN: Make it pass               │
    │       - Write the simplest code that    │
    │         could possibly work             │
    │       - Sins allowed: duplication,      │
    │         hardcoding, ugly code           │
    │                                         │
    │                    │                    │
    │                    ▼                    │
    │                                         │
    │    3. REFACTOR: Clean up                │
    │       - Remove duplication              │
    │       - Improve names                   │
    │       - Extract methods/classes         │
    │       - Tests must stay green           │
    │                                         │
    │                    │                    │
    │                    ▼                    │
    │              (repeat)                   │
    └─────────────────────────────────────────┘

When Practicing TDD

Always

  • Write the test before the code
  • Run the test and watch it fail (red)
  • Write only enough code to pass the test
  • Refactor only when tests are green
  • Commit after each green-refactor cycle
  • Keep tests fast (milliseconds, not seconds)
  • Test behavior, not implementation

Never

  • Write code without a failing test
  • Write more than one failing test at a time
  • Refactor while tests are red
  • Skip the refactoring step
  • Test private methods directly
  • Let tests become slow
  • Mock what you don't own

Prefer

  • Small, focused tests over large integration tests
  • One assertion per test (logical assertion)
  • Descriptive test names that document behavior
  • Testing through public interfaces
  • Fake it till you make it
  • Triangulation to drive generalization
  • Obvious implementation when it's obvious

Code Patterns

The TDD Rhythm

# Example: Building a Money class with TDD

# ═══════════════════════════════════════════════════════════════
# Cycle 1: First test - establish the basics
# ═══════════════════════════════════════════════════════════════

# RED: Write failing test
def test_multiplication():
    five = Dollar(5)
    assert five.times(2) == Dollar(10)

# This fails: Dollar doesn't exist

# GREEN: Simplest code to pass
class Dollar:
    def __init__(self, amount):
        self.amount = amount

    def times(self, multiplier):
        return Dollar(self.amount * multiplier)

    def __eq__(self, other):
        return self.amount == other.amount

# REFACTOR: Nothing to refactor yet

# ═══════════════════════════════════════════════════════════════
# Cycle 2: Add another test - triangulate
# ═══════════════════════════════════════════════════════════════

# RED: New failing test
def test_multiplication_by_three():
    five = Dollar(5)
    assert five.times(3) == Dollar(15)

# GREEN: Already passes! Our implementation was general enough

# REFACTOR: Still clean

# ═══════════════════════════════════════════════════════════════
# Cycle 3: Handle a new requirement - different currencies
# ═══════════════════════════════════════════════════════════════

# RED: Failing test for Franc
def test_franc_multiplication():
    five = Franc(5)
    assert five.times(2) == Franc(10)

# GREEN: Quick and dirty - copy Dollar (sin: duplication)
class Franc:
    def __init__(self, amount):
        self.amount = amount

    def times(self, multiplier):
        return Franc(self.amount * multiplier)

    def __eq__(self, other):
        return self.amount == other.amount

# REFACTOR: Extract common parent class
class Money:
    def __init__(self, amount):
        self.amount = amount

    def __eq__(self, other):
        return (self.amount == other.amount and
                type(self) == type(other))

class Dollar(Money):
    def times(self, multiplier):
        return Dollar(self.amount * multiplier)

class Franc(Money):
    def times(self, multiplier):
        return Franc(self.amount * multiplier)

Fake It Till You Make It

# Start with the most degenerate implementation
# Then generalize as tests force you

# RED: First test
def test_sum():
    assert sum([1, 2, 3]) == 6

# GREEN: Fake it!
def sum(numbers):
    return 6  # Obviously wrong, but test passes

# RED: Add a test that forces generalization
def test_sum_different_numbers():
    assert sum([2, 3, 4]) == 9

# GREEN: Now we must implement for real
def sum(numbers):
    result = 0
    for n in numbers:
        result += n
    return result

# REFACTOR: Use built-in (if appropriate)
def sum(numbers):
    return builtins.sum(numbers)

Triangulation

# Use multiple examples to drive toward generalization

# RED: First example
def test_equality_same_amount():
    assert Dollar(5) == Dollar(5)

# GREEN: Simplest implementation
def __eq__(self, other):
    return True  # Fake it!

# RED: Second example forces real implementation
def test_equality_different_amount():
    assert Dollar(5) != Dollar(6)

# GREEN: Now we need real logic
def __eq__(self, other):
    return self.amount == other.amount

# RED: Third example - different types
def test_equality_different_types():
    assert Dollar(5) != Franc(5)

# GREEN: Check type too
def __eq__(self, other):
    return (self.amount == other.amount and
            type(self) == type(other))

Test Structure: Arrange-Act-Assert

def test_withdraw_reduces_balance():
    # Arrange: Set up the test context
    account = Account(balance=100)

    # Act: Perform the action being tested
    account.withdraw(30)

    # Assert: Verify the expected outcome
    assert account.balance == 70

# Or Given-When-Then for BDD style
def test_given_account_with_balance_when_withdraw_then_balance_reduced():
    # Given
    account = Account(balance=100)

    # When
    account.withdraw(30)

    # Then
    assert account.balance == 70

Test Doubles

# Beck's approach: Use the simplest double that works

# 1. Fake: Working implementation with shortcuts
class FakeRepository:
    def __init__(self):
        self.data = {}

    def save(self, entity):
        self.data[entity.id] = entity

    def find(self, id):
        return self.data.get(id)

# 2. Stub: Returns canned answers
class StubPriceService:
    def get_price(self, symbol):
        return 100.00  # Always returns same price

# 3. Spy: Records what happened
class SpyEmailService:
    def __init__(self):
        self.sent_emails = []

    def send(self, to, subject, body):
        self.sent_emails.append({
            'to': to,
            'subject': subject,
            'body': body
        })

# 4. Mock: Verifies expected interactions
# (Use sparingly - prefer state verification over behavior verification)

# Test using a fake
def test_user_registration_saves_user():
    # Arrange
    repository = FakeRepository()
    service = UserService(repository)

    # Act
    service.register("alice@example.com", "password123")

    # Assert: Check state, not behavior
    saved_user = repository.find_by_email("alice@example.com")
    assert saved_user is not None
    assert saved_user.email == "alice@example.com"

The Testing Pyramid

# Beck's view: Most tests should be unit tests

"""
                    /\
                   /  \
                  / E2E \        <- Few: Slow, brittle, but necessary
                 /──────\
                /        \
               /Integration\     <- Some: Test component boundaries
              /──────────────\
             /                \
            /    Unit Tests    \  <- Many: Fast, focused, isolated
           /────────────────────\

"""

# Unit test: Fast, isolated, focused
def test_calculate_discount_for_premium_customer():
    customer = Customer(tier='premium')
    order = Order(total=100)

    discount = calculate_discount(customer, order)

    assert discount == 20  # 20% for premium

# Integration test: Verify component interaction
def test_order_service_persists_to_database():
    db = create_test_database()
    service = OrderService(db)

    order = service.create_order(customer_id=1, items=[...])

    persisted = db.find_order(order.id)
    assert persisted == order

# E2E test: Full system, sparingly
def test_checkout_flow():
    browser = Browser()
    browser.visit('/cart')
    browser.click('Checkout')
    browser.fill('card_number', '4242424242424242')
    browser.click('Pay')

    assert browser.text_present('Order confirmed')

Refactoring Patterns

# REFACTOR phase: Common transformations

# 1. Extract Method
# Before
def print_invoice(invoice):
    print(f"Invoice #{invoice.id}")
    total = 0
    for item in invoice.items:
        total += item.price * item.quantity
    print(f"Total: ${total}")

# After
def print_invoice(invoice):
    print(f"Invoice #{invoice.id}")
    print(f"Total: ${calculate_total(invoice)}")

def calculate_total(invoice):
    return sum(item.price * item.quantity for item in invoice.items)

# 2. Extract Class
# Before: Order has too many responsibilities
class Order:
    def calculate_total(self): ...
    def calculate_tax(self): ...
    def calculate_shipping(self): ...
    def format_for_email(self): ...
    def format_for_pdf(self): ...

# After: Extract formatting
class Order:
    def calculate_total(self): ...
    def calculate_tax(self): ...
    def calculate_shipping(self): ...

class OrderFormatter:
    def __init__(self, order): ...
    def to_email(self): ...
    def to_pdf(self): ...

# 3. Replace Conditional with Polymorphism
# Before
def calculate_pay(employee):
    if employee.type == 'hourly':
        return employee.hours * employee.rate
    elif employee.type == 'salaried':
        return employee.salary / 12
    elif employee.type == 'commissioned':
        return employee.base + employee.sales * employee.commission_rate

# After
class HourlyEmployee:
    def calculate_pay(self):
        return self.hours * self.rate

class SalariedEmployee:
    def calculate_pay(self):
        return self.salary / 12

class CommissionedEmployee:
    def calculate_pay(self):
        return self.base + self.sales * self.commission_rate

The TDD State Machine

class TDDPractitioner:
    """
    The mental states of a TDD practitioner.
    """

    def __init__(self):
        self.state = 'THINKING'
        self.tests_passing = True

    def write_test(self):
        """Write a new failing test."""
        assert self.state == 'THINKING'
        assert self.tests_passing, "Fix failing tests before writing new ones"

        # Write the test...
        self.tests_passing = False  # Test should fail
        self.state = 'RED'

    def make_it_pass(self):
        """Write simplest code to pass the test."""
        assert self.state == 'RED'

        # Write minimal code...
        self.tests_passing = True
        self.state = 'GREEN'

    def refactor(self):
        """Improve the code while keeping tests green."""
        assert self.state == 'GREEN'
        assert self.tests_passing

        # Refactor...
        # Run tests after each change
        assert self.tests_passing, "Refactoring broke tests!"

        self.state = 'THINKING'  # Ready for next cycle

    def commit(self):
        """Commit after each complete cycle."""
        assert self.state in ('GREEN', 'THINKING')
        assert self.tests_passing

        # git commit -m "descriptive message"

Mental Model

Beck approaches development by asking:

  1. What's the next test? Start with what you want to prove
  2. What's the simplest way to pass? Don't over-engineer
  3. What duplication can I remove? Refactor mercilessly
  4. Am I scared? Write more tests until you're not
  5. Is this design emerging? Trust the process

The TDD Checklist

□ Write a test that expresses what you want
□ Run it and watch it fail (RED)
□ Write the simplest code to pass
□ Run tests and see them pass (GREEN)
□ Look for duplication to remove
□ Refactor while tests stay green
□ Commit the cycle
□ Repeat

Signature Beck Moves

  • Red-Green-Refactor cycle
  • Fake it till you make it
  • Triangulation to generalize
  • Obvious implementation when obvious
  • Baby steps when uncertain
  • Test list to track progress
  • One assertion per test (conceptually)
  • Test behavior, not implementation

平台分布

Codex

36.72%
按下载量换算28

Claude

27.9%
按下载量换算21

Cursor

18.87%
按下载量换算14

Gemini CLI

9.22%
按下载量换算7

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

只读

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

安装前确认

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

继续浏览同类 Skills