agentleFS
Vimalk0703Vimalk0703/shipworthy/skills/quality/test-driven-development/SKILL.md

test-driven-development

Skill6 starsChanged 8 months agoMITView on GitHub

Testing discipline that adapts to user tier and task type. Rigorous RED-GREEN-REFACTOR for critical code. Invisible testing for Builder-tier users. Pragmatic skip for trivial changes. The goal is confidence that the code works, not ceremony.

  • Installs packages

191 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use diagnosing-superpowers, api-and-interface-design and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • obraSkill

    diagnosing-superpowers

    Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

    Also in 6 projects that use this

  • LLl0k0laDSkill

    api-and-interface-design

    Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

    Also in 32 projects that use this

  • MorningStar0709Skill

    workflow-runner

    Run an agency-orchestrator style YAML workflow inside the current Trae conversation by simulating or coordinating multiple roles. Use when the user provides a `.yaml` or `.yml` workflow, asks for multi-role collaboration, says things like “用多个角色一起评审这个 PRD”“多角色协作”“先生成工作流再执行”“让产品经理、架构师、QA 一起看一下”, or wants roles such as product manager, architect, reviewer, or QA to work together. Supports layered execution, role prompting, variable interpolation, document-backed inputs, and parallel steps only when the current environment has a clear subagent mapping. Do not use for ordinary implementation plans, simple code changes, or tasks already covered by `writing-plans`, `executing-plans`, `subagent-driven-development`, or single-purpose review/debug skills.

    Also in 5 projects that use this

  • LLl0k0laDSkill

    using-agent-skills

    Use when starting a session or when you need to discover which skill applies to the current task. This is the meta-skill that governs how all other skills are discovered and invoked.

    Also in 25 projects that use this

  • MorningStar0709Skill

    chinese-git-workflow

    Configure Git for domestic platforms and manage branching strategies suitable for Chinese teams. Use when the user asks to configure remotes, set up SSH, or manage Git workflows for Gitee, Coding, Jihu GitLab, or CNB, including requests like "配置国内 Git", "设置 Gitee 远程仓库", "推荐适合小团队的 Git 流程".

    Also in 4 projects that use this

  • vinvcnSkill

    constraint-driven-development

    把一个项目的质量线确立为书面契约,并阻止 agent 悄悄降低它。通过访谈确定用户在意哪些维度,当用户心里没有数字时提供合理的默认阈值,把一切记录进 CONSTRAINTS.md,并盯住 diff 中质量线被削弱的迹象——新增的 @ts-ignore 或 eslint-disable 抑制注释、被跳过或删除的测试、被剥掉的断言、未实现的 stub、被调低的阈值。当没有任何质量线被写下来时使用;当用户说 "set up constraints" 或 "define our standards" 时;当用户希望把他们在意的维度——无障碍性、Web 性能、覆盖率——设置成被强制执行的约束时;当 agent 为了变绿不断静默检查或跳过测试时;当你需要一个覆盖率或性能阈值却不知道该选什么数字时;或者当 agent 写下的代码超出任何人会读的体量时。

    Also in 4 projects that use this

  • +5 more from LLl0k0laD

The file

Show its rules and text

We split this skill into the rules it gives an agent

23 rules. 0 are common, 18 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 177 edited versions we read keep these.

  • 18

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write tests. Always write tests for anything meaningful.

    line 26
  2. Distinctive:

    Run them. Make sure they pass.

    line 27
  3. Distinctive:

    If something breaks, say: "I found an issue with how refunds were handled and fixed it."

    line 29
  4. Distinctive:

    Write a test that asserts the expected behavior

    line 80
  5. Distinctive:

    Run the test — it MUST fail

    line 81
  6. Distinctive:

    If it passes, your test is wrong or the feature already exists

    line 82
  7. Distinctive:

    Write the MINIMUM code to make the test pass

    line 85
  8. Distinctive:

    Do not write elegant code — write working code

    line 86
  9. Distinctive:

    Do not add features the test doesn't require

    line 87
  10. Distinctive:

    Run the test — it MUST pass

    line 88
  11. Distinctive:

    Run tests after EVERY refactor step — they must still pass

    line 93
  12. Distinctive:

    If tests break during refactoring, your refactor changed behavior — undo it

    line 94
  13. Distinctive:

    No matter who the user is or how small the task seems, these ALWAYS get tested:

    line 100
  14. Distinctive:

    Create operations validate required fields

    line 121
  15. Distinctive:

    Update operations don't overwrite unrelated fields

    line 122
  16. Distinctive:

    Delete operations handle cascading correctly

    line 123
  17. Distinctive:

    Before writing any test, ensure the test infrastructure exists:

    line 157
  18. Very specific:

    Add scripts to package.json:

    line 161
  19. Very specific:

    If supertest is needed for API tests: npm install -D supertest @types/supertest

    line 167
  20. Very specific:

    Add pytest.ini or pyproject.toml config with coverage settings

    line 171
  21. Very specific:

    Use stdlib testing — no install needed

    line 174
  22. Very specific:

    Read architecture.md to determine:

    line 194
  23. Distinctive:

    Follow whatever the architecture spec says.

    line 200

