[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D01VN92RJM8SASFBT0VPTH":3,"skill-same:01M7D01VN92RJM8SASFBT0VPTH":44},{"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":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7D01VN92RJM8SASFBT0VPTH","domain-and-types",null,"Encode the domain in a structure instead of scattered conditionals, redesign around a new requirement instead of bolting it on, and let the type checker rule out impossible states: state machines, discriminated unions, branded primitives, parsing at the boundary, exhaustive matching. Use when writing stateful logic or a branch that grows by one more case, when a new requirement meets an existing design, and when designing a type or a function signature in any typed language.","fern-works\u002Fgreenline","fern-works","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F330252531?v=4","01M7CZ6VNSYC4MB0XZS6BWJRX3","fernworks","01M7CZ6VPZYZWBPRG404SRBNA9",0,"MIT","https:\u002F\u002Fgithub.com\u002Ffern-works\u002Fgreenline\u002Fblob\u002Fmain\u002Ftest\u002Fgoldens\u002Fcorpus\u002Fdot-claude\u002Fskills\u002Fdomain-and-types\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: \"domain-and-types\"\ndescription: \"Encode the domain in a structure instead of scattered conditionals, redesign around a new requirement instead of bolting it on, and let the type checker rule out impossible states: state machines, discriminated unions, branded primitives, parsing at the boundary, exhaustive matching. Use when writing stateful logic or a branch that grows by one more case, when a new requirement meets an existing design, and when designing a type or a function signature in any typed language.\"\n---\n\n# Domain and types\n\ndomain-and-types is the habit for the moment stateful logic is written, a branch grows by one more case, a new requirement meets an existing design, or a type or a function signature is designed, at whatever step the work is in, most often build. It writes no record of its own. Where data enters from outside, boundaries says where it is parsed and validated.\n\nEncode the real domain in a data structure instead of scattering it across conditionals.\n\n**Why:** Scattered booleans, repeated shape assumptions, and branching spread across files are accidental complexity. A structure that matches the domain makes invalid states unrepresentable and deletes branches. Choosing it at write time is cheap. Recovering it later reads as a refactor and gets deferred.\n\n**Reach for structures like these:**\n\n- A state machine instead of scattered booleans, phases, or lifecycle checks.\n- A typed object\u002Fmodel instead of loose parameters or repeated shape assumptions.\n- A map, registry, lookup table, or discriminated union instead of branching spread across files.\n- A reducer or command\u002Fevent model instead of ad hoc state mutations.\n- A module organized around one body of domain knowledge instead of a sequence such as load, validate, transform, and save. Execution order is not ownership.\n- A small module boundary that gathers repeated behavior, ownership, or invariants.\n- A queue, cache, index, graph\u002Ftree, or normalized collection where the data access pattern calls for it.\n- Any other structure that fits. When none fits, work out what the code must never allow and how the data gets read, then find the structure that encodes exactly that.\n\nDo not force an abstraction. Prefer boring code if the current shape is already clear, local, and unlikely to grow. Be skeptical of an abstraction that adds indirection without removing branches, duplicated rules, invalid states, or lifecycle risk.\n\nThe sign that you skipped this is a new feature that grows an existing if\u002Felse chain by one more branch, or a second boolean that must stay in sync with the first. Temporal decomposition is another sign. Phase-named modules repeat the same domain rules across steps.\n\n## Redesign from first principles\n\nWhen integrating a change, don't bolt it onto the existing design. Redesign as if the requirement had been there from the start.\n\n- Read all affected files and understand the current design\n- Ask: \"if we were writing this from scratch with this new requirement, what would we build?\"\n- Propagate the change through every reference: types, docs, examples, rationale sections\n- Think about the whole redesign, then deliver it incrementally\n\nThis is the method for preserving option value when integrating changes into an existing design.\n\nThe redesign applies where the requirement changes the shape. Where the current shape is already clear, local and unlikely to grow, the boring code above stands.\n\n## Types\n\nThe type checker is a proof assistant. Use it to eliminate impossible states, mismatched primitives, and unhandled variants at compile time. A case the types let you ignore becomes a runtime failure the compiler could have stopped. Prefer defining errors and special cases out of existence over proliferating handlers. Unrepresentable states, total functions, and interface redesign (the patterns below) are the tools.\n\n**The patterns:**\n\n- **Make illegal states unrepresentable.** Model variants as sum types: discriminated unions in TypeScript, enums with payloads in Rust\u002FSwift\u002FKotlin, sealed classes in Scala, ADTs in Haskell\u002FOCaml. Don't model state as a bag of optional fields where contradictory combinations compile. A subtle anti-pattern: `{ completed: boolean; completedAt?: Date }` admits `completed: true; completedAt: undefined`, which is meaningless. Derive the boolean from a single source like `completedAt !== null`, or model the variants explicitly as `{ kind: 'open' } | { kind: 'done'; at: Date }`. If a bug forces the question \"wait, can this combination actually happen?\", the type is too loose.\n- **Types are constructions, not restrictions.** Build the type up from the values you want instead of carving them out of a looser type with checks. The invariant that seems to need a refinement type is usually a construction away. A non-empty list is a head plus a rest, not a list with a length check. A valid time range is a start plus a duration, not two timestamps you must keep ordered. No representation is privileged. A list of pairs is an even-length list if you interpret it that way, so choose the shape that cannot build the illegal value and expose the interface callers need on top.\n- **Brand semantic primitives.** `UserId` and `OrderId` are strings underneath but should not be interchangeable. Newtypes in Rust, opaque types in Swift, value classes in Kotlin, phantom types in Haskell, branded intersections in TypeScript. Validate once at creation, trust the type downstream.\n- **External data is untyped until parsed.** RPC payloads, JSON, IPC messages, CLI args, config files, environment variables, database rows. Have a parse function at every boundary that turns unstructured input into the typed model. See the **boundaries** habit for where to put validation.\n- **Don't lie to the type system.** Casts, unsafe coercions, and assertion functions that bypass the compiler are latent runtime crashes. If the compiler can't prove a fact, prove it (validate, narrow, refine the model) or accept that the cast is a hazard.\n- **Exhaustive matching is the compiler's job.** When you match on a sum type, the compiler must fail compilation if a new variant is added without handling. Use the idiom your language provides: `never`-typed binding in TypeScript, unannotated `match` in Rust, `-Wincomplete-patterns` in Haskell, sealed-class match exhaustiveness in Kotlin.\n- **Derive types from authoritative schemas.** When a protocol buffer, OpenAPI spec, GraphQL schema, database migration, or design-system token file defines a shape, derive from it instead of hand-rolling a parallel type.\n- **Strengthen a type only where partiality appears.** A runtime assertion, null check, or \"this should never happen\" throw marks the place a type is too weak. Push that check up into the type. Then stop. The type system's job is to track the cases each use site must handle, not to describe the data as precisely as possible. Prefer total functions. `sum` of an empty list is 0, so it takes the plain list. `head` of an empty list has no answer, so it demands the non-empty one.\n\n**The tests:**\n\n- \"Can I write a comment explaining when this combination of fields is valid?\" If yes, the type is too loose. Split it into a sum type.\n- \"Do two of my function arguments share a primitive type but mean different things?\" Brand them.\n- \"Where did this `any`, this `as`, this `assertNotNull` come from?\" Trace it to the boundary and validate there instead.\n- \"If a new variant is added next month, will the compiler tell the next agent where to add a case?\" If no, the match isn't exhaustive.\n- \"Is this type duplicating a shape another file owns?\" Derive instead.\n- \"Am I strengthening this type to keep an operation total, or just to be more precise?\" If nothing would otherwise panic, keep the plain type.\n","# Domain and types\n\ndomain-and-types is the habit for the moment stateful logic is written, a branch grows by one more case, a new requirement meets an existing design, or a type or a function signature is designed, at whatever step the work is in, most often build. It writes no record of its own. Where data enters from outside, boundaries says where it is parsed and validated.\n\nEncode the real domain in a data structure instead of scattering it across conditionals.\n\n**Why:** Scattered booleans, repeated shape assumptions, and branching spread across files are accidental complexity. A structure that matches the domain makes invalid states unrepresentable and deletes branches. Choosing it at write time is cheap. Recovering it later reads as a refactor and gets deferred.\n\n**Reach for structures like these:**\n\n- A state machine instead of scattered booleans, phases, or lifecycle checks.\n- A typed object\u002Fmodel instead of loose parameters or repeated shape assumptions.\n- A map, registry, lookup table, or discriminated union instead of branching spread across files.\n- A reducer or command\u002Fevent model instead of ad hoc state mutations.\n- A module organized around one body of domain knowledge instead of a sequence such as load, validate, transform, and save. Execution order is not ownership.\n- A small module boundary that gathers repeated behavior, ownership, or invariants.\n- A queue, cache, index, graph\u002Ftree, or normalized collection where the data access pattern calls for it.\n- Any other structure that fits. When none fits, work out what the code must never allow and how the data gets read, then find the structure that encodes exactly that.\n\nDo not force an abstraction. Prefer boring code if the current shape is already clear, local, and unlikely to grow. Be skeptical of an abstraction that adds indirection without removing branches, duplicated rules, invalid states, or lifecycle risk.\n\nThe sign that you skipped this is a new feature that grows an existing if\u002Felse chain by one more branch, or a second boolean that must stay in sync with the first. Temporal decomposition is another sign. Phase-named modules repeat the same domain rules across steps.\n\n## Redesign from first principles\n\nWhen integrating a change, don't bolt it onto the existing design. Redesign as if the requirement had been there from the start.\n\n- Read all affected files and understand the current design\n- Ask: \"if we were writing this from scratch with this new requirement, what would we build?\"\n- Propagate the change through every reference: types, docs, examples, rationale sections\n- Think about the whole redesign, then deliver it incrementally\n\nThis is the method for preserving option value when integrating changes into an existing design.\n\nThe redesign applies where the requirement changes the shape. Where the current shape is already clear, local and unlikely to grow, the boring code above stands.\n\n## Types\n\nThe type checker is a proof assistant. Use it to eliminate impossible states, mismatched primitives, and unhandled variants at compile time. A case the types let you ignore becomes a runtime failure the compiler could have stopped. Prefer defining errors and special cases out of existence over proliferating handlers. Unrepresentable states, total functions, and interface redesign (the patterns below) are the tools.\n\n**The patterns:**\n\n- **Make illegal states unrepresentable.** Model variants as sum types: discriminated unions in TypeScript, enums with payloads in Rust\u002FSwift\u002FKotlin, sealed classes in Scala, ADTs in Haskell\u002FOCaml. Don't model state as a bag of optional fields where contradictory combinations compile. A subtle anti-pattern: `{ completed: boolean; completedAt?: Date }` admits `completed: true; completedAt: undefined`, which is meaningless. Derive the boolean from a single source like `completedAt !== null`, or model the variants explicitly as `{ kind: 'open' } | { kind: 'done'; at: Date }`. If a bug forces the question \"wait, can this combination actually happen?\", the type is too loose.\n- **Types are constructions, not restrictions.** Build the type up from the values you want instead of carving them out of a looser type with checks. The invariant that seems to need a refinement type is usually a construction away. A non-empty list is a head plus a rest, not a list with a length check. A valid time range is a start plus a duration, not two timestamps you must keep ordered. No representation is privileged. A list of pairs is an even-length list if you interpret it that way, so choose the shape that cannot build the illegal value and expose the interface callers need on top.\n- **Brand semantic primitives.** `UserId` and `OrderId` are strings underneath but should not be interchangeable. Newtypes in Rust, opaque types in Swift, value classes in Kotlin, phantom types in Haskell, branded intersections in TypeScript. Validate once at creation, trust the type downstream.\n- **External data is untyped until parsed.** RPC payloads, JSON, IPC messages, CLI args, config files, environment variables, database rows. Have a parse function at every boundary that turns unstructured input into the typed model. See the **boundaries** habit for where to put validation.\n- **Don't lie to the type system.** Casts, unsafe coercions, and assertion functions that bypass the compiler are latent runtime crashes. If the compiler can't prove a fact, prove it (validate, narrow, refine the model) or accept that the cast is a hazard.\n- **Exhaustive matching is the compiler's job.** When you match on a sum type, the compiler must fail compilation if a new variant is added without handling. Use the idiom your language provides: `never`-typed binding in TypeScript, unannotated `match` in Rust, `-Wincomplete-patterns` in Haskell, sealed-class match exhaustiveness in Kotlin.\n- **Derive types from authoritative schemas.** When a protocol buffer, OpenAPI spec, GraphQL schema, database migration, or design-system token file defines a shape, derive from it instead of hand-rolling a parallel type.\n- **Strengthen a type only where partiality appears.** A runtime assertion, null check, or \"this should never happen\" throw marks the place a type is too weak. Push that check up into the type. Then stop. The type system's job is to track the cases each use site must handle, not to describe the data as precisely as possible. Prefer total functions. `sum` of an empty list is 0, so it takes the plain list. `head` of an empty list has no answer, so it demands the non-empty one.\n\n**The tests:**\n\n- \"Can I write a comment explaining when this combination of fields is valid?\" If yes, the type is too loose. Split it into a sum type.\n- \"Do two of my function arguments share a primitive type but mean different things?\" Brand them.\n- \"Where did this `any`, this `as`, this `assertNotNull` come from?\" Trace it to the boundary and validate there instead.\n- \"If a new variant is added next month, will the compiler tell the next agent where to add a case?\" If no, the match isn't exhaustive.\n- \"Is this type duplicating a shape another file owns?\" Derive instead.\n- \"Am I strengthening this type to keep an operation total, or just to be more precise?\" If nothing would otherwise panic, keep the plain type.\n",{"name":5,"description":7},"main","c4a6bc27da835d109348b8708301821838e98db2","test\u002Fgoldens\u002Fcorpus\u002Fdot-claude\u002Fskills\u002Fdomain-and-types","https:\u002F\u002Fgithub.com\u002Ffern-works\u002Fgreenline","https:\u002F\u002Fgithub.com\u002Ffern-works","2026-10-21 15:51:59",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add fern-works\u002Fgreenline --skill domain-and-types",{"tool":36,"command":37},"bunx","bunx skills add fern-works\u002Fgreenline --skill domain-and-types",{"tool":39,"command":40},"pnpm","pnpm dlx skills add fern-works\u002Fgreenline --skill domain-and-types","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Ffern-works\u002Fgreenline\u002Fblob\u002Fmain\u002Ftest\u002Fgoldens\u002Fcorpus\u002Fdot-claude\u002Fskills\u002Fdomain-and-types\u002FSKILL.md",true,[],[45,52,57,64,71,78],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":19},"01M7D04ARSVW93Y1EGVM7HQQR8","use-garden","Consulting garden, the separately installed guidance command this repository's owner enabled, when an open engineering choice the repository does not settle, made in a change or only recommended, would be informed by published guidance. Use for a choice between approaches, a pattern or pitfall for a technology or concern the work touches, or a unit a repository decision names; not for a question about this repository's own facts or a change whose choices are already settled.","https:\u002F\u002Fgithub.com\u002Ffern-works\u002Fgreenline\u002Fblob\u002Fmain\u002Ftest\u002Fgoldens\u002Fgarden-enabled\u002Fdot-claude\u002Fskills\u002Fuse-garden\u002FSKILL.md",[],[],{"skillNo":53,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M7D045RXH0SEYZKHHW2YD0FQ","https:\u002F\u002Fgithub.com\u002Ffern-works\u002Fgreenline\u002Fblob\u002Fmain\u002Ftest\u002Fgoldens\u002Fgarden-enabled\u002Fdot-agents\u002Fskills\u002Fuse-garden\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M7D03ZXQHBP1RASSRHH5DX7S","what-to-build","Propose what this product could do next at three altitudes: sharpen a shipped slice, extend one, or open ground the product does not stand on yet. Use for 'what should we build next', 'any ideas for this app', 'what's missing', 'is this done or is there more in it', and quick-win hunts. Not for refactors, which belong to the architecture survey.","https:\u002F\u002Fgithub.com\u002Ffern-works\u002Fgreenline\u002Fblob\u002Fmain\u002Ftest\u002Fgoldens\u002Fcorpus\u002Fdot-claude\u002Fskills\u002Fwhat-to-build\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7D03WVYR3NN0N0CTN51RWBV","wayfinder","Plan a huge chunk of work (more than one agent session can hold) as a shared map of decision tickets in a plan directory's map.md, and resolve them one at a time until the way to the destination is clear.","https:\u002F\u002Fgithub.com\u002Ffern-works\u002Fgreenline\u002Fblob\u002Fmain\u002Ftest\u002Fgoldens\u002Fcorpus\u002Fdot-claude\u002Fskills\u002Fwayfinder\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7D03R6MAHHKQ42E5NBRHSF6","verify","Prove a change's claims with fresh evidence: restate each item of its acceptance so it can fail, capture a baseline and a treatment with the same command, compare the raw artifacts, and return VERIFIED, NOT VERIFIED or INCONCLUSIVE for each, at the depth the change's mode gives the verify step. Use when the mode reaches verify, or when the owner says \"verify this\", \"prove it works\" or \"did this fix it\".","https:\u002F\u002Fgithub.com\u002Ffern-works\u002Fgreenline\u002Fblob\u002Fmain\u002Ftest\u002Fgoldens\u002Fcorpus\u002Fdot-claude\u002Fskills\u002Fverify\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7D03JYGW4945FSJV6CDE2K9","tdd","Test-first development at any step: discover the repository's own test commands, name the break a test catches, watch it fail for the intended reason, make it pass with the smallest change, and add a new test only where it catches a realistic failure the existing ones would miss. Use when writing or changing a test, building a feature or fixing a bug test-first, or deciding whether a change needs a new test; also on 'red-green-refactor' and integration tests.","https:\u002F\u002Fgithub.com\u002Ffern-works\u002Fgreenline\u002Fblob\u002Fmain\u002Ftest\u002Fgoldens\u002Fcorpus\u002Fdot-claude\u002Fskills\u002Ftdd\u002FSKILL.md",[],[]]