Token导航 LogoToken导航TokenDH.com
前端设计操作浏览器github未标认证来源可访问许可证需确认审计通过

tdd时差

Agent Skill

tdd 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

698

周安装

30

GitHub Stars

公开资料未说明

下载量

245
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/blogic-cz/agent-tools --skill tdd

简介

tdd 用于执行严格测试驱动开发流程,适合在 Codex、Claude、Cursor、Gemini CLI 中编写新函数或服务时使用。

  • 它要求先写失败测试,再实现最小通过代码,最后重构保绿。
  • 使用时根据决策表判断适用场景,排除纯 UI 样式变更等非 TDD 范畴任务。
  • 安装前建议确认测试框架配置及覆盖率报告生成机制。
  • tdd 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Test-Driven Development (TDD)

Apply this skill to execute strict test-first development: write a failing test, implement the minimum code to pass, then refactor while keeping tests green.

Decide when to use TDD

Use this decision table:

SituationUse this skill?Default action
New utility functionYesRun TDD cycle immediately
New Effect serviceYesDefine behavior through tests first
Complex business logicYesLock behavior with tests before implementation
Bug fixYesReproduce bug with failing test first
UI styling/layout-only changeNoUse standard implementation flow
Exploratory prototypingNoPrototype first, then switch to TDD once behavior stabilizes
TRPC endpoint (simple CRUD)Usually noUse testing-patterns by default; use this skill only when user explicitly requests test-first/RGR

Execute Red-Green-Refactor

Follow one behavior at a time through three phases.

1. RED - Write Failing Test First

import { describe, expect, it } from "vitest";
import { calculateDiscount } from "../calculate-discount";

describe("calculateDiscount", () => {
  it("applies 10% discount for orders over 100", () => {
    // This test fails first: function does not exist yet
    expect(calculateDiscount(150)).toBe(135);
  });
});

Run test to see it fail:

bun run vitest run packages/common/src/__tests__/calculate-discount.test.ts

2. GREEN - Implement Minimum Code

Write the minimum code to make the test pass:

// packages/common/src/calculate-discount.ts
export function calculateDiscount(amount: number): number {
  if (amount > 100) {
    return amount * 0.9;
  }
  return amount;
}

Run test to see it pass:

bun run vitest run packages/common/src/__tests__/calculate-discount.test.ts

3. REFACTOR - Improve Without Breaking Behavior

Improve code quality while keeping tests green:

const DISCOUNT_THRESHOLD = 100;
const DISCOUNT_RATE = 0.1;

export function calculateDiscount(amount: number): number {
  if (amount <= DISCOUNT_THRESHOLD) {
    return amount;
  }
  return amount * (1 - DISCOUNT_RATE);
}

Run tests again to verify refactoring didn't break anything.

For extended examples, failure diagnostics, and iterative expansions, read references/red-green-refactor.md.


Keep test scope lean

Prefer lighter tests first and escalate only when needed:

  1. Unit tests (preferred) - Pure functions and Effect services with mock layers.
  2. TRPC integration tests - Full TRPC + persistence behavior.
  3. E2E tests - Browser-level flows and user journeys.
SituationTest TypeAction
Pure function, parser, utilUnitWrite immediately
Effect service with dependenciesUnit with mock layersWrite immediately
TRPC procedure (DB logic)TRPC integrationFollow testing-patterns decision process
User-facing flow, UI behaviorE2EFollow testing-patterns decision process

Apply Effect-specific TDD patterns

Use test-first service design with explicit layers.

  1. Define interface via test - Make behavior explicit before implementation.
  2. Create mock layer - Isolate dependencies and keep tests deterministic.
  3. Implement service - Satisfy the tests with the minimal behavior.
  4. Refactor - Improve readability and structure while preserving behavior.
import { describe, expect, it } from "@effect/vitest";
import { Effect, Layer } from "effect";

describe("PricingService", () => {
  // 1. Define what the service should do via tests
  it.effect("calculates base price without discount", () =>
    Effect.gen(function* () {
      const service = yield* PricingService;
      const result = yield* service.calculatePrice({
        itemId: "item-1",
        quantity: 2,
      });
      expect(result.total).toBe(200);
    }).pipe(Effect.provide(testLayer)),
  );

  it.effect("applies bulk discount for quantity > 10", () =>
    Effect.gen(function* () {
      const service = yield* PricingService;
      const result = yield* service.calculatePrice({
        itemId: "item-1",
        quantity: 15,
      });
      expect(result.total).toBe(1350); // 15% discount
    }).pipe(Effect.provide(testLayer)),
  );
});

Mock Layer Factory Pattern

// Create parameterized mock layers for different test scenarios
const createMockInventoryLayer = (inventory: Map<string, number>) =>
  Layer.succeed(InventoryService, {
    getStock: (itemId) => Effect.succeed(inventory.get(itemId) ?? 0),
    reserveStock: (itemId, qty) => Effect.succeed(void 0),
  });

// Use in tests
const testLayer = PricingService.layer.pipe(
  Layer.provide(createMockInventoryLayer(new Map([["item-1", 100]]))),
);

For deeper guidance (error-path testing, layer composition, anti-vi.mock() rationale), read references/effect-tdd-patterns.md.


Use project-convention test locations (examples)

Treat these paths as project conventions/examples; adapt if a repository uses different test layout.

Code LocationTest Location
packages/X/src/file.tspackages/X/src/__tests__/file.test.ts
apps/web-app/src/infrastructure/trpc/routers/X.tsapps/web-app/src/__tests__/X.test.ts
apps/web-app/src/routes/**apps/web-app/e2e/feature.e2e.ts

Use supporting references for depth

Load targeted references instead of expanding this file during execution:

  • Use references/commands.md for runnable command patterns.
  • Use references/anti-patterns.md for failure-mode walkthroughs and corrections.

Resources

references/

  • red-green-refactor.md - Detailed TDD cycle workflow with examples
  • effect-tdd-patterns.md - Effect service testing, mock layers, error cases
  • test-first-examples.md - Step-by-step TDD examples for this codebase
  • commands.md - Command catalog and correct/incorrect invocation patterns
  • anti-patterns.md - Detailed TDD anti-pattern walkthroughs with fixes

Related Skills

  • testing-patterns - Test syntax, TRPC integration tests, E2E patterns
  • effect-ts - Effect service design, layers, error handling

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

34.54%
按下载量换算85

Claude

33.18%
按下载量换算81

Cursor

19.49%
按下载量换算48

Gemini CLI

10.22%
按下载量换算25

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

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

安装前确认

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

来源信息

继续浏览同类 Skills