“Common” is measured: kept by at least 6 in 10 of the 177 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Test-Driven Development

The Iron Rule

NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST — for code that matters.

This rule applies absolutely to: business logic, authentication, payments, data mutations, API endpoints, and calculations. No exceptions, no matter who's asking or how small the change seems.

For everything else, the approach adapts to the situation.


Tier-Adapted Testing Modes

Invisible TDD (Builder-Tier Users)

Builder-tier users care that things work, not how you verified they work. When working with Builder-tier users:

Do this:

  • Write tests. Always write tests for anything meaningful.
  • Run them. Make sure they pass.
  • Report results in outcome language: "I built the payment flow and verified it works correctly — handles successful charges, declined cards, and network errors."
  • If something breaks, say: "I found an issue with how refunds were handled and fixed it."

Don't do this:

  • "I wrote 3 failing tests to establish the RED state..."
  • "Achieved GREEN state on all test cases..."
  • "Now entering the REFACTOR phase..."
  • "Test coverage is at 87.3% across 12 test suites..."

The tests still exist. The discipline still happens. The user just doesn't need a play-by-play of your testing methodology. They need to know their product works.

How to report:

Instead ofSay
"Wrote 5 unit tests for the auth module""Built the login system and verified it handles email/password, Google sign-in, and invalid credentials correctly"
"RED: 3 failing tests for payment processing""Working on the payment flow now"
"All 12 tests passing, 94% coverage""Payment processing is working — tested with successful charges, declines, and edge cases"
"Added regression test for bug #234""Fixed the bug and made sure it won't come back"

Pragmatic TDD (Quick Fixes, Any Tier)

Some changes don't need formal TDD. Applying RED-GREEN-REFACTOR to a CSS color change is like wearing a hard hat to check the mailbox.

Skip formal TDD for:

  • CSS and styling changes (spacing, colors, fonts, layout tweaks)
  • Copy and text updates (labels, messages, placeholder text)
  • Configuration changes (env vars, feature flags, build config)
  • Simple UI tweaks (reordering elements, showing/hiding existing components)
  • Static content updates (about pages, marketing copy)
  • Dependency version bumps (with no API changes)

Instead, verify these by:

  • Building the project (confirms no syntax errors)
  • Visually checking the result when possible
  • Running the existing test suite (confirms nothing broke)

But NEVER skip tests for "quick fixes" that touch:

  • Authentication or authorization logic
  • Payment or billing code
  • Database queries or migrations
  • API request/response handling
  • Business rules or calculations
  • Data validation or sanitization

A "quick" auth fix without tests is how breaches happen.

Full TDD (Engineer-Tier Users, All Critical Code)

The complete RED-GREEN-REFACTOR cycle. Engineer-tier users appreciate and expect this rigor.

RED: Write a Failing Test

  1. Decide what the code should DO (not how it should work internally)
  2. Write a test that asserts the expected behavior
  3. Run the test — it MUST fail
  4. If it passes, your test is wrong or the feature already exists

GREEN: Make It Pass

  1. Write the MINIMUM code to make the test pass
  2. Do not write elegant code — write working code
  3. Do not add features the test doesn't require
  4. Run the test — it MUST pass

REFACTOR: Clean Up

  1. Now that it works, make it clean
  2. Extract common patterns, improve naming, simplify logic
  3. Run tests after EVERY refactor step — they must still pass
  4. If tests break during refactoring, your refactor changed behavior — undo it

What ALWAYS Gets Tests Regardless of Tier

No matter who the user is or how small the task seems, these ALWAYS get tested:

