@joktec/skills 0.1.3 → 0.1.7

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 (101) hide show
  1. package/README.md +4 -2
  2. package/dist/claude/skills/advanced-typescript-design/SKILL.md +60 -0
  3. package/dist/claude/skills/advanced-typescript-design/agents/openai.yaml +4 -0
  4. package/dist/claude/skills/advanced-typescript-design/references/advanced.md +219 -0
  5. package/dist/claude/skills/advanced-typescript-design/references/simple.md +149 -0
  6. package/dist/claude/skills/joktec-adapter-skill/SKILL.md +1 -0
  7. package/dist/claude/skills/joktec-adapter-skill/references/adapters.md +28 -0
  8. package/dist/claude/skills/joktec-broker-skill/SKILL.md +1 -0
  9. package/dist/claude/skills/joktec-broker-skill/references/brokers.md +29 -0
  10. package/dist/claude/skills/joktec-common-skill/SKILL.md +1 -0
  11. package/dist/claude/skills/joktec-common-skill/references/core.md +56 -0
  12. package/dist/claude/skills/joktec-common-skill/references/utils-cron.md +28 -0
  13. package/dist/claude/skills/joktec-database-extended-skill/SKILL.md +1 -0
  14. package/dist/claude/skills/joktec-database-extended-skill/references/extended-databases.md +24 -0
  15. package/dist/claude/skills/joktec-framework-skill/SKILL.md +1 -0
  16. package/dist/claude/skills/joktec-framework-skill/references/framework-map.md +34 -0
  17. package/dist/claude/skills/joktec-integration-skill/SKILL.md +1 -0
  18. package/dist/claude/skills/joktec-integration-skill/references/integrations.md +29 -0
  19. package/dist/claude/skills/joktec-mongo-skill/SKILL.md +9 -1
  20. package/dist/claude/skills/joktec-mongo-skill/references/repository.md +46 -0
  21. package/dist/claude/skills/joktec-mongo-skill/references/schema-and-plugins.md +65 -0
  22. package/dist/claude/skills/joktec-mysql-skill/SKILL.md +6 -1
  23. package/dist/claude/skills/joktec-mysql-skill/references/entities.md +109 -1
  24. package/dist/claude/skills/joktec-mysql-skill/references/repository.md +63 -0
  25. package/dist/claude/skills/joktec-tool-skill/SKILL.md +1 -0
  26. package/dist/claude/skills/joktec-tool-skill/references/tools.md +36 -0
  27. package/dist/codex/skills/advanced-typescript-design/SKILL.md +60 -0
  28. package/dist/codex/skills/advanced-typescript-design/agents/openai.yaml +4 -0
  29. package/dist/codex/skills/advanced-typescript-design/references/advanced.md +219 -0
  30. package/dist/codex/skills/advanced-typescript-design/references/simple.md +149 -0
  31. package/dist/codex/skills/joktec-adapter-skill/SKILL.md +1 -0
  32. package/dist/codex/skills/joktec-adapter-skill/references/adapters.md +28 -0
  33. package/dist/codex/skills/joktec-broker-skill/SKILL.md +1 -0
  34. package/dist/codex/skills/joktec-broker-skill/references/brokers.md +29 -0
  35. package/dist/codex/skills/joktec-common-skill/SKILL.md +1 -0
  36. package/dist/codex/skills/joktec-common-skill/references/core.md +56 -0
  37. package/dist/codex/skills/joktec-common-skill/references/utils-cron.md +28 -0
  38. package/dist/codex/skills/joktec-database-extended-skill/SKILL.md +1 -0
  39. package/dist/codex/skills/joktec-database-extended-skill/references/extended-databases.md +24 -0
  40. package/dist/codex/skills/joktec-framework-skill/SKILL.md +1 -0
  41. package/dist/codex/skills/joktec-framework-skill/references/framework-map.md +34 -0
  42. package/dist/codex/skills/joktec-integration-skill/SKILL.md +1 -0
  43. package/dist/codex/skills/joktec-integration-skill/references/integrations.md +29 -0
  44. package/dist/codex/skills/joktec-mongo-skill/SKILL.md +9 -1
  45. package/dist/codex/skills/joktec-mongo-skill/references/repository.md +46 -0
  46. package/dist/codex/skills/joktec-mongo-skill/references/schema-and-plugins.md +65 -0
  47. package/dist/codex/skills/joktec-mysql-skill/SKILL.md +6 -1
  48. package/dist/codex/skills/joktec-mysql-skill/references/entities.md +109 -1
  49. package/dist/codex/skills/joktec-mysql-skill/references/repository.md +63 -0
  50. package/dist/codex/skills/joktec-tool-skill/SKILL.md +1 -0
  51. package/dist/codex/skills/joktec-tool-skill/references/tools.md +36 -0
  52. package/dist/copilot/.github/copilot-instructions.md +1003 -3
  53. package/dist/cursor/.cursor/rules/advanced-typescript-design.mdc +437 -0
  54. package/dist/cursor/.cursor/rules/joktec-adapter-skill.mdc +29 -0
  55. package/dist/cursor/.cursor/rules/joktec-broker-skill.mdc +30 -0
  56. package/dist/cursor/.cursor/rules/joktec-common-skill.mdc +85 -0
  57. package/dist/cursor/.cursor/rules/joktec-database-extended-skill.mdc +25 -0
  58. package/dist/cursor/.cursor/rules/joktec-framework-skill.mdc +35 -0
  59. package/dist/cursor/.cursor/rules/joktec-integration-skill.mdc +30 -0
  60. package/dist/cursor/.cursor/rules/joktec-mongo-skill.mdc +120 -1
  61. package/dist/cursor/.cursor/rules/joktec-mysql-skill.mdc +178 -2
  62. package/dist/cursor/.cursor/rules/joktec-tool-skill.mdc +37 -0
  63. package/dist/gemini/GEMINI.md +1005 -3
  64. package/dist/windsurf/.windsurf/rules/advanced-typescript-design.md +433 -0
  65. package/dist/windsurf/.windsurf/rules/joktec-adapter-skill.md +29 -0
  66. package/dist/windsurf/.windsurf/rules/joktec-broker-skill.md +30 -0
  67. package/dist/windsurf/.windsurf/rules/joktec-common-skill.md +85 -0
  68. package/dist/windsurf/.windsurf/rules/joktec-database-extended-skill.md +25 -0
  69. package/dist/windsurf/.windsurf/rules/joktec-framework-skill.md +35 -0
  70. package/dist/windsurf/.windsurf/rules/joktec-integration-skill.md +30 -0
  71. package/dist/windsurf/.windsurf/rules/joktec-mongo-skill.md +120 -1
  72. package/dist/windsurf/.windsurf/rules/joktec-mysql-skill.md +178 -2
  73. package/dist/windsurf/.windsurf/rules/joktec-tool-skill.md +37 -0
  74. package/package.json +6 -3
  75. package/scripts/sync-pack-version.mjs +38 -0
  76. package/skill-pack.json +35 -1
  77. package/skills/advanced-typescript-design/SKILL.md +60 -0
  78. package/skills/advanced-typescript-design/agents/openai.yaml +4 -0
  79. package/skills/advanced-typescript-design/references/advanced.md +219 -0
  80. package/skills/advanced-typescript-design/references/simple.md +149 -0
  81. package/skills/joktec-adapter-skill/SKILL.md +1 -0
  82. package/skills/joktec-adapter-skill/references/adapters.md +28 -0
  83. package/skills/joktec-broker-skill/SKILL.md +1 -0
  84. package/skills/joktec-broker-skill/references/brokers.md +29 -0
  85. package/skills/joktec-common-skill/SKILL.md +1 -0
  86. package/skills/joktec-common-skill/references/core.md +56 -0
  87. package/skills/joktec-common-skill/references/utils-cron.md +28 -0
  88. package/skills/joktec-database-extended-skill/SKILL.md +1 -0
  89. package/skills/joktec-database-extended-skill/references/extended-databases.md +24 -0
  90. package/skills/joktec-framework-skill/SKILL.md +1 -0
  91. package/skills/joktec-framework-skill/references/framework-map.md +34 -0
  92. package/skills/joktec-integration-skill/SKILL.md +1 -0
  93. package/skills/joktec-integration-skill/references/integrations.md +29 -0
  94. package/skills/joktec-mongo-skill/SKILL.md +9 -1
  95. package/skills/joktec-mongo-skill/references/repository.md +46 -0
  96. package/skills/joktec-mongo-skill/references/schema-and-plugins.md +65 -0
  97. package/skills/joktec-mysql-skill/SKILL.md +6 -1
  98. package/skills/joktec-mysql-skill/references/entities.md +109 -1
  99. package/skills/joktec-mysql-skill/references/repository.md +63 -0
  100. package/skills/joktec-tool-skill/SKILL.md +1 -0
  101. package/skills/joktec-tool-skill/references/tools.md +36 -0
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # JokTec Skills
2
2
 
