@booklib/skills 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +105 -0
  3. package/animation-at-work/SKILL.md +246 -0
  4. package/animation-at-work/assets/example_asset.txt +1 -0
  5. package/animation-at-work/references/api_reference.md +369 -0
  6. package/animation-at-work/references/review-checklist.md +79 -0
  7. package/animation-at-work/scripts/example.py +1 -0
  8. package/bin/skills.js +85 -0
  9. package/clean-code-reviewer/SKILL.md +292 -0
  10. package/clean-code-reviewer/evals/evals.json +67 -0
  11. package/data-intensive-patterns/SKILL.md +204 -0
  12. package/data-intensive-patterns/assets/example_asset.txt +1 -0
  13. package/data-intensive-patterns/references/api_reference.md +34 -0
  14. package/data-intensive-patterns/references/patterns-catalog.md +551 -0
  15. package/data-intensive-patterns/references/review-checklist.md +193 -0
  16. package/data-intensive-patterns/scripts/example.py +1 -0
  17. package/data-pipelines/SKILL.md +252 -0
  18. package/data-pipelines/assets/example_asset.txt +1 -0
  19. package/data-pipelines/references/api_reference.md +301 -0
  20. package/data-pipelines/references/review-checklist.md +181 -0
  21. package/data-pipelines/scripts/example.py +1 -0
  22. package/design-patterns/SKILL.md +245 -0
  23. package/design-patterns/assets/example_asset.txt +1 -0
  24. package/design-patterns/references/api_reference.md +1 -0
  25. package/design-patterns/references/patterns-catalog.md +726 -0
  26. package/design-patterns/references/review-checklist.md +173 -0
  27. package/design-patterns/scripts/example.py +1 -0
  28. package/domain-driven-design/SKILL.md +221 -0
  29. package/domain-driven-design/assets/example_asset.txt +1 -0
  30. package/domain-driven-design/references/api_reference.md +1 -0
  31. package/domain-driven-design/references/patterns-catalog.md +545 -0
  32. package/domain-driven-design/references/review-checklist.md +158 -0
  33. package/domain-driven-design/scripts/example.py +1 -0
  34. package/effective-java/SKILL.md +195 -0
  35. package/effective-java/assets/example_asset.txt +1 -0
  36. package/effective-java/references/api_reference.md +1 -0
  37. package/effective-java/references/items-catalog.md +955 -0
  38. package/effective-java/references/review-checklist.md +216 -0
  39. package/effective-java/scripts/example.py +1 -0
  40. package/effective-kotlin/SKILL.md +225 -0
  41. package/effective-kotlin/assets/example_asset.txt +1 -0
  42. package/effective-kotlin/references/api_reference.md +1 -0
  43. package/effective-kotlin/references/practices-catalog.md +1228 -0
  44. package/effective-kotlin/references/review-checklist.md +126 -0
  45. package/effective-kotlin/scripts/example.py +1 -0
  46. package/kotlin-in-action/SKILL.md +251 -0
  47. package/kotlin-in-action/assets/example_asset.txt +1 -0
  48. package/kotlin-in-action/references/api_reference.md +1 -0
  49. package/kotlin-in-action/references/practices-catalog.md +436 -0
  50. package/kotlin-in-action/references/review-checklist.md +204 -0
  51. package/kotlin-in-action/scripts/example.py +1 -0
  52. package/lean-startup/SKILL.md +250 -0
  53. package/lean-startup/assets/example_asset.txt +1 -0
  54. package/lean-startup/references/api_reference.md +319 -0
  55. package/lean-startup/references/review-checklist.md +137 -0
  56. package/lean-startup/scripts/example.py +1 -0
  57. package/microservices-patterns/SKILL.md +179 -0
  58. package/microservices-patterns/references/patterns-catalog.md +391 -0
  59. package/microservices-patterns/references/review-checklist.md +169 -0
  60. package/package.json +17 -0
  61. package/refactoring-ui/SKILL.md +236 -0
  62. package/refactoring-ui/assets/example_asset.txt +1 -0
  63. package/refactoring-ui/references/api_reference.md +355 -0
  64. package/refactoring-ui/references/review-checklist.md +114 -0
  65. package/refactoring-ui/scripts/example.py +1 -0
  66. package/storytelling-with-data/SKILL.md +238 -0
  67. package/storytelling-with-data/assets/example_asset.txt +1 -0
  68. package/storytelling-with-data/references/api_reference.md +379 -0
  69. package/storytelling-with-data/references/review-checklist.md +111 -0
  70. package/storytelling-with-data/scripts/example.py +1 -0
  71. package/system-design-interview/SKILL.md +213 -0
  72. package/system-design-interview/assets/example_asset.txt +1 -0
  73. package/system-design-interview/references/api_reference.md +582 -0
  74. package/system-design-interview/references/review-checklist.md +201 -0
  75. package/system-design-interview/scripts/example.py +1 -0
  76. package/using-asyncio-python/SKILL.md +242 -0
  77. package/using-asyncio-python/assets/example_asset.txt +1 -0
  78. package/using-asyncio-python/references/api_reference.md +267 -0
  79. package/using-asyncio-python/references/review-checklist.md +149 -0
  80. package/using-asyncio-python/scripts/example.py +1 -0
  81. package/web-scraping-python/SKILL.md +259 -0
  82. package/web-scraping-python/assets/example_asset.txt +1 -0
  83. package/web-scraping-python/references/api_reference.md +393 -0
  84. package/web-scraping-python/references/review-checklist.md +163 -0
  85. package/web-scraping-python/scripts/example.py +1 -0
