← 返回 Skills 市场
imbeasting

test-driven-development

作者 ImBeasting · GitHub ↗ · v1.0.0
cross-platform ⚠ suspicious
813
总下载
1
收藏
4
当前安装
1
版本数
在 OpenClaw 中安装
/install imbeasting-test-driven-development
功能描述
Unified TDD skill with three input modes — from spec, from task, or from description. Enforces test-first development using repository patterns, with proptes...
使用说明 (SKILL.md)

Test-Driven Development

Overview

One skill for all TDD workflows. Enforces test-first development using existing repository patterns. Three input modes handle different entry points — specs, task files, or ad-hoc descriptions — but the core cycle is always RED → GREEN → REFACTOR.

Input Modes

Detect the input type and follow the corresponding mode:

Mode A: From Spec (.spec.md)

Use when the input references a .spec.md file with Given/When/Then acceptance criteria.

  1. Locate and parse the spec file — extract all Given/When/Then triples
  2. Generate one test stub per criterion with todo!() bodies:
    /// Spec: \x3Cspec-file> — Criterion #\x3CN>
    /// Given \x3Cgiven text>
    /// When \x3Cwhen text>
    /// Then \x3Cthen text>
    #[test]
    fn \x3Cspec_name>_criterion_\x3CN>_\x3Cslug>() {
        todo!("Implement: \x3Cthen text>");
    }
    
  3. Verify stubs compile but fail: cargo test --no-run -p \x3Ccrate>
  4. Proceed to the TDD Cycle to make stubs pass

Programmatic support: ralph_core::preflight::{extract_acceptance_criteria, extract_criteria_from_file, extract_all_criteria} can parse criteria from spec files.

Mode B: From Task (.code-task.md)

Use when the input references a .code-task.md file or a specific implementation task.

  1. Read the task and identify acceptance criteria or requirements
  2. Discover patterns (see Pattern Discovery)
  3. Design test scenarios covering normal operation, edge cases, and error conditions
  4. Write failing tests for all requirements before any implementation
  5. Proceed to the TDD Cycle

Mode C: From Description

Use for ad-hoc tasks without a spec or task file.

  1. Clarify requirements from the description
  2. Discover patterns (see Pattern Discovery)
  3. Write failing tests targeting the described behavior
  4. Proceed to the TDD Cycle

Pattern Discovery

Before writing tests, discover existing conventions:

rg --files -g "crates/*/tests/*.rs"
rg -n "#\[cfg\(test\)\]" crates/

Read 2-3 relevant test files near the target code. Mirror:

  • Test module layout, naming, and assertion style
  • Fixture helpers and test utilities
  • Use of tempfile, scenarios, or harnesses

TDD Cycle

1) RED — Failing Tests

  • Write tests for the exact behavior required
  • Run tests to confirm failure for the right reason
  • If tests pass without implementation, the test is wrong

2) GREEN — Minimal Implementation

  • Write the minimum code to make tests pass
  • No extra features or refactoring during this step

3) REFACTOR — Clean Up

  • Improve implementation and tests while keeping tests green
  • Align with surrounding codebase conventions
  • Re-run tests after every change

Proptest Guidance

Use proptest only when ALL of:

  • Function is pure (no I/O, no time, no globals)
  • Deterministic output for given input
  • Non-trivial input space or edge cases
proptest! {
    #[test]
    fn round_trip(input in "[a-z0-9]{0,32}") {
        let encoded = encode(input.as_str());
        let decoded = decode(&encoded).expect("should decode");
        prop_assert_eq!(decoded, input);
    }
}

Don't introduce proptest as a new dependency without strong justification.

Backpressure Integration

Include coverage evidence in completion events:

ralph emit "build.done" "tests: pass, lint: pass, typecheck: pass, audit: pass, coverage: pass (82%)"

Run cargo tarpaulin --out Html --output-dir coverage --skip-clean when feasible. If coverage cannot be run, state why and include targeted test evidence instead.

Test Location Rules

  • Spec maps to a single module → inline #[cfg(test)] tests
  • Spec spans multiple modules → integration test in crates/\x3Ccrate>/tests/
  • CLI behavior → crates/ralph-cli/tests/
  • Follow existing patterns in the target crate

Anti-Patterns

  • Writing implementation before tests
  • Generating tests that pass without implementation
  • Copying tests from other crates without adapting to local patterns
  • Adding proptest when a simple example test suffices
  • Emitting completion events without coverage evidence
安全使用建议
This skill appears to be a useful Rust TDD helper, but it assumes tools and an external event emitter without declaring them. Before installing or running: (1) verify you have a safe, isolated environment (sandbox or CI worker) because 'cargo test' and coverage can execute repository code; (2) confirm the presence and versions of required tools (cargo, ripgrep, cargo-tarpaulin, and the 'ralph' CLI/library) and ask the author to list them in metadata; (3) ask what 'ralph emit' does and where completion events are sent — treat it as a potential data exfiltration vector until proven otherwise; (4) run on trusted repositories first or review tests for malicious setup/teardown logic; and (5) prefer installing the skill only after the author updates requirements and documents external integrations.
功能分析
Type: OpenClaw Skill Name: imbeasting-test-driven-development Version: 1.0.0 The skill bundle defines a standard Test-Driven Development (TDD) workflow for Rust projects, utilizing common development tools like `cargo` and `ripgrep` (`rg`). It provides structured instructions for the agent to follow Red-Green-Refactor cycles based on specification files or task descriptions, and it lacks any indicators of malicious intent, data exfiltration, or unauthorized command execution.
能力评估
Purpose & Capability
The name/description describe a Rust-oriented TDD workflow (RED/GREEN/REFACTOR) which matches the instructions, but the SKILL.md assumes cargo, ripgrep (rg), cargo-tarpaulin, and a 'ralph' tool/library; none of those are declared in the skill metadata. The omission of these required tools is disproportionate to the stated lightweight metadata.
Instruction Scope
Instructions direct the agent to read repository files, run 'cargo test --no-run', run coverage (cargo tarpaulin), run ripgrep, and call 'ralph emit'. Running tests and coverage can execute repository code; 'ralph emit' likely posts completion events externally. The instructions do not document where/events are sent or require explicit authorization, so they may transmit repository-derived data without explicit disclosure.
Install Mechanism
This is an instruction-only skill with no install spec and no code files, so there is no installer download or archive execution risk.
Credentials
No environment variables, binaries, or config paths are declared, yet the guidance relies on multiple external tools and an integration (ralph) that may need credentials or config. The skill should declare required binaries and any credentials/config needed for 'ralph' or CI integration.
Persistence & Privilege
The skill is not always-enabled and does not request persistent or cross-skill configuration changes; it does not require elevated platform privileges per the provided metadata.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install imbeasting-test-driven-development
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /imbeasting-test-driven-development 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial publish under account-scoped slug due reserved original slug
元数据
Slug imbeasting-test-driven-development
版本 1.0.0
许可证
累计安装 4
当前安装数 4
历史版本数 1
常见问题

test-driven-development 是什么?

Unified TDD skill with three input modes — from spec, from task, or from description. Enforces test-first development using repository patterns, with proptes... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 813 次。

如何安装 test-driven-development?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install imbeasting-test-driven-development」即可一键安装,无需额外配置。

test-driven-development 是免费的吗?

是的,test-driven-development 完全免费(开源免费),可自由下载、安装和使用。

test-driven-development 支持哪些平台?

test-driven-development 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 test-driven-development?

由 ImBeasting(@imbeasting)开发并维护,当前版本 v1.0.0。

💬 留言讨论