3
3
  ![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)
4
- ![Skills](https://img.shields.io/badge/skills-9-blue.svg)
4
+ ![Skills](https://img.shields.io/badge/skills-10-blue.svg)
5
5
  ![Agents](https://img.shields.io/badge/agents-Codex%20%7C%20Claude%20%7C%20Cursor%20%7C%20Gemini%20%7C%20Copilot%20%7C%20Windsurf-purple.svg)
6
- ![Version](https://img.shields.io/badge/version-0.1.0-lightgrey.svg)
6
+ ![Version](https://img.shields.io/badge/version-0.1.4-lightgrey.svg)
7
7
 
8
8
  Hybrid agent skills for using `@joktec/*` libraries in consumer projects.
9
9
 
@@ -104,6 +104,7 @@ The result is less prompt repetition, better package boundary discipline, and mo
104
104
  | `joktec-database-extended-skill` | `@joktec/elastic`, `@joktec/arango`, `@joktec/bigquery` | You use additional database clients outside Mongo/MySQL. |
105
105
  | `joktec-integration-skill` | `@joktec/firebase`, `@joktec/gpt` | You wire Firebase or GPT/OpenAI-style integrations. |
106
106
  | `joktec-tool-skill` | `@joktec/http`, `@joktec/file`, `@joktec/alert` | You use shared HTTP, file, or alert utility services. |
107
+ | `advanced-typescript-design` | TypeScript, NestJS | You design or refactor framework-style TypeScript APIs, advanced generic types, decorators, lifecycle abstractions, or pattern-heavy library code. |
107
108
 
108
109
  ## Skill Dependencies
109
110
 
@@ -147,6 +148,7 @@ npx skills add joktec/joktec-skills -a codex --project . \
147
148
  | "Use Elastic, Arango, or BigQuery" | `joktec-database-extended-skill` |
148
149
  | "Use Firebase or GPT package" | `joktec-integration-skill` |
149
150
  | "Use HTTP/file/alert helpers" | `joktec-tool-skill` |
151
+ | "Design advanced TypeScript APIs or decorators" | `advanced-typescript-design` |
150
152
 
151
153
  ---
152
154
 
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: advanced-typescript-design
3
+ description: Use this skill for TypeScript framework/library design, including generic public APIs, infer/conditional/recursive mapped types, decorator metadata, type-safe query DSLs, lifecycle abstractions, and design pattern selection. Use for TypeScript/NestJS packages, repositories, DTO/query types, clients, loaders, metrics, or when deciding whether simple TypeScript is enough or advanced type-system design is justified.
4
+ ---
5
+
6
+ # Advanced TypeScript Design
7
+
8
+ ## Overview
9
+
10
+ Act as a TypeScript architecture partner. Choose the simplest design that preserves clear boundaries, runtime correctness, and useful compile-time guarantees.
11
+
12
+ Use design patterns as vocabulary and pressure tests, not as decoration. Prefer local project conventions, readable APIs, and low-friction extension points before adding type-level machinery.
13
+
14
+ ## Architectural Mindset
15
+
16
+ - Start from the domain boundary: identify entity, request/response, service, repository, client, decorator, loader, and integration responsibilities.
17
+ - Keep public APIs narrow and stable. Make extension explicit through interfaces, abstract classes, generic constraints, or composition.
18
+ - Use classes when lifecycle, inheritance hooks, decorators, or framework reflection matter. Use plain functions/types when behavior is stateless or purely transformational.
19
+ - Let runtime validation and compile-time types reinforce each other. Do not pretend TypeScript types validate untrusted runtime data.
20
+ - Do not assume TypeScript generics, interfaces, unions, or array element types exist at runtime through `reflect-metadata`.
21
+ - Escalate type complexity only when it removes real duplication, prevents invalid states, or makes an API substantially safer.
22
+ - Check existing code before inventing a new pattern; mirror the repository's style when it already solves the same class of problem.
23
+
24
+ ## Public API Compatibility
25
+
26
+ - Treat exported types, classes, decorators, config objects, modules, and provider APIs as public contracts.
27
+ - Prefer additive changes over breaking renames, deleted fields, changed generic parameter order, or narrower accepted input shapes.
28
+ - Before changing exported generic types, check downstream inference from normal call sites and verify that common extension patterns still compile.
29
+ - If a breaking type or runtime contract change is unavoidable, report migration impact explicitly and include the smallest migration path.
30
+
31
+ ## Pattern Vocabulary
32
+
33
+ Use the classic catalog as shared language, including the TypeScript examples catalog from Refactoring.Guru.
34
+
35
+ - Creational Patterns: Abstract Factory, Builder, Factory Method, Prototype, Singleton.
36
+ - Structural Patterns: Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy.
37
+ - Behavioral Patterns: Chain of Responsibility, Iterator, Memento, State, Template Method, Command, Mediator, Observer, Strategy, Visitor.
38
+
39
+ Treat pattern names as a starting point for design discussion. Validate whether the implementation needs the pattern's tradeoffs, or whether a direct function, data object, or interface is enough.
40
+
41
+ ## Agent Workflow
42
+
43
+ 1. Inspect local code first when working inside a repository. Look for existing abstractions, decorators, DTO types, factory functions, lifecycle hooks, and tests.
44
+ 2. Classify the task:
45
+ - Use `references/simple.md` for everyday TypeScript, OOP, data modeling, classes, interfaces, types, records, maps, arrays, simple decorators, and pragmatic refactors.
46
+ - Use `references/advanced.md` for generic framework code, recursive mapped types, `infer`, distributed/deferred conditional types, reflection metadata, advanced decorators, type-safe builders, plugin architectures, or expert pattern selection.
47
+ 3. Choose the least complex pattern that solves the force in front of you. Record why a simpler alternative was not enough when choosing advanced machinery.
48
+ 4. Design the public surface before implementation: inputs, outputs, extension points, error behavior, lifecycle, and type inference experience.
49
+ 5. Implement incrementally. Keep runtime behavior testable, and add focused type-level checks when exported generic or decorator behavior is subtle.
50
+ 6. Review for overengineering: remove unused generic parameters, speculative base classes, unnecessary inheritance, and type utilities that do not protect a real API.
51
+
52
+ ## Repository Signals
53
+
54
+ In JokTec-style TypeScript, expect patterns such as:
55
+
56
+ - Generic request/query types with recursive conditions and sort/populate typing.
57
+ - Factory functions that return decorated NestJS classes.
58
+ - Abstract services and clients with template methods for lifecycle-specific behavior.
59
+ - Decorator factories that compose validation, Swagger, transformation, metrics, and integration metadata.
60
+ - Loader/registry patterns that collect decorator metadata and wire runtime behavior during module initialization.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Advanced TypeScript Design"
3
+ short_description: "Design advanced TypeScript APIs"
4
+ default_prompt: "Use $advanced-typescript-design to design or refactor TypeScript framework code with an appropriate type-safety and pattern level."
@@ -0,0 +1,219 @@
1
+ # Advanced TypeScript Design Guidance
2
+
3
+ Use this reference for framework-level TypeScript, generic libraries, decorator infrastructure, metadata-driven loaders, and APIs where compile-time inference is part of the product experience.
4
+
5
+ ## Escalation Criteria
6
+
7
+ Reach for advanced TypeScript only when at least one is true:
8
+
9
+ - The API is reused widely and type inference prevents real misuse.
10
+ - The runtime model is already generic, recursive, or metadata-driven.
11
+ - The abstraction eliminates repeated boilerplate across many entities, DTOs, repositories, services, clients, or transports.
12
+ - The type-level design mirrors a stable domain contract, not a speculative future.
13
+ - Tests or examples can prove both runtime behavior and developer ergonomics.
14
+
15
+ If the advanced type exists only to feel clever, delete it.
16
+
17
+ ## Infer, Conditional, and Deferred Types
18
+
19
+ - Use `infer` to extract return types, payloads, entity types, DTO shapes, tuple elements, and callback signatures from source contracts.
20
+ - Control distributive conditional types intentionally. Wrap operands in tuples, such as `[T] extends [U]`, when union distribution is not wanted.
21
+ - Prefer named intermediate aliases when nested conditionals exceed two branches.
22
+ - Use `never` as a filter, but verify that it cannot erase useful error information from public APIs.
23
+ - Treat deferred conditional types and generic inference as public UX: callers should get helpful autocomplete and errors without manual type arguments.
24
+
25
+ ## Recursive and Mapped Types
26
+
27
+ - Use recursive mapped types for query languages, nested sort/select/populate APIs, deep partials, and entity graph traversal.
28
+ - Add clear stop conditions for primitives, dates, arrays, functions, and branded values.
29
+ - Use branded or opaque types for special primitives such as `ObjectId`, `UserId`, tenant IDs, cursors, or external reference IDs when plain strings would blur domain boundaries.
30
+ - Avoid infinite or overly expensive type recursion. Keep recursion shallow enough for editor performance.
31
+ - Preserve optionality and readonly modifiers intentionally with `+?`, `-?`, `readonly`, and `-readonly`.
32
+ - Separate query operator typing from entity typing so the operator model remains testable and reusable.
33
+
34
+ ## Reflection and Decorators
35
+
36
+ - Use `reflect-metadata` only when runtime type information materially improves the API: schema generation, validation composition, serialization, dependency injection, or loader registration.
37
+ - Remember that reflected TypeScript types are lossy at runtime. Arrays, unions, generics, and interfaces need explicit options or factories.
38
+ - Prefer decorator factories that normalize options, resolve type factories, compose framework decorators, and define one clear metadata contract.
39
+ - Keep advanced decorators thin at the call site and explicit internally: clone options, sanitize runtime-only fields, then compose validators, transformers, docs, and persistence metadata.
40
+ - For method decorators, preserve `this`, return values, thrown errors, and async behavior unless the decorator explicitly changes them.
41
+ - Use function source parsing only as a last-resort runtime technique for decorator infrastructure, such as mapping method argument names. Keep it isolated, deterministic, and covered by tests because minification, transpilation, defaults, destructuring, and comments can break it.
42
+ - Test decorator behavior through a class that uses it, especially for metadata, wrapping behavior, and dependency injection.
43
+
44
+ ## Type-Level Verification
45
+
46
+ - Add type-level tests when changing exported generic utilities, query DSLs, decorators, builders, or public inference-heavy APIs.
47
+ - Prefer the project's existing compile/type test setup. If available, use `tsd`, `expect-type`, `vitest`/`jest` type helpers, or a dedicated `tsc --noEmit` fixture.
48
+ - Include positive inference examples from normal call sites, not only explicit generic arguments.
49
+ - Include negative examples with `@ts-expect-error` when an invalid state must stay rejected.
50
+ - Verify runtime tests separately when decorators, reflection metadata, validation, transformation, or loaders are involved.
51
+
52
+ ## Expert Pattern Selection
53
+
54
+ - Abstract Factory fits families of related clients, repositories, or transport adapters that must be created consistently.
55
+ - Builder fits fluent configuration with required-step guarantees; type-state builders can enforce completeness but should stay readable.
56
+ - Factory Method fits framework hooks that create DTOs, pagination wrappers, controllers, or provider instances.
57
+ - Prototype fits cloning configured objects when construction is expensive or stateful.
58
+ - Singleton should usually be delegated to the DI container; avoid hand-rolled global state.
59
+ - Adapter fits third-party client normalization and migration layers.
60
+ - Bridge fits separating abstraction from implementation, such as transport-agnostic messaging APIs over Rabbit, Kafka, or Redis.
61
+ - Composite fits tree-shaped filters, pipelines, menu/routes, or nested query conditions.
62
+ - Decorator fits metrics, retries, circuit breakers, serialization, validation, or publishing side effects around existing behavior.
63
+ - Facade fits a stable service hiding multiple low-level collaborators.
64
+ - Flyweight fits large repeated metadata or schema objects only after measuring memory pressure.
65
+ - Proxy fits lazy clients, caching, access control, retries, and remote boundaries.
66
+ - Chain of Responsibility fits validation, middleware, parsing, and request pipelines.
67
+ - Command fits queued work, replayable operations, and undoable actions.
68
+ - Iterator fits cursor pagination and collection traversal without exposing storage details.
69
+ - Mediator fits module coordination where direct dependencies would become tangled.
70
+ - Memento fits snapshots, rollbacks, and state restoration.
71
+ - Observer fits event streams and pub/sub, with explicit unsubscribe and error policy.
72
+ - State fits lifecycle-heavy clients, jobs, or connections with mode-specific behavior.
73
+ - Strategy fits interchangeable algorithms selected by config or runtime context.
74
+ - Template Method fits abstract base services/clients that own lifecycle while subclasses implement `init`, `start`, `stop`, `validate`, or `transform` steps.
75
+ - Visitor fits operations over stable object structures when adding new operations is more common than adding new node types.
76
+
77
+ ## Symbolic Examples
78
+
79
+ Use examples like these as compact templates for thinking. Keep production implementations smaller or larger depending on the actual force.
80
+
81
+ ### Type-Safe Event Map
82
+
83
+ ```typescript
84
+ type EventMap = {
85
+ "user.created": { id: string };
86
+ "invoice.paid": { invoiceId: string; amount: number };
87
+ };
88
+
89
+ class EventBus<TEvents extends Record<string, unknown>> {
90
+ on<K extends keyof TEvents>(event: K, handler: (payload: TEvents[K]) => void) {}
91
+ emit<K extends keyof TEvents>(event: K, payload: TEvents[K]) {}
92
+ }
93
+
94
+ const bus = new EventBus<EventMap>();
95
+ bus.emit("invoice.paid", { invoiceId: "inv_1", amount: 100 });
96
+ ```
97
+
98
+ Use this for Observer/Mediator-style APIs where event names and payloads must stay coupled.
99
+
100
+ ### API Contract Inference
101
+
102
+ ```typescript
103
+ type Endpoint = {
104
+ "/users/:id": {
105
+ GET: { params: { id: string }; response: User };
106
+ PATCH: { params: { id: string }; body: Partial<User>; response: User };
107
+ };
108
+ };
109
+
110
+ type ResponseOf<T> = T extends { response: infer R } ? R : never;
111
+
112
+ class ApiClient<TContract extends Record<string, any>> {
113
+ request<Path extends keyof TContract, Method extends keyof TContract[Path]>(
114
+ path: Path,
115
+ method: Method,
116
+ ): Promise<ResponseOf<TContract[Path][Method]>> {
117
+ return null as any;
118
+ }
119
+ }
120
+ ```
121
+
122
+ Use this when a contract object should drive call-site inference.
123
+
124
+ ### Type-State Builder
125
+
126
+ ```typescript
127
+ type With<K extends string> = Record<K, true>;
128
+
129
+ class JobBuilder<State = {}> {
130
+ queue(name: string): JobBuilder<State & With<"queue">> {
131
+ return this as any;
132
+ }
133
+
134
+ handler(fn: () => Promise<void>): JobBuilder<State & With<"handler">> {
135
+ return this as any;
136
+ }
137
+
138
+ build(this: State extends With<"queue"> & With<"handler"> ? JobBuilder<State> : never) {
139
+ return {};
140
+ }
141
+ }
142
+ ```
143
+
144
+ Use this when incomplete configuration is common and worth rejecting at compile time.
145
+
146
+ ### Recursive Query Shape
147
+
148
+ ```typescript
149
+ type Primitive = string | number | boolean | Date;
150
+ type FieldOp<T> = T | { $eq?: T; $in?: T[] };
151
+ type Brand<T, Name extends string> = T & { readonly __brand: Name };
152
+ type ObjectId = Brand<string, "ObjectId">;
153
+
154
+ type Query<T> = {
155
+ [K in keyof T]?: T[K] extends Primitive
156
+ ? FieldOp<T[K]>
157
+ : T[K] extends Array<infer U>
158
+ ? Query<U>
159
+ : Query<T[K]>;
160
+ } & {
161
+ $or?: Query<T>[];
162
+ };
163
+ ```
164
+
165
+ Use this for Composite-style nested filters, but add stop conditions before expanding it.
166
+
167
+ ### Opaque ID Boundary
168
+
169
+ ```typescript
170
+ type Brand<T, Name extends string> = T & { readonly __brand: Name };
171
+ type UserId = Brand<string, "UserId">;
172
+ type PostId = Brand<string, "PostId">;
173
+
174
+ function asUserId(value: string): UserId {
175
+ return value as UserId;
176
+ }
177
+
178
+ function findUser(id: UserId) {}
179
+
180
+ findUser(asUserId("u_1"));
181
+ // @ts-expect-error raw strings are not accepted here
182
+ findUser("u_1");
183
+ ```
184
+
185
+ Use this when a domain primitive crosses many generic/query layers and accidental mixing would be costly.
186
+
187
+ ### Decorator Wrapper with Preserved Method Contract
188
+
189
+ ```typescript
190
+ function Around(run: (next: () => unknown) => unknown): MethodDecorator {
191
+ return (_, __, descriptor) => {
192
+ const original = descriptor.value;
193
+
194
+ descriptor.value = function (...args: unknown[]) {
195
+ return run(() => original.apply(this, args));
196
+ };
197
+ };
198
+ }
199
+ ```
200
+
201
+ Use this for metrics, retry, logging, or publishing side effects; preserve `this`, args, return values, and thrown errors.
202
+
203
+ ## JokTec-Style Signals to Reuse
204
+
205
+ - Recursive query typing can combine entity properties with operator unions, nested entity traversal, and logical `$or`/`$and` shapes.
206
+ - Base services and clients commonly use Template Method: the base class owns lifecycle and shared behavior while subclasses provide specific implementation steps.
207
+ - Controller factories can return decorated classes to avoid repetitive NestJS endpoint scaffolding while preserving DTO-specific metadata.
208
+ - Decorator infrastructure often composes Swagger, validation, transformation, persistence, and metric behavior from one options object.
209
+ - Rabbit loaders show a metadata registry plus module-init loader pattern: decorators declare intent; loaders resolve providers and connect runtime consumers.
210
+
211
+ ## Advanced Review Checklist
212
+
213
+ - Does every generic parameter appear in the public contract or implementation?
214
+ - Can inference succeed from normal call-site arguments?
215
+ - Does the type-level model match runtime validation and transformation?
216
+ - Are metadata keys centralized and collision-resistant?
217
+ - Are decorator side effects documented by tests?
218
+ - Is editor performance acceptable after adding recursive or conditional types?
219
+ - Is there a simpler Strategy, Adapter, or function-based design that would provide the same value?
@@ -0,0 +1,149 @@
1
+ # Simple TypeScript Design Guidance
2
+
3
+ Use this reference for ordinary application and library work where readability, stable APIs, and maintainable TypeScript matter more than type-level cleverness.
4
+
5
+ ## Default Practices
6
+
7
+ - Prefer explicit, small interfaces for public boundaries and concrete classes for runtime behavior with lifecycle, dependency injection, or decorators.
8
+ - Use `type` for unions, mapped shapes, conditional aliases, and composition. Use `interface` for object contracts intended to be implemented or extended.
9
+ - Keep primitive aliases meaningful. A `UserId` alias can clarify intent, but it does not add runtime safety unless paired with validation or branding.
10
+ - Model data with plain objects when behavior is absent. Add classes when construction, methods, inheritance hooks, decorators, or framework reflection are required.
11
+ - Keep DTOs, entities, requests, and responses separate when they have different validation, persistence, or transport concerns.
12
+ - Avoid `any` at public boundaries. Use `unknown` for untrusted data, then narrow or validate it.
13
+ - Prefer narrow generic constraints such as `T extends Entity` over unconstrained `T` when the implementation depends on object semantics.
14
+
15
+ ## Classes, Interfaces, and OOP
16
+
17
+ - Use abstract classes for shared runtime behavior, protected hooks, and constructor-injected dependencies.
18
+ - Use interfaces for contracts that should not carry runtime behavior.
19
+ - Prefer composition over inheritance when variants differ by collaborator rather than lifecycle.
20
+ - Keep protected hooks purposeful: `afterInit`, `transform`, `validate`, and `map` are good when subclasses are expected to customize one stable step.
21
+ - Avoid deep inheritance chains. If a third level appears, consider Strategy, Adapter, or composition.
22
+
23
+ ## Common Data Structures
24
+
25
+ - Use `Record<K, V>` when the key set is known or constrained.
26
+ - Use `{ [key: string]: V }` when the object is truly open-ended.
27
+ - Use `Map<K, V>` when keys are not strings, insertion order matters, or frequent add/remove operations are central.
28
+ - Use arrays for ordered collections and tuples for fixed positional contracts.
29
+ - Use discriminated unions for state or command variants instead of loose booleans.
30
+ - Keep hash-like caches private unless callers need iteration, eviction, or explicit lifecycle.
31
+
32
+ ## Basic Types and Utilities
33
+
34
+ - Use union literals for finite options: status, mode, operation, direction.
35
+ - Use `Pick`, `Omit`, `Partial`, `Required`, `Readonly`, `Record`, `Extract`, and `Exclude` before writing custom utilities.
36
+ - Use `keyof` and indexed access types for property-safe APIs.
37
+ - Use overloads sparingly; prefer a single options object when overloads become hard to read.
38
+ - Keep mapped types shallow unless the data is truly nested and the API benefits from deep transformation.
39
+
40
+ ## Simple Decorators
41
+
42
+ - Use decorator factories to attach framework metadata or compose existing decorators.
43
+ - Keep decorator options serializable and explicit where possible.
44
+ - Separate metadata collection from runtime execution. A decorator should usually register intent; a loader/service should execute it later.
45
+ - Avoid parsing function source in ordinary decorators. If runtime argument-name mapping truly requires it, escalate to `advanced.md` and isolate the parser behind tests.
46
+ - Test decorators at the behavior boundary, not only by checking metadata keys.
47
+
48
+ ## Pattern Choices
49
+
50
+ - Use Factory Method or simple factory functions when object creation varies by type or config.
51
+ - Use Builder for stepwise configuration only when partially built objects are common or order matters.
52
+ - Use Adapter to normalize third-party APIs behind project interfaces.
53
+ - Use Facade to simplify a noisy subsystem for callers.
54
+ - Use Decorator when behavior should wrap a method/object without changing its public contract.
55
+ - Use Template Method when a base class owns an algorithm and subclasses fill in specific steps.
56
+ - Use Strategy when an algorithm family changes independently from the caller.
57
+ - Use Observer or Mediator for event-style communication, but keep ownership and error handling explicit.
58
+
59
+ ## Symbolic Examples
60
+
61
+ Use examples like these to reason about shape and tradeoffs. Keep final code adapted to the repository style.
62
+
63
+ ### Strategy with a Narrow Interface
64
+
65
+ ```typescript
66
+ interface PriceStrategy {
67
+ total(items: CartItem[]): number;
68
+ }
69
+
70
+ class RetailPrice implements PriceStrategy {
71
+ total(items: CartItem[]) {
72
+ return items.reduce((sum, item) => sum + item.price, 0);
73
+ }
74
+ }
75
+
76
+ class WholesalePrice implements PriceStrategy {
77
+ total(items: CartItem[]) {
78
+ return items.reduce((sum, item) => sum + item.price * 0.9, 0);
79
+ }
80
+ }
81
+
82
+ class CheckoutService {
83
+ constructor(private readonly strategy: PriceStrategy) {}
84
+
85
+ quote(items: CartItem[]) {
86
+ return this.strategy.total(items);
87
+ }
88
+ }
89
+ ```
90
+
91
+ Use this when the caller should not know which algorithm is active.
92
+
93
+ ### Adapter for Third-Party Boundaries
94
+
95
+ ```typescript
96
+ interface MessageBus {
97
+ publish(topic: string, payload: unknown): Promise<void>;
98
+ }
99
+
100
+ class RabbitBusAdapter implements MessageBus {
101
+ constructor(private readonly rabbit: RabbitClient) {}
102
+
103
+ publish(topic: string, payload: unknown) {
104
+ return this.rabbit.sendToQueue(topic, JSON.stringify(payload));
105
+ }
106
+ }
107
+ ```
108
+
109
+ Use this when external clients have noisy or unstable APIs.
110
+
111
+ ### Template Method for Lifecycle Hooks
112
+
113
+ ```typescript
114
+ abstract class ManagedClient<TConfig, TClient> {
115
+ async connect(config: TConfig) {
116
+ const client = await this.create(config);
117
+ await this.start(client);
118
+ return client;
119
+ }
120
+
121
+ protected abstract create(config: TConfig): Promise<TClient>;
122
+ protected abstract start(client: TClient): Promise<void>;
123
+ }
124
+ ```
125
+
126
+ Use this when the base class owns lifecycle order and subclasses fill the variable steps.
127
+
128
+ ### Simple Decorator Metadata
129
+
130
+ ```typescript
131
+ const HANDLER_KEY = "app:handler";
132
+
133
+ function Handler(name: string): MethodDecorator {
134
+ return (_, __, descriptor) => {
135
+ Reflect.defineMetadata(HANDLER_KEY, name, descriptor.value);
136
+ };
137
+ }
138
+ ```
139
+
140
+ Use this when methods declare intent and another loader executes it later.
141
+
142
+ ## Practical Review Checklist
143
+
144
+ - Can a teammate understand the public API without reading private helpers?
145
+ - Does the type design represent real runtime rules?
146
+ - Are names domain-specific enough to explain intent?
147
+ - Is the pattern solving current duplication or variability?
148
+ - Are validation, transformation, persistence, and transport concerns separated?
149
+ - Are tests focused on behavior that the abstraction promises to preserve?
@@ -24,6 +24,7 @@ Use this skill for pluggable external capability adapters.
24
24
  - Use validated config and `conId` where supported.
25
25
  - Keep secrets and credentials in app config or runtime environment, never in code.
26
26
  - Prefer adapter services over direct SDK usage in app services.
27
+ - If guidance is insufficient, read this skill's references and inspect `../joktec-framework` package source or GitHub fallback before assuming APIs.
27
28
 
28
29
  ## Reference
29
30
 
@@ -1,12 +1,40 @@
1
1
  # Adapter Usage
2
2
 
3
+ ## Source Lookup
4
+
5
+ When blocked, inspect:
6
+
7
+ - `packages/adapters/README.md`
8
+ - `packages/adapters/AGENTS.md`
9
+ - `packages/adapters/<package>/README.md`
10
+ - `packages/adapters/<package>/src/index.ts`
11
+ - package module/config/service files under `src/`
12
+
3
13
  ## Runtime Pattern
4
14
 
5
15
  Adapters are global Nest modules. Services own native client creation and expose package-specific operations.
6
16
 
17
+ Most adapters follow `AbstractClientService`: config is validated, native clients are created by the service, `conId` selects the connection, and shutdown/retry/debug behavior should remain package-owned.
18
+
7
19
  ## Package Notes
8
20
 
9
21
  - Cacher: choose local, Redis, or Memcached stores based on runtime config.
10
22
  - Mailer: centralize mail transport configuration in the service that owns outbound email.
11
23
  - Notifier: keep push provider configuration outside app business logic.
12
24
  - Storage: keep storage metadata and object operations behind the adapter service.
25
+
26
+ ## Best Practices
27
+
28
+ - Import adapter modules in the application layer, then inject services into domain services.
29
+ - Keep provider credentials, endpoints, bucket names, SMTP secrets, and push credentials in runtime config.
30
+ - Keep business payload composition in the consuming app. The adapter should send/cache/store, not decide product semantics.
31
+ - Use `conId` for multiple providers or tenants instead of creating ad-hoc service instances.
32
+ - Normalize provider errors at the package/app boundary so controllers do not branch on SDK-specific messages.
33
+ - Mock SDK clients in unit tests; run live provider checks only in explicit integration or consumer harness tests.
34
+
35
+ ## Anti-Patterns
36
+
37
+ - Do not put email template business rules inside `@joktec/mailer`.
38
+ - Do not hardcode S3 buckets, Redis URLs, SMTP credentials, or notification tokens in source.
39
+ - Do not bypass adapter services by importing provider SDK clients directly throughout the app.
40
+ - Do not assume every adapter has identical method names; read each package README/source before calling.
@@ -24,6 +24,7 @@ Use this skill for message broker packages.
24
24
  - Use broker decorators for transport wiring, not for domain policy.
25
25
  - Preserve config-driven client selection and `conId` when available.
26
26
  - Keep topic, queue, and routing names explicit in app configuration or decorators.
27
+ - If guidance is insufficient, read this skill's references and inspect `../joktec-framework` package source or GitHub fallback before assuming APIs.
27
28
 
28
29
  ## Reference
29
30
 
@@ -1,12 +1,41 @@
1
1
  # Broker Usage
2
2
 
3
+ ## Source Lookup
4
+
5
+ When blocked, inspect:
6
+
7
+ - `packages/brokers/README.md`
8
+ - `packages/brokers/AGENTS.md`
9
+ - `packages/brokers/<package>/README.md`
10
+ - `packages/brokers/<package>/src/index.ts`
11
+ - package decorators, loaders, config, and service files under `src/`
12
+
3
13
  ## Runtime Pattern
4
14
 
5
15
  Broker services follow `AbstractClientService` lifecycle. Loader classes discover decorator metadata after module initialization. Apps define producers, consumers, and message semantics.
6
16
 
17
+ Use broker packages for transport wiring, not for business workflow ownership. The consuming app owns event names, payload contracts, idempotency, retry policy, dead-letter behavior, and handler semantics.
18
+
7
19
  ## Package Notes
8
20
 
9
21
  - Kafka: check topic existence and broker advertised listeners in local development.
10
22
  - RabbitMQ: use module options and decorators for exchanges, queues, and bindings.
11
23
  - SQS: local ElasticMQ-style environments may require queues to exist before consumers start.
12
24
  - Redcast: use Redis-backed list, stream, or pub/sub behavior when a lightweight broker is enough.
25
+
26
+ ## Best Practices
27
+
28
+ - Start consumers only in processes that should own subscriptions.
29
+ - Keep producer and consumer payload DTOs versionable and explicit.
30
+ - Use config paths or module options for topic/queue names when supported.
31
+ - Make handlers idempotent; brokers may redeliver.
32
+ - Add observable effects for consumer tests rather than asserting log text.
33
+ - Keep broker health/preflight checks separate from business request handling.
34
+ - In local stacks, verify broker-specific infrastructure: Kafka topics, Rabbit exchanges/queues, SQS queues, Redis password/db.
35
+
36
+ ## Anti-Patterns
37
+
38
+ - Do not hide domain workflows inside decorators or broker package services.
39
+ - Do not assume auto-create topic/queue behavior unless the package and local broker support it.
40
+ - Do not run the same consumer group/queue owner in every process by accident.
41
+ - Do not swallow message handling errors without retry/dead-letter visibility.
@@ -24,6 +24,7 @@ Use this skill for shared framework primitives, low-level helpers, cron utilitie
24
24
  - Use page, offset, or cursor pagination contracts from core; let database packages execute storage-specific pagination.
25
25
  - Use `AbstractClientService` patterns for client packages that need config, lifecycle, retry, and `conId`.
26
26
  - Use `@joktec/utils` for shared helpers instead of duplicating conversion, validation, hashing, or UUID logic.
27
+ - If guidance is insufficient, read this skill's references and inspect `../joktec-framework` package source or GitHub fallback before assuming APIs.
27
28
 
28
29
  ## References
29
30
 
@@ -1,19 +1,75 @@
1
1
  # Common Core Usage
2
2
 
3
+ ## Source Lookup
4
+
5
+ When blocked, inspect these framework files before guessing:
6
+
7
+ - `packages/common/core/README.md`
8
+ - `packages/common/core/AGENTS.md`
9
+ - `packages/common/core/src/index.ts`
10
+ - `packages/common/core/src/abstractions/*`
11
+ - `packages/common/core/src/models/base.request.ts`
12
+ - `packages/common/core/src/models/base.response.ts`
13
+ - `packages/common/core/src/models/paginations/*`
14
+ - `packages/common/core/src/client/abstract-client.service.ts`
15
+ - `packages/common/core/src/infras/application.ts`
16
+ - `packages/common/core/src/modules/*`
17
+
3
18
  ## Runtime Bootstrap
4
19
 
5
20
  Use the application bootstrap helpers from `@joktec/core` for gateway and microservice runtimes. Keep runtime behavior config-driven.
6
21
 
22
+ Best practice:
23
+
24
+ - Use `Application.bootstrap(AppModule)` instead of hand-rolling Nest bootstrap unless the consumer app has a specific runtime reason.
25
+ - Keep gateway-only behavior in gateway runtime modules and microservice-only behavior in micro runtime modules.
26
+ - Register framework modules through their dynamic module APIs when provided.
27
+ - Do not duplicate config parsing, logger setup, metrics setup, or process lifecycle hooks in consumer apps.
28
+
7
29
  ## CRUD Abstractions
8
30
 
9
31
  - `BaseController` creates standard REST CRUD endpoints for DTO-backed resources.
10
32
  - `BaseService` delegates repository operations through the shared repository contract.
11
33
  - `ClientController` and `ClientService` provide generated microservice CRUD patterns.
12
34
 
35
+ Use BaseController/BaseService when the resource follows standard CRUD. Avoid them when the endpoint has domain-specific command semantics, multi-step transactions, or non-standard authorization that would make the generic abstraction obscure behavior.
36
+
37
+ Controller checklist:
38
+
39
+ - choose the DTO/entity class intentionally
40
+ - set `paginationMode` for the representative Swagger response shape
41
+ - use `customDto.paginationDto` only when the built-in page/offset/cursor response does not represent the API
42
+ - keep auth/guards/interceptors consistent with app conventions
43
+ - avoid putting business branching in controller methods when it belongs in the service
44
+
13
45
  ## Pagination
14
46
 
15
47
  Request priority is cursor, then offset, then page. `BaseController.paginationMode` affects Swagger response shape; runtime selection remains request-driven unless the app service narrows it.
16
48
 
49
+ Best practice:
50
+
51
+ - Use page pagination for admin tables and simple back-office views.
52
+ - Use offset pagination for mobile-style load-more when the data set is moderate and stable enough.
53
+ - Use cursor pagination for feeds, timelines, frequently inserted lists, or large tables.
54
+ - Do not document cursor support for a resource unless the underlying repository package actually supports it.
55
+ - When using cursor mode, ensure the database layer has stable sort keys and tie-breakers.
56
+
17
57
  ## Client Lifecycle
18
58
 
19
59
  Use `ClientConfig`, `AbstractClientService`, and `conId` when building or consuming packages that support multiple client connections.
60
+
61
+ Client package checklist:
62
+
63
+ - config class validates all required runtime options
64
+ - service startup fails clearly when the native client cannot initialize
65
+ - shutdown closes native connections only when initialized
66
+ - `conId` is preserved through service/repository calls
67
+ - logs do not leak credentials or full connection strings
68
+ - retries and debug behavior are config-driven
69
+
70
+ ## Do Not
71
+
72
+ - Do not import concrete package or app code into `@joktec/core`.
73
+ - Do not bypass shared pagination contracts with ad-hoc response shapes for standard CRUD.
74
+ - Do not add new public symbols without exporting them through `src/index.ts`.
75
+ - Do not silently swallow bootstrap/client initialization failures.