[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DVNGVFPFK5KEAE5KR07RT2":3,"skill-same:01M6DVNGVFPFK5KEAE5KR07RT2":72},{"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":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":6,"ownerHtmlUrl":49,"ownerBlogUrl":50,"ownerDescription":6,"updatedAt":51,"install":52,"resources":65},"01M6DVNGVFPFK5KEAE5KR07RT2","oop-principles",null,"ACTIVATE when designing classes, and the value objects or collections modelled as classes, or when the user asks about object design, encapsulation, or 'Tell Don't Ask' across languages. Covers cross-language OOP principles: Tell Don't Ask, collection over named properties, Whole Object pattern, iterable collections, self-describing value objects. Language-specific examples and constructs (IteratorAggregate, Symbol.iterator, branded types) live in companion skills (php-oop, ts-oop). DO NOT use for: a value object or an aggregate modelled as an immutable record with functions over it rather than as a class (see craft:ddd-fp-principles).","FabienSalles\u002Fclaude-marketplace","FabienSalles","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F937901?v=4","01M6DVJBD31CJKRB382FQFZ5FH","Fabien Salles","01M6DVJBQNY8Q18KJD1ESAD6TX",9,"MIT","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fcraft\u002Fskills\u002Foop-principles\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"oop principles","oop","functions","as","collections","across","self","record","objects","do","activate","design","properties","constructs","use","ask","collection","immutable","examples","ddd","2026-11-10 10:12:30",false,"---\nname: oop-principles\ndescription: \"ACTIVATE when designing classes, and the value objects or collections modelled as classes, or when the user asks about object design, encapsulation, or 'Tell Don't Ask' across languages. Covers cross-language OOP principles: Tell Don't Ask, collection over named properties, Whole Object pattern, iterable collections, self-describing value objects. Language-specific examples and constructs (IteratorAggregate, Symbol.iterator, branded types) live in companion skills (php-oop, ts-oop). DO NOT use for: a value object or an aggregate modelled as an immutable record with functions over it rather than as a class (see craft:ddd-fp-principles).\"\n---\n\n# OOP Design — Cross-Language Principles\n\n> The **rules** below are language-agnostic. Concrete syntax-specific examples live in:\n> - `php-oop` (PHP — `IteratorAggregate`, readonly properties)\n> - `ts-oop` (TypeScript — `Symbol.iterator`, branded types)\n\nThese principles focus on patterns where Claude tends to produce \"ask\" code instead of \"tell\" code.\n\n## 1. Tell Don't Ask\n\nThe object that owns the data exposes the behavior. Do **not** extract data to make decisions externally.\n\n**Smell:** caller queries `obj.getX()`, applies a condition, then calls back into the object.\n\n**Fix:** push the condition into the object — expose a method that already encodes the decision (`obj.getMissingX()`, `obj.canDoY()`).\n\n**Criterion:** if the same `if\u002Fmatch` on object state appears in multiple call sites, the object should own it.\n\n## 2. Collection Over Separate Named Properties\n\nWhen elements share the same type and undergo the same processing, use an indexed collection — **even if the count is known and fixed**.\n\n**Smell:** `$frontFile`, `$backFile`, `$passportFile` (or `frontFile`, `backFile`, `passportFile`) with parallel handling code.\n\n**Fix:** a single keyed collection (`Map\u003Cstring, File>`, `array\u003Cstring, File>`) with one loop.\n\n**Criterion:** same nature + same treatment (upload, validation, display) = collection.\n\n## 3. Whole Object — Pass the Object, Not Its Primitives\n\nWhen multiple parameters come from the same object, pass the **object**. Extracting primitives on the caller side is feature envy.\n\n**Smell:** `add(documentType: doc.type, documentName: doc.originalFileName, downloadUrl: url)` — three properties of `doc` destructured.\n\n**Fix:** `addFromDocument(doc, url)` — let the receiver extract what it needs.\n\n**Criterion:** if a call site reads ≥ 2 properties of the same object to pass them along, pass the object.\n\n## 4. Iterable Collections with Private Internals\n\nWhen a collection will be iterated, expose iteration **without** exposing the underlying array. The language provides a protocol for this (PHP: `IteratorAggregate`, TS: `Symbol.iterator`, Python: `__iter__`, …).\n\n**Smell:** public property holding the underlying array, allowing `coll.files.push(...)`.\n\n**Fix:** keep the array private, implement the language's iteration protocol so `for ... of coll` (or equivalent) works.\n\n**Criterion:** if a caller iterates the collection, it must not be able to mutate it directly.\n\n## 5. Self-Describing Value Objects\n\nInclude the type \u002F identity **in** the value object so consumers don't need an external mapping to interpret it.\n\n**Smell:** `{ content, originalFileName }` + a separate `fieldName → fileType` mapping kept by the consumer.\n\n**Fix:** add the `type` (or other discriminator) **inside** the value object — `{ type, content, originalFileName }`.\n\n**Criterion:** if a consumer needs an external lookup to know what kind of value object it received, the type is missing from the object.\n\n## Quick Reference\n\n| Rule | Principle |\n|------|-----------|\n| Tell Don't Ask | The object exposes behavior, not data to interpret |\n| Collection > named properties | Same nature + same processing = indexed collection |\n| Whole Object | Pass the entire object, not its extracted primitives |\n| Iterable + private | Use the language's iteration protocol, keep internals private |\n| Self-describing VO | Include type\u002Fidentity in the object — no external mapping |\n","# OOP Design — Cross-Language Principles\n\n> The **rules** below are language-agnostic. Concrete syntax-specific examples live in:\n> - `php-oop` (PHP — `IteratorAggregate`, readonly properties)\n> - `ts-oop` (TypeScript — `Symbol.iterator`, branded types)\n\nThese principles focus on patterns where Claude tends to produce \"ask\" code instead of \"tell\" code.\n\n## 1. Tell Don't Ask\n\nThe object that owns the data exposes the behavior. Do **not** extract data to make decisions externally.\n\n**Smell:** caller queries `obj.getX()`, applies a condition, then calls back into the object.\n\n**Fix:** push the condition into the object — expose a method that already encodes the decision (`obj.getMissingX()`, `obj.canDoY()`).\n\n**Criterion:** if the same `if\u002Fmatch` on object state appears in multiple call sites, the object should own it.\n\n## 2. Collection Over Separate Named Properties\n\nWhen elements share the same type and undergo the same processing, use an indexed collection — **even if the count is known and fixed**.\n\n**Smell:** `$frontFile`, `$backFile`, `$passportFile` (or `frontFile`, `backFile`, `passportFile`) with parallel handling code.\n\n**Fix:** a single keyed collection (`Map\u003Cstring, File>`, `array\u003Cstring, File>`) with one loop.\n\n**Criterion:** same nature + same treatment (upload, validation, display) = collection.\n\n## 3. Whole Object — Pass the Object, Not Its Primitives\n\nWhen multiple parameters come from the same object, pass the **object**. Extracting primitives on the caller side is feature envy.\n\n**Smell:** `add(documentType: doc.type, documentName: doc.originalFileName, downloadUrl: url)` — three properties of `doc` destructured.\n\n**Fix:** `addFromDocument(doc, url)` — let the receiver extract what it needs.\n\n**Criterion:** if a call site reads ≥ 2 properties of the same object to pass them along, pass the object.\n\n## 4. Iterable Collections with Private Internals\n\nWhen a collection will be iterated, expose iteration **without** exposing the underlying array. The language provides a protocol for this (PHP: `IteratorAggregate`, TS: `Symbol.iterator`, Python: `__iter__`, …).\n\n**Smell:** public property holding the underlying array, allowing `coll.files.push(...)`.\n\n**Fix:** keep the array private, implement the language's iteration protocol so `for ... of coll` (or equivalent) works.\n\n**Criterion:** if a caller iterates the collection, it must not be able to mutate it directly.\n\n## 5. Self-Describing Value Objects\n\nInclude the type \u002F identity **in** the value object so consumers don't need an external mapping to interpret it.\n\n**Smell:** `{ content, originalFileName }` + a separate `fieldName → fileType` mapping kept by the consumer.\n\n**Fix:** add the `type` (or other discriminator) **inside** the value object — `{ type, content, originalFileName }`.\n\n**Criterion:** if a consumer needs an external lookup to know what kind of value object it received, the type is missing from the object.\n\n## Quick Reference\n\n| Rule | Principle |\n|------|-----------|\n| Tell Don't Ask | The object exposes behavior, not data to interpret |\n| Collection > named properties | Same nature + same processing = indexed collection |\n| Whole Object | Pass the entire object, not its extracted primitives |\n| Iterable + private | Use the language's iteration protocol, keep internals private |\n| Self-describing VO | Include type\u002Fidentity in the object — no external mapping |\n",{"name":5,"description":7},"main","479b264ec17cc5fafbf36287a1087472d3a386d3","plugins\u002Fcraft\u002Fskills\u002Foop-principles",2,"https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace","https:\u002F\u002Fgithub.com\u002FFabienSalles","https:\u002F\u002Ffabiensalles.com","2026-10-13 04:33:22",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add FabienSalles\u002Fclaude-marketplace --skill oop-principles",{"tool":58,"command":59},"bunx","bunx skills add FabienSalles\u002Fclaude-marketplace --skill oop-principles",{"tool":61,"command":62},"pnpm","pnpm dlx skills add FabienSalles\u002Fclaude-marketplace --skill oop-principles","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fcraft\u002Fskills\u002Foop-principles\u002FSKILL.md",true,[66],{"path":67,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":70,"sourceHtmlUrl":71},"index.json","REFERENCE","参考文档",689,"https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fmalware-cobaltstrike-malleable\u002Findex.json",[73,97,112,133,152,162],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":39},"01M6DW2YS1MGF65JNS1QQ15QHS","vitest-test-conventions","ACTIVATE when writing Vitest tests, creating test files, using vi.fn()\u002Fvi.mock()\u002Fvi.spyOn(), or test factories. ACTIVATE for 'Vitest', 'it.each', 'NestJS testing module', 'supertest', 'vi.fn', 'vi.mock', 'spyOn'. Provides Vitest\u002FNestJS-specific testing patterns; cross-language testing principles (DAMP, AAA, spy over mock, what NOT to test) live in craft:testing-principles. DO NOT use for: node:test files (a file importing node:test) or a project whose tests run under node --test (see node-test:node-test-conventions), TDD workflow\u002Fiterations (see vitest:vitest-tdd-workflow), PHP\u002FPHPUnit tests (see phpunit:php-test-conventions).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fvitest\u002Fskills\u002Fvitest-test-conventions\u002FSKILL.md",[],[80,81,82,83,84,85,86,87,88,89,33,90,91,29,28,92,93,94,95,96],"test","vitest","conventions","vitest test conventions","testing","writing","tdd","workflow","file","testing patterns","files","nestjs","project","tests","module","fn","testing principles",{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":39},"01M6DW2VFE6NPFCGQKQ68P1MVZ","vitest-tdd-workflow","ACTIVATE when building new features, endpoints, or user stories using TDD with Vitest in a TypeScript\u002FNestJS context. ACTIVATE for '\u002Ffeature-tdd-dev', 'TDD', 'red-green-refactor' in TS context. Provides Vitest\u002FNestJS-specific TDD examples and commands; cross-language TDD workflow (cross-layer iterations, RED-GREEN-REFACTOR, working app, bug-fix-first-test, mocks-hiding-bugs) lives in craft:tdd-workflow-principles. DO NOT use for: node:test files (a file importing node:test) or a project whose tests run under node --test (see node-test:node-test-conventions), test writing conventions (see vitest:vitest-test-conventions), PHP TDD (see phpunit:php-tdd-workflow).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fvitest\u002Fskills\u002Fvitest-tdd-workflow\u002FSKILL.md",[],[86,87,104,81,105,85,106,88,37,107,33,108,90,29,28,109,92,93,110,111],"tdd workflow","vitest tdd workflow","dev","fix","red-green-refactor","green","feature","app",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":39},"01M6DW2RGMQE10D8C5Z5MA2RMY","ts-refactoring","ACTIVATE when refactoring TypeScript code. ACTIVATE for 'refactor', 'extract', 'redesign', 'simplify', or 'clean up' in a TypeScript \u002F Node \u002F NestJS context. This skill provides TS-specific examples for the cross-language refactoring rules defined in craft:refactoring-principles. DO NOT use for: writing new features from scratch, general OOP patterns (see ts-oop).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-refactoring\u002FSKILL.md",[],[119,120,85,121,122,37,123,124,125,126,127,33,128,129,130,91,131,29,28,132],"refactoring","ts refactoring","typescript","code","refactor","simplify","Rules","node","redesign","up","general","clean","craft","patterns",{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":39},"01M6DW2MHYXNBBVYEGB058Y48J","ts-ports-adapters","ACTIVATE when a TypeScript codebase with no dependency-injection container has to declare a port and wire its adapter — a repository, a clock, an id generator, an event dispatcher the domain depends on. ACTIVATE for 'port', 'adapter', 'SPI', 'dependency inversion' or 'composition root' in a codebase that wires its dependencies by hand. Covers: the port as a type of functions in the domain layer, the adapter as an object literal annotated with it, the handler that takes its dependencies first and its data second, the composition root in the infrastructure layer, and the in-memory stub that substitutes for the adapter in a unit test. DO NOT use for: NestJS, or any container-based DI with decorators and tokens (see nest-ddd-conventions), aggregate operations and smart constructors (see ddd-ts-fp), the Result type itself (see ts-functional).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-ports-adapters\u002FSKILL.md",[],[140,141,142,80,38,143,33,144,21,91,145,29,28,146,147,148,22,149,150,151],"ports","ts ports adapters","memory","Composition","container","Literal","dependency-injection","domain","tokens","type","id","adapter",{"skillNo":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":156,"categories":157,"keywords":158,"publishedAt":39},"01M6DW2GRXZFYT05HEDB26C9B8","ts-oop","ACTIVATE when designing TypeScript classes, and the value objects or collections modelled as classes, or when the user asks about object design, encapsulation, Tell Don't Ask, or Symbol.iterator. Provides TS-specific examples for the cross-language OOP rules defined in craft:oop-principles, plus TS-specific patterns (Symbol.iterator, branded types for primitive identifiers). DO NOT use for: a value object or an aggregate modelled as an immutable record rather than a class (see ddd-ts-fp), refactoring methodology (see ts-refactoring).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-oop\u002FSKILL.md",[],[20,159,30,121,38,37,160,36,119,125,34,33,161,131,29,28,27,26,23,22],"ts oop","methodology","refactoring methodology",{"skillNo":163,"name":164,"nameZh":6,"description":165,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":166,"categories":167,"keywords":168,"publishedAt":39},"01M6DW2D26XG5MJMTP9MSE43S2","ts-layer-boundaries","ACTIVATE when wiring a Worker entry point, a Router, a controller, or a domain event consumer in a TypeScript CQRS codebase, or when deciding where a port belongs. ACTIVATE for 'composition root', 'layer boundary', 'ESLint zones', 'domain must not import infrastructure'. Covers: the *Worker.ts composition root, the curried consumer, Router wiring of command endpoints, the five-gesture controller, the domain-to-infrastructure import boundary enforced by ESLint, infrastructure-only ports, in-memory doubles for every port, the read-can-reach-write asymmetry, and read endpoints going through a domain handler. DO NOT use for: the port's own shape and adapter binding (see ts-ports-adapters), the Result type (see ts-functional), domain event structure (see ts-ddd-events).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-layer-boundaries\u002FSKILL.md",[],[169,142,38,170,171,143,140,33,172,173,174,29,28,175,147,176,177,149,151,178],"ts layer boundaries","controller","boundary","router","only","endpoints","structure","cqrs","worker","import"]