Auth Flows

  • Login with valid credentials succeeds
  • Login with invalid credentials fails with appropriate error
  • Session expiry is handled correctly
  • Protected routes reject unauthenticated requests
  • Role-based access controls are enforced
  • Password reset flow works end-to-end
  • OAuth callback handling works correctly

Payment Processing

  • Successful charge processes correctly
  • Declined card is handled gracefully
  • Webhook signature verification works
  • Refund flow processes correctly
  • Subscription creation, update, and cancellation work
  • Price calculation is accurate (tax, discounts, currency)
  • Idempotency keys prevent duplicate charges

Data Mutations

  • Create operations validate required fields
  • Update operations don't overwrite unrelated fields
  • Delete operations handle cascading correctly
  • Concurrent writes don't cause data corruption
  • Invalid data is rejected with clear errors
  • Database transactions roll back on failure

API Endpoints

  • Correct status codes for success and error cases
  • Request validation rejects malformed input
  • Response shape matches the contract
  • Rate limiting works (if applicable)
  • Authentication is enforced on protected endpoints
  • Pagination works correctly

Business Calculations

  • Pricing calculations are accurate
  • Rounding is handled correctly (especially for currency)
  • Edge cases: zero amounts, negative values, overflow
  • Time zone handling is correct
  • Unit conversions are accurate

Testing Anti-Patterns to Avoid

  1. Testing implementation, not behavior — test WHAT it does, not HOW it does it
  2. Mocking everything — mocks that diverge from reality give false confidence
  3. Testing the framework — don't test that React renders a div
  4. No assertions — a test without assertions is not a test
  5. Flaky tests — fix or delete; a flaky test is worse than no test
  6. Testing trivial getters/setters — this adds maintenance, not confidence
  7. Ceremonial tests — writing tests to hit a coverage number rather than to verify behavior

Test Infrastructure Setup (Do This First)

Before writing any test, ensure the test infrastructure exists:

TypeScript/JavaScript

  1. Install vitest if not present: npm install -D vitest @vitest/coverage-v8
  2. Add scripts to package.json:
    "test": "vitest run",
    "test:watch": "vitest",
    "test:coverage": "vitest run --coverage"
  3. If supertest is needed for API tests: npm install -D supertest @types/supertest

Python

  1. Install pytest if not present: pip install pytest pytest-cov
  2. Add pytest.ini or pyproject.toml config with coverage settings

Go

  1. Use stdlib testing — no install needed
  2. Run with: go test -cover ./...

This is a one-time setup. Do it on the FIRST test, not every test.

TypeScript-Specific Rules

  • NEVER use catch (err: any) — use catch (err: unknown) and narrow:
    catch (err: unknown) {
      if (err instanceof Error) {
        // handle Error
      }
      throw err;
    }
  • NEVER use : any in test files either — tests should be as strictly typed as production code

Integration with Architecture Spec

Read architecture.md to determine:

  • Which testing framework to use (Jest, Vitest, pytest, Go testing, etc.)
  • Where test files should live (co-located, __tests__/, tests/)
  • Naming conventions for test files
  • Coverage thresholds (if specified)

Follow whatever the architecture spec says. If it doesn't specify, default to Vitest for TypeScript, pytest for Python, stdlib testing for Go.


Rationalization Pressure Test

These are excuses you might generate to skip testing. Each one is wrong.

RationalizationWhy It's WrongWhat To Do Instead
"This change is too small to test"Small changes cause big bugs. A one-line auth fix without tests is how breaches happenIf it's small, the test is small too — write it
"I'll add tests later"Later never comes. Untested code breeds more untested codeWrite the test FIRST. That's what TDD means
"The test would be trivial"If it's trivial, it takes 30 seconds. If it's not trivial, you definitely need itWrite the "trivial" test and move on
"Testing this would require too much setup"Complex test setup signals complex code that needs testing the mostSimplify the code or invest in test fixtures. Either way, test it
"The user didn't ask for tests"Production code gets tests. That's not optional. Your human partner is paying for working softwareWrite tests. Report results, not methodology
"This is just a prototype"Shipworthy exists to prevent prototypes from becoming unmaintainable production codeTest the prototype. It's faster than debugging it later
"I can verify this manually"Manual verification misses edge cases and regressions. Run the commandWrite an automated test. Run it. Trust the output
"The existing tests already cover this"If they do, adding one more is cheap insurance. If they don't, you need itCheck coverage. If covered, great. If not, add a test

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.