[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75NGD25AY0E4F8JRY8AT392":3,"skill-same:01M75NGD25AY0E4F8JRY8AT392":60},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M75NGD25AY0E4F8JRY8AT392","tdd",null,"Use during design and planning to shape testable interfaces, seams, and verification strategy; use during implementation when a plan needs a test-first behavior cycle","don-smith\u002Fmyflow","don-smith","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F228761?v=4","01M75NEQQ3GJBN4ARH0S5EFYV2","Don Smith","01M75NEQQVBT5HAYN363PDG334",0,"MIT","https:\u002F\u002Fgithub.com\u002Fdon-smith\u002Fmyflow\u002Fblob\u002Fmain\u002Fskills\u002Ftdd\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: tdd\ndescription: Use during design and planning to shape testable interfaces, seams, and verification strategy; use during implementation when a plan needs a test-first behavior cycle\n---\n\n# Test-Driven Development\n\nTDD is a design practice with a testing side effect. A test is a small, executable design conversation: it describes the behavior a caller needs, exposes the interface and seam that behavior requires, and gives us a regression check once the design is implemented.\n\nTDD is not the same as unit testing. Unit testing means having tests for a unit, regardless of when they were written. TDD means using a failing behavior example to design the interface and implementation before writing production code. The valuable result is a module with a small, useful interface, clear dependencies, and tests that exercise behavior rather than implementation details.\n\n## When to use this skill\n\nUse TDD primarily during **Design and Plan**:\n\n- identify the public interfaces and seams for risk-bearing behavior;\n- decide which dependencies should be passed in rather than constructed internally;\n- choose the appropriate test level (unit, integration, contract, or end-to-end);\n- turn acceptance criteria into executable examples; and\n- record what is and is not covered by automated verification.\n\nDuring **Implement**, follow the TDD decisions and verification map in the accepted plan. Invoke this skill again only when the plan has not specified a seam or behavior, or when implementation reveals that the planned interface is not workable. Do not reopen settled design merely to repeat the loop.\n\nTDD may be unnecessary for throwaway prototypes, generated code, and configuration-only changes. For legacy behavior, write a characterization or regression test at the best available public seam before changing it.\n\nWhen exploring a repository, read `CONTEXT.md` if it exists and respect applicable ADRs so the interface vocabulary, test locations, and dependency conventions match the codebase.\n\n## Design the seam before the test\n\nA **seam** is the interface where a test observes behavior without reaching inside the module. Tests and callers should cross the same seam.\n\nBefore writing a test, record and, during collaborative planning, confirm:\n\n1. **Behavior** — what should a caller observe, using an acceptance criterion or independent example.\n2. **Interface** — the smallest useful public interface that can provide that behavior.\n3. **Dependencies** — what the implementation needs, and which of those should be supplied by the caller.\n4. **Test level** — the cheapest level that exercises the real behavior without hiding important integration.\n\nUse public interfaces, not private methods, internal collaborators, call counts, or side channels. If a test needs to reach inside, first ask whether the seam is in the wrong place or the module is too shallow. Use `codebase-design` as the vocabulary when the interface, depth, or seam is itself a design question: module, interface, seam, adapter, depth, leverage, and locality.\n\nPrefer designs that:\n\n- accept dependencies through parameters, constructors, or factories rather than creating them internally;\n- return meaningful results rather than requiring tests to observe incidental side effects;\n- keep infrastructure behind an adapter at a deliberate seam; and\n- expose a small, deep interface that hides implementation complexity.\n\nA test that requires mocking an unrelated internal dependency is design feedback. Simplify the interface or move the seam before adding more test machinery.\n\n## The red → green loop\n\nWork in a vertical slice: one behavior, one failing test, one minimal implementation.\n\n### 1. Red — write the behavior first\n\nWrite one clear test through the agreed public interface. Use a real example and an independent expected result. Name the behavior, not the implementation.\n\n```typescript\ntest(\"returns the saved account by id\", async () => {\n  const accounts = new InMemoryAccounts();\n  const service = new AccountService(accounts);\n\n  await service.save({ id: \"a-1\", name: \"Ada\" });\n\n  expect(await service.get(\"a-1\")).toEqual({ id: \"a-1\", name: \"Ada\" });\n});\n```\n\n### 2. Verify red — observe the right failure\n\nRun the narrowest relevant test command. Confirm that it fails because the behavior is missing, not because of a typo, invalid setup, or broken test runner. A test that already passes is not a useful red step; revise it or choose the next missing behavior.\n\nDo not add a separate “break it on purpose” step. The intended behavior should be absent until the implementation is written, so the first execution supplies the necessary evidence.\n\n### 3. Green — implement only enough\n\nWrite the smallest production change that makes the failing behavior pass. Pass dependencies into the code under test. Do not add speculative options, unrelated refactors, or test-only production methods.\n\n### 4. Verify green — run the narrow test, then the relevant suite\n\nConfirm the new test passes, then run the affected suite and the project checks required by the plan. If a test fails, fix the implementation or revisit the design; do not weaken the test to fit the code.\n\n### 5. Refine after green\n\nRemove duplication and improve names only while behavior remains green. Larger architectural refactors belong in the plan or review, not hidden inside a red → green cycle. Repeat with the next behavior.\n\n## Test doubles and infrastructure\n\nPrefer real implementations, simple fixtures, and in-memory adapters where they make the behavior clearer. A fake is acceptable when it is a small, meaningful adapter with behavior the test genuinely needs; do not build elaborate test-only worlds.\n\nMocks are exceptional, not the default:\n\n- do not mock your own modules or internal collaborators merely to isolate a unit;\n- mock only a genuine system seam when using the real adapter would be unsafe, slow, nondeterministic, or outside the test's purpose;\n- prefer dependency injection over patching globals or intercepting internal calls; and\n- if a mock is necessary, understand the real dependency and model the complete data shape the code may consume.\n\nIntegration tests with real components are often simpler and more trustworthy than a large collection of mocks. Test the behavior of the subject, never the behavior or existence of a mock. Read [mocking.md](mocking.md) and [testing-anti-patterns.md](testing-anti-patterns.md) before introducing a double.\n\n## Verification map: make tests visible\n\nDo not leave test intent buried in individual test files. During Design or Plan, add a concise verification map to the stage artifact or handoff:\n\n```markdown\n## Verification Map\n\n| Acceptance criterion | Observable behavior \u002F seam | Test level | Test location or name | Status |\n|---|---|---|---|---|\n| Account can be retrieved after saving | `AccountService` public interface | integration | `account-service.test.ts`: returns the saved account | planned |\n\n### Explicitly not tested\n- Real database failover — covered by the database adapter's integration environment, not this change.\n```\n\nThe map is a coverage summary, not a replacement for tests. It should make clear:\n\n- which acceptance criteria have automated evidence;\n- which test level and seam provide that evidence;\n- where a reviewer can find the evidence without reading every test; and\n- what is explicitly not tested, with a reason or a follow-up.\n\nKeep the map synchronized with the plan's success criteria as slices change. At handoff, include the test commands, changed test paths, current red\u002Fgreen evidence, and any uncovered criteria.\n\n## Quality gates\n\nBefore a slice is complete:\n\n- [ ] The behavior and public seam were identified before implementation.\n- [ ] The test was written before the production behavior and failed for the expected reason.\n- [ ] The test asserts observable behavior with an independent expected result.\n- [ ] Dependencies are injected where doing so improves the seam; no unrelated internal dependency is mocked.\n- [ ] The smallest useful implementation passes the test.\n- [ ] The affected suite and required project checks pass.\n- [ ] The verification map records the acceptance-criterion coverage and explicit exclusions.\n\nDo not turn these gates into a demand for one unit test per function. Choose tests for meaningful behavior and risk. A well-designed integration test can be better evidence than many isolated tests.\n\n## References\n\n- [tests.md](tests.md) — examples of behavior-focused tests and tautological-test traps\n- [mocking.md](mocking.md) — dependency injection and system-boundary guidance\n- [testing-anti-patterns.md](testing-anti-patterns.md) — mock and test-only production-code anti-patterns\n","# Test-Driven Development\n\nTDD is a design practice with a testing side effect. A test is a small, executable design conversation: it describes the behavior a caller needs, exposes the interface and seam that behavior requires, and gives us a regression check once the design is implemented.\n\nTDD is not the same as unit testing. Unit testing means having tests for a unit, regardless of when they were written. TDD means using a failing behavior example to design the interface and implementation before writing production code. The valuable result is a module with a small, useful interface, clear dependencies, and tests that exercise behavior rather than implementation details.\n\n## When to use this skill\n\nUse TDD primarily during **Design and Plan**:\n\n- identify the public interfaces and seams for risk-bearing behavior;\n- decide which dependencies should be passed in rather than constructed internally;\n- choose the appropriate test level (unit, integration, contract, or end-to-end);\n- turn acceptance criteria into executable examples; and\n- record what is and is not covered by automated verification.\n\nDuring **Implement**, follow the TDD decisions and verification map in the accepted plan. Invoke this skill again only when the plan has not specified a seam or behavior, or when implementation reveals that the planned interface is not workable. Do not reopen settled design merely to repeat the loop.\n\nTDD may be unnecessary for throwaway prototypes, generated code, and configuration-only changes. For legacy behavior, write a characterization or regression test at the best available public seam before changing it.\n\nWhen exploring a repository, read `CONTEXT.md` if it exists and respect applicable ADRs so the interface vocabulary, test locations, and dependency conventions match the codebase.\n\n## Design the seam before the test\n\nA **seam** is the interface where a test observes behavior without reaching inside the module. Tests and callers should cross the same seam.\n\nBefore writing a test, record and, during collaborative planning, confirm:\n\n1. **Behavior** — what should a caller observe, using an acceptance criterion or independent example.\n2. **Interface** — the smallest useful public interface that can provide that behavior.\n3. **Dependencies** — what the implementation needs, and which of those should be supplied by the caller.\n4. **Test level** — the cheapest level that exercises the real behavior without hiding important integration.\n\nUse public interfaces, not private methods, internal collaborators, call counts, or side channels. If a test needs to reach inside, first ask whether the seam is in the wrong place or the module is too shallow. Use `codebase-design` as the vocabulary when the interface, depth, or seam is itself a design question: module, interface, seam, adapter, depth, leverage, and locality.\n\nPrefer designs that:\n\n- accept dependencies through parameters, constructors, or factories rather than creating them internally;\n- return meaningful results rather than requiring tests to observe incidental side effects;\n- keep infrastructure behind an adapter at a deliberate seam; and\n- expose a small, deep interface that hides implementation complexity.\n\nA test that requires mocking an unrelated internal dependency is design feedback. Simplify the interface or move the seam before adding more test machinery.\n\n## The red → green loop\n\nWork in a vertical slice: one behavior, one failing test, one minimal implementation.\n\n### 1. Red — write the behavior first\n\nWrite one clear test through the agreed public interface. Use a real example and an independent expected result. Name the behavior, not the implementation.\n\n```typescript\ntest(\"returns the saved account by id\", async () => {\n  const accounts = new InMemoryAccounts();\n  const service = new AccountService(accounts);\n\n  await service.save({ id: \"a-1\", name: \"Ada\" });\n\n  expect(await service.get(\"a-1\")).toEqual({ id: \"a-1\", name: \"Ada\" });\n});\n```\n\n### 2. Verify red — observe the right failure\n\nRun the narrowest relevant test command. Confirm that it fails because the behavior is missing, not because of a typo, invalid setup, or broken test runner. A test that already passes is not a useful red step; revise it or choose the next missing behavior.\n\nDo not add a separate “break it on purpose” step. The intended behavior should be absent until the implementation is written, so the first execution supplies the necessary evidence.\n\n### 3. Green — implement only enough\n\nWrite the smallest production change that makes the failing behavior pass. Pass dependencies into the code under test. Do not add speculative options, unrelated refactors, or test-only production methods.\n\n### 4. Verify green — run the narrow test, then the relevant suite\n\nConfirm the new test passes, then run the affected suite and the project checks required by the plan. If a test fails, fix the implementation or revisit the design; do not weaken the test to fit the code.\n\n### 5. Refine after green\n\nRemove duplication and improve names only while behavior remains green. Larger architectural refactors belong in the plan or review, not hidden inside a red → green cycle. Repeat with the next behavior.\n\n## Test doubles and infrastructure\n\nPrefer real implementations, simple fixtures, and in-memory adapters where they make the behavior clearer. A fake is acceptable when it is a small, meaningful adapter with behavior the test genuinely needs; do not build elaborate test-only worlds.\n\nMocks are exceptional, not the default:\n\n- do not mock your own modules or internal collaborators merely to isolate a unit;\n- mock only a genuine system seam when using the real adapter would be unsafe, slow, nondeterministic, or outside the test's purpose;\n- prefer dependency injection over patching globals or intercepting internal calls; and\n- if a mock is necessary, understand the real dependency and model the complete data shape the code may consume.\n\nIntegration tests with real components are often simpler and more trustworthy than a large collection of mocks. Test the behavior of the subject, never the behavior or existence of a mock. Read [mocking.md](mocking.md) and [testing-anti-patterns.md](testing-anti-patterns.md) before introducing a double.\n\n## Verification map: make tests visible\n\nDo not leave test intent buried in individual test files. During Design or Plan, add a concise verification map to the stage artifact or handoff:\n\n```markdown\n## Verification Map\n\n| Acceptance criterion | Observable behavior \u002F seam | Test level | Test location or name | Status |\n|---|---|---|---|---|\n| Account can be retrieved after saving | `AccountService` public interface | integration | `account-service.test.ts`: returns the saved account | planned |\n\n### Explicitly not tested\n- Real database failover — covered by the database adapter's integration environment, not this change.\n```\n\nThe map is a coverage summary, not a replacement for tests. It should make clear:\n\n- which acceptance criteria have automated evidence;\n- which test level and seam provide that evidence;\n- where a reviewer can find the evidence without reading every test; and\n- what is explicitly not tested, with a reason or a follow-up.\n\nKeep the map synchronized with the plan's success criteria as slices change. At handoff, include the test commands, changed test paths, current red\u002Fgreen evidence, and any uncovered criteria.\n\n## Quality gates\n\nBefore a slice is complete:\n\n- [ ] The behavior and public seam were identified before implementation.\n- [ ] The test was written before the production behavior and failed for the expected reason.\n- [ ] The test asserts observable behavior with an independent expected result.\n- [ ] Dependencies are injected where doing so improves the seam; no unrelated internal dependency is mocked.\n- [ ] The smallest useful implementation passes the test.\n- [ ] The affected suite and required project checks pass.\n- [ ] The verification map records the acceptance-criterion coverage and explicit exclusions.\n\nDo not turn these gates into a demand for one unit test per function. Choose tests for meaningful behavior and risk. A well-designed integration test can be better evidence than many isolated tests.\n\n## References\n\n- [tests.md](tests.md) — examples of behavior-focused tests and tautological-test traps\n- [mocking.md](mocking.md) — dependency injection and system-boundary guidance\n- [testing-anti-patterns.md](testing-anti-patterns.md) — mock and test-only production-code anti-patterns\n",{"name":5,"description":7},"main","d0a5f620d08689e2cb9684ab07b8055854402f57","skills\u002Ftdd","https:\u002F\u002Fgithub.com\u002Fdon-smith\u002Fmyflow","https:\u002F\u002Fdon-smith.github.io\u002Fmyflow\u002F","https:\u002F\u002Fgithub.com\u002Fdon-smith","attempting the most positive impact possible while trying to figure out what that means","2026-10-23 09:17:14",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add don-smith\u002Fmyflow --skill tdd",{"tool":38,"command":39},"bunx","bunx skills add don-smith\u002Fmyflow --skill tdd",{"tool":41,"command":42},"pnpm","pnpm dlx skills add don-smith\u002Fmyflow --skill tdd","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdon-smith\u002Fmyflow\u002Fblob\u002Fmain\u002Fskills\u002Ftdd\u002FSKILL.md",true,[46,52,56],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"mocking.md","REFERENCE","参考文档",1481,"https:\u002F\u002Fgithub.com\u002Fdon-smith\u002Fmyflow\u002Fblob\u002Fmain\u002Fskills\u002Ftdd\u002Fmocking.md",{"path":53,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":54,"sourceHtmlUrl":55},"testing-anti-patterns.md",8251,"https:\u002F\u002Fgithub.com\u002Fdon-smith\u002Fmyflow\u002Fblob\u002Fmain\u002Fskills\u002Ftdd\u002Ftesting-anti-patterns.md",{"path":57,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":58,"sourceHtmlUrl":59},"tests.md",2214,"https:\u002F\u002Fgithub.com\u002Fdon-smith\u002Fmyflow\u002Fblob\u002Fmain\u002Fskills\u002Ftdd\u002Ftests.md",[61,68,75,82,89,96],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M75NGR4SAVDTSN8A11EW8NBH","clean-support","Use when the clean-stage fixture skill needs a supporting skill to reference.","https:\u002F\u002Fgithub.com\u002Fdon-smith\u002Fmyflow\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskill-structure\u002Fskills\u002Fclean-support\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M75NGPM5WW77DHQN07SSGQWG","clean-stage","Use when exercising the structural skill lint against a tree that satisfies every rule.","https:\u002F\u002Fgithub.com\u002Fdon-smith\u002Fmyflow\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskill-structure\u002Fskills\u002Fclean-stage\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M75NGMXP2ANH3WB2QM5XE75Z","verify","Use after Implement to verify an accepted MyFlow plan, collect review evidence, and produce a workstream-aware Verify report.","https:\u002F\u002Fgithub.com\u002Fdon-smith\u002Fmyflow\u002Fblob\u002Fmain\u002Fskills\u002Fverify\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M75NGHZVYBDA346Q14MH7PRG","technical-writing","Layered technical-writing standard: Diátaxis structure, Google developer style sentences, STE instruction rules, Global English syntax. Use when writing or reviewing docs, RFCs, readmes, PR descriptions, or commit messages.","https:\u002F\u002Fgithub.com\u002Fdon-smith\u002Fmyflow\u002Fblob\u002Fmain\u002Fskills\u002Ftechnical-writing\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":19},"01M75NGB6W0G42QCQNZQSZD0CW","story","Tell a repository's artifact-backed story, answer a question with a dated chapter, or refresh stale story pages.","https:\u002F\u002Fgithub.com\u002Fdon-smith\u002Fmyflow\u002Fblob\u002Fmain\u002Fskills\u002Fstory\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":19},"01M75NG7N9FS6Q9Z35SGFKPXDE","scope","Begin a MyFlow workstream with right-sized, code-light scoping. Establishes a workstream ID and durable alignment artifact when needed, selects only the specialists the work requires, and offers an isolated worktree or trunk-based path.","https:\u002F\u002Fgithub.com\u002Fdon-smith\u002Fmyflow\u002Fblob\u002Fmain\u002Fskills\u002Fscope\u002FSKILL.md",[],[]]