Test driven development
Skill pantheon-org/tekhne/skills/testing/test-driven-development
Guides TDD (test-driven development) with red-green-refactor workflows, test-first feature delivery, bug reproduction through failing tests, behavior-focused assertions, and refactoring safety. Use when writing unit tests, implementing new functions, adding test coverage, fixing regressions, changing APIs, or restructuring code under test — especially when a user says "write tests first", "TDD", or "test before code".From its SKILL.md
npx -y skills add pantheon-org/tekhne --skill test-driven-developmentAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 9 stars9 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.4 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it
Test-Driven Development
Navigation hub for applying TDD in day-to-day implementation work.
When to Use
- "Write tests first for this feature."
- "How should I do red-green-refactor here?"
- "I need to reproduce a bug with a failing test first."
- "I want to refactor safely while preserving behavior."
When Not to Use
- End-to-end scenario design across full systems.
- Performance benchmarking and load testing.
- Security testing workflows.
Scope
In Scope
- Unit test design and behavior-driven assertions.
- Red-Green-Refactor cycle execution.
- Mock/stub isolation strategy.
- Naming and organization conventions for maintainable tests.
Out of Scope
- Full E2E harness setup and browser automation pipelines.
- Infra-only test framework bootstrapping.
- Non-deterministic perf profiling.
Workflow
- Write the smallest failing test that expresses one behavior.
- Run tests and verify failure is for the expected reason.
- Implement minimal code to make the test pass.
- Refactor while keeping the suite green.
- Repeat for next behavior/edge case.
Example: Red-Green-Refactor Cycle (TypeScript)
RED — write the failing test first:
// add.test.ts
import { add } from "./add";
test("add returns the sum of two numbers", () => {
expect(add(2, 3)).toBe(5);
});
// ❌ Fails: cannot find module './add'
GREEN — implement the minimum code to pass:
// add.ts
export function add(a: number, b: number): number {
return a + b;
}
// ✅ Test passes
REFACTOR — improve without breaking green:
// add.ts — no logic change needed here, but you might rename,
// extract constants, or improve types while the suite stays green.
export const add = (a: number, b: number): number => a + b;
// ✅ Still green
Example: Elixir variant
# test/math_test.exs (RED)
test "add/2 returns the sum" do
assert Math.add(2, 3) == 5
end
# lib/math.ex (GREEN)
defmodule Math do
def add(a, b), do: a + b
end
Quick Commands
# Run full suite
bun test
# Watch mode while iterating
bun test --watch
# Run a specific file
bun test path/to/file.test.ts
# Elixir variant
mix test
Anti-Patterns
NEVER implement feature code before writing a failing test
WHY: skipping RED phase removes behavior-first design pressure.
// BAD: production code written first, test added after
export function greet(name: string) { return `Hello, ${name}!`; }
// ... then test written to match existing impl
// GOOD: test written first, impl follows
test("greet returns a personalised greeting", () => {
expect(greet("Ada")).toBe("Hello, Ada!");
});
// ❌ red → write greet() → ✅ green
NEVER test implementation details instead of behavior
WHY: implementation-coupled tests break during valid refactors.
// BAD: asserting internal call sequence
expect(mockFormatter.format).toHaveBeenCalledBefore(mockLogger.log);
// GOOD: assert observable output
expect(result).toBe("Hello, Ada!");
NEVER combine multiple behaviors into one test case
WHY: failures become ambiguous and debugging slows down.
// BAD: one test covers create/login/update/delete flow
test("user lifecycle", () => { /* 40 lines */ });
// GOOD: one behavior per test
test("createUser returns a user with the given name", () => { ... });
test("login returns a session token for valid credentials", () => { ... });
NEVER use arbitrary sleeps in unit tests
WHY: fixed waits create flaky and slow suites.
// BAD
await sleep(1000);
expect(result).toBeDefined();
// GOOD: synchronize with deterministic signals
await expect(promise).resolves.toBeDefined();
Verification
# Evaluate skill quality
sh skills/agentic-harness/skill-quality-auditor/scripts/evaluate.sh test-driven-development --json
# Lint this skill docs
bunx markdownlint-cli2 "skills/test-driven-development/**/*.md"
References
| Topic | Reference |
|---|---|
| Red-Green-Refactor cycle | references/cycle-write-test-first.md |
| Verify failing tests first | references/cycle-verify-test-fails-first.md |
| AAA and behavior-first design | references/design-aaa-pattern.md |
| Avoid implementation-detail tests | references/design-test-behavior-not-implementation.md |
| Isolation and dependency injection | references/isolate-use-dependency-injection.md |
| Flakiness and speed | references/perf-fix-flaky-tests.md |
What ships with it: 49 files
109.8 KB alongside SKILL.md
evals/
- scenario-01.md3.7 KB
- scenario-02.md4.4 KB
- scenario-03.md3.9 KB
- scenario-04.md4.0 KB
- scenario-05.md4.3 KB
references/
- assert-custom-matchers.md2.3 KB
- assert-error-messages.md1.8 KB
- assert-no-assertions-antipattern.md2.2 KB
- assert-snapshot-testing.md2.1 KB
- assert-specific-assertions.md1.9 KB
- cycle-maintain-test-list.md2.0 KB
- cycle-minimal-code-to-pass.md1.8 KB
- cycle-refactor-after-green.md1.8 KB
- cycle-small-increments.md2.1 KB
- cycle-verify-test-fails-first.md1.8 KB
- cycle-write-test-first.md2.0 KB
- data-avoid-mystery-guests.md2.0 KB
- data-builder-pattern.md2.6 KB
- data-minimal-setup.md1.8 KB
- data-unique-identifiers.md2.3 KB
- data-use-factories.md2.3 KB
- design-aaa-pattern.md2.0 KB
- design-avoid-logic-in-tests.md2.3 KB
- design-descriptive-test-names.md1.7 KB
- design-one-assertion-per-test.md2.2 KB
- design-test-behavior-not-implementation.md2.0 KB
- design-test-edge-cases.md2.4 KB
- isolate-deterministic-tests.md2.1 KB
- isolate-mock-external-dependencies.md1.8 KB
- isolate-no-shared-state.md1.8 KB
- isolate-prefer-stubs-over-mocks.md2.4 KB
- isolate-use-dependency-injection.md2.5 KB
- org-file-structure.md1.6 KB
- org-group-by-behavior.md2.1 KB
- org-parameterized-tests.md2.4 KB
- org-setup-teardown.md2.3 KB
- org-test-utilities.md2.3 KB
- perf-avoid-network-calls.md2.0 KB
- perf-avoid-sleep.md2.2 KB
- CHANGELOG.md736 B
9 more files not listed here. See all 49 in the repository.