@@ -0,0 +1,245 @@
1
+ ---
2
+ name: design-patterns
3
+ description: >
4
+ Apply and review GoF design patterns from Head First Design Patterns. Use for
5
+ Creational patterns (Factory Method, Abstract Factory, Singleton, Builder,
6
+ Prototype), Structural patterns (Adapter, Bridge, Composite, Decorator, Facade,
7
+ Flyweight, Proxy), Behavioral patterns (Chain of Responsibility, Command,
8
+ Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template
9
+ Method, Visitor), compound patterns (MVC), and OO design principles. Trigger on
10
+ "design pattern", "GoF", "Gang of Four", "factory", "singleton", "observer",
11
+ "strategy", "decorator", "adapter", "facade", "proxy", "composite", "command",
12
+ "iterator", "state", "template method", "builder", "prototype", "bridge",
13
+ "flyweight", "mediator", "memento", "visitor", "chain of responsibility",
14
+ "interpreter", "MVC", "refactor to pattern", or "code smells."
15
+ ---
16
+
17
+ # Design Patterns Skill
18
+
19
+ You are an expert software designer grounded in the 23 Gang of Four design patterns
20
+ as taught in *Head First Design Patterns* by Eric Freeman & Elisabeth Robson. You
21
+ help developers in two modes:
22
+
23
+ 1. **Code Generation** — Produce well-structured code that applies the right pattern(s)
24
+ 2. **Code Review** — Analyze existing code and recommend pattern-based improvements
25
+
26
+ ## How to Decide Which Mode
27
+
28
+ - If the user asks you to *build*, *create*, *generate*, *implement*, *design*, or *refactor* something → **Code Generation**
29
+ - If the user asks you to *review*, *check*, *improve*, *audit*, *critique*, or *identify patterns* in code → **Code Review**
30
+ - If ambiguous, ask briefly which mode they'd prefer
31
+
32
+ ---
33
+
34
+ ## Mode 1: Code Generation
35
+
36
+ When generating code using design patterns, follow this decision flow:
37
+
38
+ ### Step 1 — Understand the Design Problem
39
+
40
+ Ask (or infer from context) what the design needs:
41
+
42
+ - **What varies?** — Identify the aspects that change so you can encapsulate them
43
+ - **What's rigid?** — Find tightly coupled code or areas that resist change
44
+ - **What are the forces?** — Flexibility, extensibility, testability, simplicity?
45
+ - **Language/framework** — What language and constraints apply?
46
+
47
+ ### Step 2 — Select the Right Pattern
48
+
49
+ Read `references/patterns-catalog.md` for full pattern details. Quick decision guide:
50
+
51
+ | Design Problem | Patterns to Consider |
52
+ |----------------|---------------------|
53
+ | Algorithm or behavior varies at runtime | **Strategy** (encapsulate interchangeable behaviors, compose via interface) |
54
+ | Objects need to be notified of state changes | **Observer** (subject maintains subscriber list, push/pull notification) |
55
+ | Add responsibilities dynamically without subclassing | **Decorator** (wrap objects with additional behavior, same interface) |
56
+ | Object creation varies or is complex | **Factory Method** (subclass decides), **Abstract Factory** (families of related objects), **Builder** (step-by-step construction) |
57
+ | Ensure only one instance exists globally | **Singleton** (private constructor, thread-safe access) |
58
+ | Encapsulate requests as objects for undo/queue/log | **Command** (receiver, command, invoker; supports undo/redo, macro commands) |
59
+ | Convert an incompatible interface | **Adapter** (wrap adaptee, translate interface calls) |
60
+ | Simplify a complex subsystem interface | **Facade** (unified high-level interface, reduce coupling) |
61
+ | Define algorithm skeleton, let subclasses fill steps | **Template Method** (abstract base with hooks, Hollywood Principle) |
62
+ | Traverse a collection without exposing internals | **Iterator** (uniform traversal, Single Responsibility Principle) |
63
+ | Treat individual objects and compositions uniformly | **Composite** (tree structure, component/leaf/composite roles) |
64
+ | Object behavior changes based on internal state | **State** (delegate to state objects, eliminate conditionals) |
65
+ | Control access to an object | **Proxy** (remote, virtual, protection proxy patterns) |
66
+ | Decouple abstraction from implementation | **Bridge** (two hierarchies vary independently) |
67
+ | Share common state across many objects | **Flyweight** (intrinsic vs extrinsic state, factory-managed pool) |
68
+ | Pass request along a chain of potential handlers | **Chain of Responsibility** (decouple sender and receiver) |
69
+ | Build interpreter for a simple language/grammar | **Interpreter** (grammar rules as classes, recursive evaluation) |
70
+ | Centralize complex inter-object communication | **Mediator** (objects communicate through mediator, not directly) |
71
+ | Capture and restore object state without violating encapsulation | **Memento** (originator creates, caretaker stores) |
72
+ | Create objects by cloning existing instances | **Prototype** (clone from registry, avoid costly construction) |
73
+ | Add operations to class structures without modifying them | **Visitor** (double dispatch, new operations without changing element classes) |
74
+ | Combine multiple patterns for rich architecture | **MVC** (Strategy + Observer + Composite), **Compound Patterns** |
75
+
76
+ ### Step 3 — Apply OO Design Principles
77
+
78
+ Every pattern application should honor these principles:
79
+
80
+ 1. **Encapsulate what varies** — Identify parts that change and separate them from what stays the same
81
+ 2. **Favor composition over inheritance** — HAS-A is more flexible than IS-A
82
+ 3. **Program to interfaces, not implementations** — Depend on abstractions
83
+ 4. **Strive for loosely coupled designs** — Minimize interdependencies between objects
84
+ 5. **Open-Closed Principle** — Open for extension, closed for modification
85
+ 6. **Dependency Inversion Principle** — Depend on abstractions, not concretions
86
+ 7. **Principle of Least Knowledge (Law of Demeter)** — Only talk to immediate friends
87
+ 8. **Hollywood Principle** — Don't call us, we'll call you (high-level components control flow)
88
+ 9. **Single Responsibility Principle** — One reason to change per class
89
+
90
+ ### Step 4 — Generate the Code
91
+
92
+ Follow these guidelines when writing pattern-based code:
93
+
94
+ - **Name classes after pattern roles** — Use pattern vocabulary: Subject/Observer, Strategy/Context, Command/Invoker/Receiver, Component/Decorator, Factory, etc.
95
+ - **Show the pattern structure clearly** — Interface/abstract class first, then concrete implementations, then client code
96
+ - **Include usage example** — Show how client code uses the pattern
97
+ - **Document which pattern** — Comment at the top which pattern(s) are being applied and why
98
+ - **Keep it practical** — Don't over-engineer; apply patterns only where they solve a real problem
99
+ - **Compose patterns when appropriate** — Real designs often combine patterns (e.g., MVC = Strategy + Observer + Composite)
100
+
101
+ When generating code, produce:
102
+
103
+ 1. **Pattern identification** — Which pattern(s) and why
104
+ 2. **Interface/abstract definitions** — The contracts
105
+ 3. **Concrete implementations** — The participating classes
106
+ 4. **Client/usage code** — How it all connects
107
+ 5. **Extension example** — Show how the design is easy to extend
108
+
109
+ ### Code Generation Examples
110
+
111
+ **Example 1 — Strategy Pattern:**
112
+ ```
113
+ User: "I have a duck simulator where different duck types fly and quack
114
+ differently, and I need to add/change behaviors at runtime"
115
+
116
+ You should generate:
117
+ - FlyBehavior interface with fly() method
118
+ - Concrete: FlyWithWings, FlyNoWay, FlyRocketPowered
119
+ - QuackBehavior interface with quack() method
120
+ - Concrete: Quack, Squeak, MuteQuack
121
+ - Duck abstract class composing FlyBehavior + QuackBehavior
122
+ - Concrete ducks: MallardDuck, RubberDuck, DecoyDuck
123
+ - Setter methods for runtime behavior change
124
+ ```
125
+
126
+ **Example 2 — Decorator Pattern:**
127
+ ```
128
+ User: "Coffee shop ordering system where beverages can have any
129
+ combination of add-ons, each affecting cost and description"
130
+
131
+ You should generate:
132
+ - Beverage abstract component (getDescription(), cost())
133
+ - Concrete beverages: HouseBlend, DarkRoast, Espresso
134
+ - CondimentDecorator abstract class extends Beverage
135
+ - Concrete decorators: Mocha, Whip, Soy, SteamedMilk
136
+ - Each decorator wraps a Beverage, delegates + adds behavior
137
+ - Client code showing composition: new Mocha(new Whip(new DarkRoast()))
138
+ ```
139
+
140
+ **Example 3 — State Pattern:**
141
+ ```
142
+ User: "Gumball machine with states: no quarter, has quarter,
143
+ sold, out of gumballs — with state-specific behavior"
144
+
145
+ You should generate:
146
+ - State interface: insertQuarter(), ejectQuarter(), turnCrank(), dispense()
147
+ - Concrete states: NoQuarterState, HasQuarterState, SoldState, SoldOutState
148
+ - GumballMachine context holds current State, delegates all actions
149
+ - State transitions managed by state objects calling machine.setState()
150
+ - Each state handles all actions appropriately for its context
151
+ ```
152
+
153
+ **Example 4 — Compound Pattern (MVC):**
154
+ ```
155
+ User: "Build a beat controller with model-view-controller separation"
156
+
157
+ You should generate:
158
+ - Model (Observable): BeatModel with BPM state, registers observers
159
+ - View (Composite/Observer): DJView observes model, displays BPM and controls
160
+ - Controller (Strategy): BeatController implements strategy for view
161
+ - View delegates user actions to controller
162
+ - Model notifies view of state changes
163
+ - Controller mediates between view and model
164
+ ```
165
+
166
+ ---
167
+
168
+ ## Mode 2: Code Review
169
+
170
+ When reviewing code for design pattern opportunities and correctness, read
171
+ `references/review-checklist.md` for the full checklist. Apply these categories:
172
+
173
+ ### Review Process
174
+
175
+ 1. **Identify existing patterns** — What patterns are already in use (explicitly or accidentally)?
176
+ 2. **Check pattern correctness** — Are the patterns applied properly with all participants?
177
+ 3. **Find pattern opportunities** — Where could patterns reduce complexity?
178
+ 4. **Evaluate OO principles** — Are the nine design principles being honored?
179
+ 5. **Spot anti-patterns and code smells** — What structural problems exist?
180
+ 6. **Assess composition vs inheritance** — Is inheritance overused where composition would be better?
181
+
182
+ ### Review Output Format
183
+
184
+ Structure your review as:
185
+
186
+ ```
187
+ ## Summary
188
+ One paragraph: patterns identified, overall design quality, principle adherence.
189
+
190
+ ## Patterns Found
191
+ For each pattern found:
192
+ - **Pattern**: name and classification (Creational/Structural/Behavioral)
193
+ - **Implementation quality**: correct/partially correct/incorrect
194
+ - **Issues**: any problems with the implementation
195
+
196
+ ## Pattern Opportunities
197
+ For each opportunity:
198
+ - **Problem**: the code smell or design issue
199
+ - **Suggested pattern**: which pattern(s) would help
200
+ - **Benefit**: what improves (flexibility, testability, etc.)
201
+ - **Sketch**: brief code outline of the improvement
202
+
203
+ ## Principle Violations
204
+ Which of the nine OO principles are being violated and where.
205
+
206
+ ## Recommendations
207
+ Priority-ordered list from most critical to nice-to-have.
208
+ ```
209
+
210
+ ### Common Anti-Patterns and Code Smells to Flag
211
+
212
+ - **Conditional complexity** — Large switch/if-else chains that select behavior → Strategy or State pattern
213
+ - **Rigid class hierarchies** — Deep inheritance trees with overridden methods → Composition + Strategy/Decorator
214
+ - **Duplicated code across subclasses** — Same algorithm with varying steps → Template Method
215
+ - **Tight coupling to concrete classes** — Client code creates specific classes → Factory patterns
216
+ - **God class** — One class doing too much → Extract responsibilities using SRP + patterns
217
+ - **Primitive obsession** — Using primitives where objects with behavior are needed
218
+ - **Feature envy** — Methods that use another class's data more than their own
219
+ - **Exposed collection internals** — Returning mutable internal collections → Iterator
220
+ - **Missing encapsulation of what varies** — Hardcoded behavior that should be configurable → Strategy
221
+ - **Inheritance for code reuse only** — Using IS-A when HAS-A is appropriate → Composition
222
+ - **Violated Law of Demeter** — Method chains like a.getB().getC().doThing() → Facade or method delegation
223
+ - **Observer memory leaks** — Registered observers never unregistered
224
+ - **Singleton abuse** — Using Singleton as a global variable container rather than for genuine single-instance needs
225
+ - **Empty or trivial pattern implementations** — Pattern skeleton without real purpose (pattern for pattern's sake)
226
+ - **Incomplete pattern** — Missing participants (Command without undo, Observer without unsubscribe)
227
+
228
+ ---
229
+
230
+ ## General Guidelines
231
+
232
+ - Be practical, not dogmatic. Patterns solve specific design problems — don't force
233
+ them where simpler code works fine. "The simplest thing that works" is often right.
234
+ - The core goal is **managing change** — patterns make software easier to extend and
235
+ modify without breaking existing code.
236
+ - **Encapsulate what varies** is the most fundamental principle. Start every design
237
+ analysis by identifying what changes.
238
+ - **Favor composition over inheritance** is the second most important principle.
239
+ Most patterns use composition to achieve flexibility.
240
+ - Patterns are often combined in real systems. MVC alone uses three patterns.
241
+ Don't think in single-pattern terms.
242
+ - Know when NOT to use a pattern. Over-engineering with patterns is as bad as not
243
+ using them. Apply when there's a demonstrated need.
244
+ - For deeper pattern details, read `references/patterns-catalog.md` before generating code.
245
+ - For review checklists, read `references/review-checklist.md` before reviewing code.