loom-test-driven-development

loom-test-driven-development is a skill for Claude Code, Codex from xiqin/loom. It costs 44 tokens per session (1,035 once invoked), scanned A, original, MIT.

A test-driven development workflow, where tests are written first, the smallest code change makes them pass, and the result is then refactored. TDD means test-driven development.

In plain words
What is it for?
It helps select a public boundary to test, write and run failing tests, implement the required behavior, refactor safely, and repeat the red-green-refactor cycle.
Why use it?
It ensures each production change starts with a failing test that describes observable behavior, reducing the risk of implementing untested behavior.

Skill for Claude CodeCodex

Part of the loom-engineering plugin — 22 skills shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/xiqin/loom/loom-test-driven-development
Any agent
npx skills add xiqin/loom --skill loom-test-driven-development
Clone the repo
git clone --depth 1 https://github.com/xiqin/loom

Made for: Claude Code, Codex.

Or install loom-engineering, the plugin that ships this one along with the rest of its 22 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for loom-test-driven-development

README.md
[![agentmods](https://agentmods.dev/badge/skills/xiqin/loom/loom-test-driven-development.svg)](https://agentmods.dev/skills/xiqin/loom/loom-test-driven-development)
Your own site
<a href="https://agentmods.dev/skills/xiqin/loom/loom-test-driven-development"><img src="https://agentmods.dev/badge/skills/xiqin/loom/loom-test-driven-development.svg" alt="Measured on agentmods" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,035 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00044 $0.01035
Opus 5 $0.00022 $0.00517
Sonnet 5 $0.00009 $0.00207
Haiku 4.5 $0.00004 $0.00103

Measured 4d ago against content hash 4f14613e3978, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

loom-test-driven-development scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/loom-test-driven-development/SKILL.md · 117 lines

What it actually says

测试驱动开发(TDD)

核心循环

红(Red)→ 绿(Green)→ 重构(Refactor)
  1. :先写一个失败的测试。
  2. 绿:写最少的代码让测试通过。
  3. 重构:优化代码结构,保持测试通过。

铁律

  • 没有失败的测试在先,不写生产代码。
  • 测试文件必须持久化到项目标准测试目录,不得作为临时验证后删除。
  • 先写了代码?删除它,从红开始。
  • 写测试前必须确认 seam:测试要通过哪个 public boundary 验证行为。

使用场景

默认用于新功能、bug 修复、重构和行为变更。一次性原型、生成代码或纯配置变更可以先询问用户是否例外。

执行流程

当前 task 的需求产物必须从 specs/<date+feature>/ 读取;不要在项目根目录读取或生成 spec.mdplan.mdtasks/ 等 loom 阶段产物。

Step 1:理解需求

读取 specs/<date+feature>/spec.mdspecs/<date+feature>/plan.md 和当前 specs/<date+feature>/tasks/TN.md,明确当前 task 的测试范围。

Step 2:确认 seam

写测试前先列出候选 seam,并说明每个 seam 对应的 public boundary,例如 CLI 命令、HTTP API、组件交互、公开函数、持久化副作用或事件输出。

必须向用户或当前已批准 spec/plan 对齐以下内容:

  1. 选择哪个 seam。
  2. 该 seam 验证的用户可观察行为是什么。
  3. 为什么不测试内部实现细节。

未确认 seam 时,不得写测试。若用户不在场且 spec/plan 已明确 public boundary,可基于已批准产物确认 seam,并在输出中记录依据。

Step 3:红

  1. 为当前行为写测试。
  2. 运行项目约定的单文件测试命令。
  3. 确认测试因缺少目标行为而失败,而不是拼写、导入或测试本身错误。

测试立即通过说明测了已有行为;修正测试。

Step 4:绿

写最少代码让测试通过,只实现当前测试覆盖的行为。不要顺手扩展功能、重构无关代码或添加未来配置。

Step 5:重构

仅在测试绿色后重构。消除重复、改善命名,并重新运行相关测试。需要时执行 constitution.md 中的 BUILD_CMD、VET_CMD、TEST_CMD。

Step 6:重复

对下一个行为点重复红绿重构。

测试规范

  • 名称描述真实行为。
  • 一个测试验证一件事。
  • 结构遵循 Arrange / Act / Assert。
  • 覆盖正常流程、异常流程和边界条件。
  • 默认测试真实代码,仅在不可避免时 mock。
  • 通过 public seam 验证行为,不绑定私有函数、内部状态或实现顺序。

示例、理由和反模式见:

  • references/examples-and-rationale.md
  • references/testing-anti-patterns.md
  • references/common-excuses.md

红旗

  • 先写代码后写测试。
  • 测试在实现之后添加。
  • 无法解释测试为什么失败。
  • 无法解释测试 seam。
  • 依赖手动测试替代自动测试。
  • 为"就这一次"跳过 TDD 找理由。
  • 想保留未验证代码作为参考。

出现红旗时,删除未验证实现,从红开始。

完成清单

  • 每个新行为都有测试。
  • 每个测试都有明确 seam,且 seam 是 public boundary。
  • 每个测试在实现前因预期原因失败。
  • 实现是让测试通过的最小代码。
  • 所有相关测试通过。
  • 测试文件持久化在项目标准测试目录。
  • 输出干净,无新增错误或警告。

最终规则

生产代码 -> 测试存在且先失败
否则 -> 不是 TDD
Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 117 lines · 44 tokens per session scan A 4f14613e3978

Subscribe to this mod's changes

loom-test-driven-development is a skill published in the GitHub repository xiqin/loom (5 stars, last pushed 1mo ago), licensed MIT. It adds 44 tokens to every session and 1,035 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

tdd

Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.

GreyDGL/PentestGPT · 33 tokens

test-first-bugs

Enforces a test-driven bug-fixing workflow. Use when a user reports a bug, failing code, an error, or asks to fix something.

jamditis/claude-skills-journalism · 35 tokens

growing-outside-in-systems

Drive feature development using Outside-In TDD with Hexagonal Architecture. Design emerges through inline code, in-memory fakes, interface extraction, and deferred I/O. Use when building features, writing tests, or structuring backend services. Triggers on: TDD, outside-in, hexagonal, ports and adapters, emergent…

lexler/skill-factory · 122 tokens

plan-create

Create structured implementation plans for autonomous TDD development. Use for new features, multi-file changes, or anything requiring multiple steps or tests. Triggers on aspirational openers ("let's build", "let's start building", "I want to make", "I want an app that", "help me build"), capability lists ("users…

markshust/hcf · 171 tokens

red-green-refactor

Guides the red-green-refactor TDD workflow: write a failing test first, implement the minimum code to make it pass, then refactor while keeping tests green. Use when a user asks to practice TDD, write tests first, follow red-green-refactor, do test-driven development, write failing tests before code, or phrases like…

rohitg00/skillkit · 90 tokens

outside-in-tdd

Use when writing tests from the outside-in, defining behavior before code, or any feature where tests should start from observable business behavior and let internal design emerge.

SebastienDegodez/copilot-instructions · 35 tokens