[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ABMZVT7C9KME996EEZ99QB":3,"skill-same:01M7ABMZVT7C9KME996EEZ99QB":46},{"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":30,"ownerDescription":6,"updatedAt":31,"install":32,"resources":45},"01M7ABMZVT7C9KME996EEZ99QB","tdd",null,"Build behavior test-first. Use when a step adds behavior, when adding tests to existing code, or when deciding what to mock or whether a test earns its place. Not for planning the build (write-plan) or spec sign-off (verify-specs).","j0hanz\u002Fj0hanz-marketplace","j0hanz","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F159924955?v=4","01M7ABFK415CKHXYV9GZRJ16T7","Linus Johansson","01M7ABFK52FCPP2PNBH1YR7ZPA",0,"MIT","https:\u002F\u002Fgithub.com\u002Fj0hanz\u002Fj0hanz-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fworkbench\u002Fskills\u002Ftdd\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: tdd\ndescription: Build behavior test-first. Use when a step adds behavior, when adding tests to existing code, or when deciding what to mock or whether a test earns its place. Not for planning the build (write-plan) or spec sign-off (verify-specs).\n---\n\n# Test-Driven Development\n\nTest-first buys one thing: a test you have watched **red**.\n\nWhere a spec exists it supplies the test list — [write-specs](..\u002Fwrite-specs\u002FSKILL.md) names the single observation that falsifies each requirement, and that observation is the test you write. Inside a plan, this loop is how a step that adds behavior gets worked ([run-plan](..\u002Frun-plan\u002FSKILL.md)).\n\n## Steps\n\n### 1. Name the seams\n\nA **seam** is a public boundary you can observe behavior through without reaching inside: an exported function, an HTTP route, a module's public API, a CLI. A test earns its place when it can fail at the seam for a reason a caller would care about — if the only way to break it is to rename a private helper, it tests structure, not behavior.\n\nWrite down the seams under test before any test exists, and confirm them. Where the surface is wide, fan out [research](..\u002Fresearch\u002FSKILL.md) to find the callers and the conventions the tests must match.\n\n**Done when** the seam list is written and confirmed against its callers, and every requirement ID in scope maps to a seam on it — every test written sits at a confirmed seam.\n\n### 2. Red\n\nWrite one failing test at one seam. Before running it, write down the failure you expect: which assertion fails, and the actual value it will report. Then run it. A test that errors on a missing import, a typo, or a file that does not exist yet is not **red**, it is broken.\n\nCode that already exists — a coverage gap, a module that never had tests — passes a new test on its first run, so the red comes from the code: break the line the test claims to cover (invert the condition, return a constant), run, and watch it go red for the predicted reason. A test that stays green under the break does not cover that line; rewrite it. A test red before any break, its expected value sourced from outside the code, has found a defect: hand it to [diagnose](..\u002Fdiagnose\u002FSKILL.md).\n\n**Done when** the test is **red** and its failure matches the prediction written before the run. A different failure is not done: find out why, predict again, rerun.\n\n### 3. Green\n\nWrite the least code that turns that one test **green** — only the branch the current test exercises.\n\nWhere step 2 broke existing code for its red, green is undoing the break: `git diff` on the code under test comes back empty.\n\n**Done when** the new test has been **red** at least once and now passes, every existing test still does, and the new test satisfies every rule in [Writing the test](#writing-the-test): one act, value asserted rather than shape, expected value sourced from outside the code, name carrying the requirement ID where one exists and the capability alone otherwise.\n\nRepeat 2–3 until every requirement ID in scope carries its own test that has been red at least once; with no spec, each behavior the plan step or the repro names counts as one requirement. Each pass is a **vertical slice**, and the test you write next is shaped by what the last slice taught you — a test written ahead of that, in bulk, was never red for a predicted reason.\n\n**Land the slice, then refactor.** Restructuring while chasing green makes a design problem and a broken test indistinguishable; refactor against a green suite as its own pass with [refactor](..\u002Frefactor\u002FSKILL.md), which hands the new structure to [qc](..\u002Fqc\u002FSKILL.md).\n\n## Writing the test\n\n**Name it after the capability, and carry the requirement ID where one exists.** `R2 — expired token is rejected` tells you what the system does and which requirement it answers; `checkout calls paymentService.process` describes plumbing a refactor is free to change.\n\n**One act per test** — a single call to the seam, so a failure names one behavior. Setup before it, assertions after. Two acts in one test means two tests.\n\n**Assert the value, not the shape.** `toBe(\"confirmed\")` fails loudly the day the status changes; `toBeTruthy()` and `not.toBeNull()` keep passing for the wrong reasons. Several `expect`s describing one outcome are still one assertion; two unrelated outcomes are two tests.\n\n**Expected values come from outside the code** — a known-good literal, a worked example, the requirement's `Then` clause. A value recomputed the way the implementation computes it is a **tautology**.\n\n```ts\n\u002F\u002F tautological — the expectation reimplements the function\ntest('calculateTotal sums line items', () => {\n  const items = [{ price: 10 }, { price: 5 }];\n  const expected = items.reduce((sum, i) => sum + i.price, 0);\n  expect(calculateTotal(items)).toBe(expected);\n});\n\n\u002F\u002F independent — 15 was worked out by hand\ntest('calculateTotal sums line items', () => {\n  expect(calculateTotal([{ price: 10 }, { price: 5 }])).toBe(15);\n});\n```\n\n## Boundaries\n\nEverything you own runs for real: your own modules, internal collaborators, the dependencies of the code under test. Mock only where a slice's seam crosses a **system boundary** — what you do not own and cannot make deterministic:\n\n- External APIs: payments, email, third-party HTTP\n- Time and randomness\n- The file system — prefer a real temp directory; mock only where the test must assert on a path the OS will not give you\n- The database — prefer a real test database\n\n**Inject boundary dependencies rather than constructing them.**\n\n```ts\n\u002F\u002F injected — the test hands in its own client\nfunction processPayment(order, paymentClient) {\n  return paymentClient.charge(order.total);\n}\n\n\u002F\u002F constructed — the boundary is welded shut\nfunction processPayment(order) {\n  const client = new StripeClient(process.env.STRIPE_KEY);\n  return client.charge(order.total);\n}\n```\n\n**Give a boundary one function per operation.** An SDK-shaped object lets each mock return one fixed shape, types each response separately, and shows at a glance which endpoints a test exercises. A single generic fetcher pushes an `if` chain over endpoints into every mock.\n\n```ts\n\u002F\u002F SDK-shaped — each operation mocks independently\nconst api = {\n  getUser: (id) => fetch(`\u002Fusers\u002F${id}`),\n  getOrders: (userId) => fetch(`\u002Fusers\u002F${userId}\u002Forders`),\n  createOrder: (data) => fetch('\u002Forders', { method: 'POST', body: data }),\n};\n```\n\n## Test smells\n\nTells that a test already written is bound to implementation rather than behavior.\n\n**It breaks under refactoring while behavior held still.** The test reached inside — mocked an internal collaborator, called a private method, or asserted on call counts and ordering. Assert on what the **seam** returns or does.\n\n**It verifies through a side channel.** Reaching past the interface to a database row, a log line, or a private field couples the test to storage instead of behavior. Verify through the interface a caller would use.\n\n```ts\n\u002F\u002F side channel — passes even if the read path is broken\ntest('createUser saves to database', async () => {\n  await createUser({ name: 'Alice' });\n  const row = await db.query('SELECT * FROM users WHERE name = ?', ['Alice']);\n  expect(row).toBeDefined();\n});\n\n\u002F\u002F through the interface\ntest('createUser makes user retrievable', async () => {\n  const user = await createUser({ name: 'Alice' });\n  expect((await getUser(user.id)).name).toBe('Alice');\n});\n```\n\n**It was written in bulk.** A test written before the implementation taught you anything locks in an imagined structure, and the suite drifts insensitive to real changes.\n\n## Referencing\n\nTests live in the repo, not in the per-change directory the rest of the chain writes to. What travels between them is the requirement ID: a test name carries it verbatim, so a failing run names the requirement that broke and [verify-specs](..\u002Fverify-specs\u002FSKILL.md) can take the test name itself as evidence.\n\n```ts\ntest(\"R2 — expired token is rejected\", async () => { … });\n```\n\nOne ID per test where the requirement has one; a test covering behavior no requirement names states the capability alone. IDs are stable ([write-specs](..\u002Fwrite-specs\u002FSKILL.md)), so a name written today keeps pointing at the same requirement.\n\nOnce the loop exits, the landed change goes to [verify-specs](..\u002Fverify-specs\u002FSKILL.md): a green suite proves the tests you wrote pass, not that every requirement arrived.\n","# Test-Driven Development\n\nTest-first buys one thing: a test you have watched **red**.\n\nWhere a spec exists it supplies the test list — [write-specs](..\u002Fwrite-specs\u002FSKILL.md) names the single observation that falsifies each requirement, and that observation is the test you write. Inside a plan, this loop is how a step that adds behavior gets worked ([run-plan](..\u002Frun-plan\u002FSKILL.md)).\n\n## Steps\n\n### 1. Name the seams\n\nA **seam** is a public boundary you can observe behavior through without reaching inside: an exported function, an HTTP route, a module's public API, a CLI. A test earns its place when it can fail at the seam for a reason a caller would care about — if the only way to break it is to rename a private helper, it tests structure, not behavior.\n\nWrite down the seams under test before any test exists, and confirm them. Where the surface is wide, fan out [research](..\u002Fresearch\u002FSKILL.md) to find the callers and the conventions the tests must match.\n\n**Done when** the seam list is written and confirmed against its callers, and every requirement ID in scope maps to a seam on it — every test written sits at a confirmed seam.\n\n### 2. Red\n\nWrite one failing test at one seam. Before running it, write down the failure you expect: which assertion fails, and the actual value it will report. Then run it. A test that errors on a missing import, a typo, or a file that does not exist yet is not **red**, it is broken.\n\nCode that already exists — a coverage gap, a module that never had tests — passes a new test on its first run, so the red comes from the code: break the line the test claims to cover (invert the condition, return a constant), run, and watch it go red for the predicted reason. A test that stays green under the break does not cover that line; rewrite it. A test red before any break, its expected value sourced from outside the code, has found a defect: hand it to [diagnose](..\u002Fdiagnose\u002FSKILL.md).\n\n**Done when** the test is **red** and its failure matches the prediction written before the run. A different failure is not done: find out why, predict again, rerun.\n\n### 3. Green\n\nWrite the least code that turns that one test **green** — only the branch the current test exercises.\n\nWhere step 2 broke existing code for its red, green is undoing the break: `git diff` on the code under test comes back empty.\n\n**Done when** the new test has been **red** at least once and now passes, every existing test still does, and the new test satisfies every rule in [Writing the test](#writing-the-test): one act, value asserted rather than shape, expected value sourced from outside the code, name carrying the requirement ID where one exists and the capability alone otherwise.\n\nRepeat 2–3 until every requirement ID in scope carries its own test that has been red at least once; with no spec, each behavior the plan step or the repro names counts as one requirement. Each pass is a **vertical slice**, and the test you write next is shaped by what the last slice taught you — a test written ahead of that, in bulk, was never red for a predicted reason.\n\n**Land the slice, then refactor.** Restructuring while chasing green makes a design problem and a broken test indistinguishable; refactor against a green suite as its own pass with [refactor](..\u002Frefactor\u002FSKILL.md), which hands the new structure to [qc](..\u002Fqc\u002FSKILL.md).\n\n## Writing the test\n\n**Name it after the capability, and carry the requirement ID where one exists.** `R2 — expired token is rejected` tells you what the system does and which requirement it answers; `checkout calls paymentService.process` describes plumbing a refactor is free to change.\n\n**One act per test** — a single call to the seam, so a failure names one behavior. Setup before it, assertions after. Two acts in one test means two tests.\n\n**Assert the value, not the shape.** `toBe(\"confirmed\")` fails loudly the day the status changes; `toBeTruthy()` and `not.toBeNull()` keep passing for the wrong reasons. Several `expect`s describing one outcome are still one assertion; two unrelated outcomes are two tests.\n\n**Expected values come from outside the code** — a known-good literal, a worked example, the requirement's `Then` clause. A value recomputed the way the implementation computes it is a **tautology**.\n\n```ts\n\u002F\u002F tautological — the expectation reimplements the function\ntest('calculateTotal sums line items', () => {\n  const items = [{ price: 10 }, { price: 5 }];\n  const expected = items.reduce((sum, i) => sum + i.price, 0);\n  expect(calculateTotal(items)).toBe(expected);\n});\n\n\u002F\u002F independent — 15 was worked out by hand\ntest('calculateTotal sums line items', () => {\n  expect(calculateTotal([{ price: 10 }, { price: 5 }])).toBe(15);\n});\n```\n\n## Boundaries\n\nEverything you own runs for real: your own modules, internal collaborators, the dependencies of the code under test. Mock only where a slice's seam crosses a **system boundary** — what you do not own and cannot make deterministic:\n\n- External APIs: payments, email, third-party HTTP\n- Time and randomness\n- The file system — prefer a real temp directory; mock only where the test must assert on a path the OS will not give you\n- The database — prefer a real test database\n\n**Inject boundary dependencies rather than constructing them.**\n\n```ts\n\u002F\u002F injected — the test hands in its own client\nfunction processPayment(order, paymentClient) {\n  return paymentClient.charge(order.total);\n}\n\n\u002F\u002F constructed — the boundary is welded shut\nfunction processPayment(order) {\n  const client = new StripeClient(process.env.STRIPE_KEY);\n  return client.charge(order.total);\n}\n```\n\n**Give a boundary one function per operation.** An SDK-shaped object lets each mock return one fixed shape, types each response separately, and shows at a glance which endpoints a test exercises. A single generic fetcher pushes an `if` chain over endpoints into every mock.\n\n```ts\n\u002F\u002F SDK-shaped — each operation mocks independently\nconst api = {\n  getUser: (id) => fetch(`\u002Fusers\u002F${id}`),\n  getOrders: (userId) => fetch(`\u002Fusers\u002F${userId}\u002Forders`),\n  createOrder: (data) => fetch('\u002Forders', { method: 'POST', body: data }),\n};\n```\n\n## Test smells\n\nTells that a test already written is bound to implementation rather than behavior.\n\n**It breaks under refactoring while behavior held still.** The test reached inside — mocked an internal collaborator, called a private method, or asserted on call counts and ordering. Assert on what the **seam** returns or does.\n\n**It verifies through a side channel.** Reaching past the interface to a database row, a log line, or a private field couples the test to storage instead of behavior. Verify through the interface a caller would use.\n\n```ts\n\u002F\u002F side channel — passes even if the read path is broken\ntest('createUser saves to database', async () => {\n  await createUser({ name: 'Alice' });\n  const row = await db.query('SELECT * FROM users WHERE name = ?', ['Alice']);\n  expect(row).toBeDefined();\n});\n\n\u002F\u002F through the interface\ntest('createUser makes user retrievable', async () => {\n  const user = await createUser({ name: 'Alice' });\n  expect((await getUser(user.id)).name).toBe('Alice');\n});\n```\n\n**It was written in bulk.** A test written before the implementation taught you anything locks in an imagined structure, and the suite drifts insensitive to real changes.\n\n## Referencing\n\nTests live in the repo, not in the per-change directory the rest of the chain writes to. What travels between them is the requirement ID: a test name carries it verbatim, so a failing run names the requirement that broke and [verify-specs](..\u002Fverify-specs\u002FSKILL.md) can take the test name itself as evidence.\n\n```ts\ntest(\"R2 — expired token is rejected\", async () => { … });\n```\n\nOne ID per test where the requirement has one; a test covering behavior no requirement names states the capability alone. IDs are stable ([write-specs](..\u002Fwrite-specs\u002FSKILL.md)), so a name written today keeps pointing at the same requirement.\n\nOnce the loop exits, the landed change goes to [verify-specs](..\u002Fverify-specs\u002FSKILL.md): a green suite proves the tests you wrote pass, not that every requirement arrived.\n",{"name":5,"description":7},"main","534498267dccbe415f22f31fceac9da6771c195f","plugins\u002Fworkbench\u002Fskills\u002Ftdd","https:\u002F\u002Fgithub.com\u002Fj0hanz\u002Fj0hanz-marketplace","https:\u002F\u002Fj0hanz-marketplace.vercel.app","https:\u002F\u002Fgithub.com\u002Fj0hanz","linus-johansson-cv-d308be9b73e1.herokuapp.com","2026-11-15 02:42:07",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add j0hanz\u002Fj0hanz-marketplace --skill tdd",{"tool":38,"command":39},"bunx","bunx skills add j0hanz\u002Fj0hanz-marketplace --skill tdd",{"tool":41,"command":42},"pnpm","pnpm dlx skills add j0hanz\u002Fj0hanz-marketplace --skill tdd","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fj0hanz\u002Fj0hanz-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fworkbench\u002Fskills\u002Ftdd\u002FSKILL.md",true,[],[47,54,61,68,75,82],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":19},"01M7ABP78JFYBMCXJ9GMETCYZM","unslop","Use when writing or editing prose a person will read, or when text sounds AI-generated.","https:\u002F\u002Fgithub.com\u002Fj0hanz\u002Fj0hanz-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fwriteup\u002Fskills\u002Funslop\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M7ABP52BNV7NRPNBR6PCNZWC","show-me","Use when asked to show, diagram, or walk through how code fits together or what a change does, or before explaining a multi-file flow in prose.","https:\u002F\u002Fgithub.com\u002Fj0hanz\u002Fj0hanz-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fwriteup\u002Fskills\u002Fshow-me\u002FSKILL.md",[],[],{"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},"01M7ABP3EPN4KFB4HPJNMY31NR","pr","Use when writing or updating a pull request description, or before running `gh pr create`.","https:\u002F\u002Fgithub.com\u002Fj0hanz\u002Fj0hanz-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fwriteup\u002Fskills\u002Fpr\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},"01M7ABP08MXTHPZYTG4HKEP7WQ","commit","Use when writing a commit message, or before running `git commit`.","https:\u002F\u002Fgithub.com\u002Fj0hanz\u002Fj0hanz-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fwriteup\u002Fskills\u002Fcommit\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},"01M7ABNV9J7DN1AFRBGDBHVBY2","write-specs","Spec a feature's observable behavior. Use when asked for requirements, when a request says what the system should do but not how, or to capture what a built system already guarantees. Not for how to build it (write-plan).","https:\u002F\u002Fgithub.com\u002Fj0hanz\u002Fj0hanz-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fworkbench\u002Fskills\u002Fwrite-specs\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},"01M7ABNPK2GVG8EB3SSEAMK4FZ","write-skills","Write, fix, or audit a skill's frontmatter, trigger description, and body. Use when a skill is asked for, never fires, or fires at the wrong moment. Not for a hook (write-hooks) or the plugin manifest and catalog.","https:\u002F\u002Fgithub.com\u002Fj0hanz\u002Fj0hanz-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fworkbench\u002Fskills\u002Fwrite-skills\u002FSKILL.md",[],[]]