dsh-ecc-skills 0.4.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 (278) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +99 -0
  3. package/cordis.patch.yml +5 -0
  4. package/lib/index.js +195 -0
  5. package/package.json +46 -0
  6. package/skills/accessibility/SKILL.md +147 -0
  7. package/skills/agent-architecture-audit/SKILL.md +257 -0
  8. package/skills/agent-eval/SKILL.md +147 -0
  9. package/skills/agent-harness-construction/SKILL.md +74 -0
  10. package/skills/agent-introspection-debugging/SKILL.md +154 -0
  11. package/skills/agent-payment-x402/SKILL.md +225 -0
  12. package/skills/agent-self-evaluation/SKILL.md +182 -0
  13. package/skills/agent-sort/SKILL.md +216 -0
  14. package/skills/agentic-engineering/SKILL.md +64 -0
  15. package/skills/agentic-os/SKILL.md +388 -0
  16. package/skills/ai-first-engineering/SKILL.md +52 -0
  17. package/skills/ai-regression-testing/SKILL.md +386 -0
  18. package/skills/android-clean-architecture/SKILL.md +340 -0
  19. package/skills/angular-developer/SKILL.md +155 -0
  20. package/skills/api-connector-builder/SKILL.md +121 -0
  21. package/skills/api-design/SKILL.md +524 -0
  22. package/skills/architecture-decision-records/SKILL.md +180 -0
  23. package/skills/article-writing/SKILL.md +80 -0
  24. package/skills/automation-audit-ops/SKILL.md +143 -0
  25. package/skills/autonomous-agent-harness/SKILL.md +274 -0
  26. package/skills/autonomous-loops/SKILL.md +611 -0
  27. package/skills/backend-patterns/SKILL.md +562 -0
  28. package/skills/benchmark/SKILL.md +95 -0
  29. package/skills/benchmark-methodology/SKILL.md +191 -0
  30. package/skills/benchmark-optimization-loop/SKILL.md +71 -0
  31. package/skills/blender-motion-state-inspection/SKILL.md +165 -0
  32. package/skills/blueprint/SKILL.md +106 -0
  33. package/skills/brand-discovery/SKILL.md +145 -0
  34. package/skills/brand-voice/SKILL.md +98 -0
  35. package/skills/browser-qa/SKILL.md +105 -0
  36. package/skills/bun-runtime/SKILL.md +85 -0
  37. package/skills/canary-watch/SKILL.md +108 -0
  38. package/skills/carrier-relationship-management/SKILL.md +212 -0
  39. package/skills/cisco-ios-patterns/SKILL.md +164 -0
  40. package/skills/ck/SKILL.md +148 -0
  41. package/skills/claude-devfleet/SKILL.md +112 -0
  42. package/skills/click-path-audit/SKILL.md +245 -0
  43. package/skills/clickhouse-io/SKILL.md +445 -0
  44. package/skills/code-tour/SKILL.md +254 -0
  45. package/skills/codebase-onboarding/SKILL.md +234 -0
  46. package/skills/codehealth-mcp/SKILL.md +167 -0
  47. package/skills/coding-standards/SKILL.md +551 -0
  48. package/skills/competitive-platform-analysis/SKILL.md +214 -0
  49. package/skills/competitive-report-structure/SKILL.md +162 -0
  50. package/skills/compose-multiplatform-patterns/SKILL.md +300 -0
  51. package/skills/config-gc/SKILL.md +120 -0
  52. package/skills/configure-ecc/SKILL.md +206 -0
  53. package/skills/connections-optimizer/SKILL.md +190 -0
  54. package/skills/content-engine/SKILL.md +132 -0
  55. package/skills/content-hash-cache-pattern/SKILL.md +162 -0
  56. package/skills/context-budget/SKILL.md +136 -0
  57. package/skills/continuous-agent-loop/SKILL.md +46 -0
  58. package/skills/contract-first/SKILL.md +287 -0
  59. package/skills/cost-aware-llm-pipeline/SKILL.md +184 -0
  60. package/skills/cost-tracking/SKILL.md +97 -0
  61. package/skills/council/SKILL.md +204 -0
  62. package/skills/council-multi-model/SKILL.md +167 -0
  63. package/skills/cpp-coding-standards/SKILL.md +724 -0
  64. package/skills/cpp-testing/SKILL.md +325 -0
  65. package/skills/crosspost/SKILL.md +112 -0
  66. package/skills/csharp-testing/SKILL.md +322 -0
  67. package/skills/customer-billing-ops/SKILL.md +141 -0
  68. package/skills/customs-trade-compliance/SKILL.md +263 -0
  69. package/skills/dart-flutter-patterns/SKILL.md +564 -0
  70. package/skills/dashboard-builder/SKILL.md +109 -0
  71. package/skills/data-scraper-agent/SKILL.md +765 -0
  72. package/skills/data-throughput-accelerator/SKILL.md +74 -0
  73. package/skills/database-migrations/SKILL.md +430 -0
  74. package/skills/deep-research/SKILL.md +160 -0
  75. package/skills/defi-amm-security/SKILL.md +167 -0
  76. package/skills/delivery-gate/SKILL.md +126 -0
  77. package/skills/deployment-patterns/SKILL.md +428 -0
  78. package/skills/design-system/SKILL.md +83 -0
  79. package/skills/dev-team/SKILL.md +203 -0
  80. package/skills/django-celery/SKILL.md +458 -0
  81. package/skills/django-patterns/SKILL.md +735 -0
  82. package/skills/django-security/SKILL.md +644 -0
  83. package/skills/django-tdd/SKILL.md +730 -0
  84. package/skills/django-verification/SKILL.md +470 -0
  85. package/skills/dmux-workflows/SKILL.md +192 -0
  86. package/skills/docker-patterns/SKILL.md +520 -0
  87. package/skills/documentation-lookup/SKILL.md +91 -0
  88. package/skills/dotnet-patterns/SKILL.md +322 -0
  89. package/skills/dynamic-workflow-mode/SKILL.md +124 -0
  90. package/skills/e2e-testing/SKILL.md +327 -0
  91. package/skills/ecc-tools-cost-audit/SKILL.md +161 -0
  92. package/skills/email-ops/SKILL.md +122 -0
  93. package/skills/energy-procurement/SKILL.md +228 -0
  94. package/skills/enterprise-agent-ops/SKILL.md +51 -0
  95. package/skills/error-handling/SKILL.md +377 -0
  96. package/skills/eval-harness/SKILL.md +271 -0
  97. package/skills/evm-token-decimals/SKILL.md +131 -0
  98. package/skills/exa-search/SKILL.md +108 -0
  99. package/skills/fal-ai-media/SKILL.md +289 -0
  100. package/skills/fastapi-patterns/SKILL.md +514 -0
  101. package/skills/finance-billing-ops/SKILL.md +128 -0
  102. package/skills/flox-environments/SKILL.md +497 -0
  103. package/skills/flutter-dart-code-review/SKILL.md +436 -0
  104. package/skills/foundation-models-on-device/SKILL.md +243 -0
  105. package/skills/frontend-a11y/SKILL.md +446 -0
  106. package/skills/frontend-design-direction/SKILL.md +93 -0
  107. package/skills/frontend-patterns/SKILL.md +657 -0
  108. package/skills/fsharp-testing/SKILL.md +281 -0
  109. package/skills/gan-style-harness/SKILL.md +279 -0
  110. package/skills/generating-python-installer/SKILL.md +820 -0
  111. package/skills/git-workflow/SKILL.md +716 -0
  112. package/skills/github-ops/SKILL.md +145 -0
  113. package/skills/golang-patterns/SKILL.md +676 -0
  114. package/skills/golang-testing/SKILL.md +721 -0
  115. package/skills/google-workspace-ops/SKILL.md +96 -0
  116. package/skills/growth-log/SKILL.md +128 -0
  117. package/skills/healthcare-cdss-patterns/SKILL.md +246 -0
  118. package/skills/healthcare-emr-patterns/SKILL.md +160 -0
  119. package/skills/healthcare-eval-harness/SKILL.md +208 -0
  120. package/skills/healthcare-phi-compliance/SKILL.md +146 -0
  121. package/skills/hermes-imports/SKILL.md +89 -0
  122. package/skills/hexagonal-architecture/SKILL.md +277 -0
  123. package/skills/hipaa-compliance/SKILL.md +79 -0
  124. package/skills/homelab-network-readiness/SKILL.md +170 -0
  125. package/skills/homelab-network-setup/SKILL.md +130 -0
  126. package/skills/homelab-pihole-dns/SKILL.md +275 -0
  127. package/skills/homelab-vlan-segmentation/SKILL.md +312 -0
  128. package/skills/homelab-wireguard-vpn/SKILL.md +306 -0
  129. package/skills/hookify-rules/SKILL.md +128 -0
  130. package/skills/inherit-legacy-style/SKILL.md +157 -0
  131. package/skills/intent-driven-development/SKILL.md +360 -0
  132. package/skills/inventory-demand-planning/SKILL.md +247 -0
  133. package/skills/investor-materials/SKILL.md +97 -0
  134. package/skills/investor-outreach/SKILL.md +92 -0
  135. package/skills/ios-icon-gen/SKILL.md +158 -0
  136. package/skills/iterative-retrieval/SKILL.md +212 -0
  137. package/skills/ito-baskets/SKILL.md +263 -0
  138. package/skills/ito-compute/SKILL.md +151 -0
  139. package/skills/ito-inference/SKILL.md +119 -0
  140. package/skills/ito-training/SKILL.md +123 -0
  141. package/skills/java-coding-standards/SKILL.md +384 -0
  142. package/skills/jira-integration/SKILL.md +303 -0
  143. package/skills/jpa-patterns/SKILL.md +152 -0
  144. package/skills/knowledge-ops/SKILL.md +155 -0
  145. package/skills/kotlin-coroutines-flows/SKILL.md +285 -0
  146. package/skills/kotlin-exposed-patterns/SKILL.md +720 -0
  147. package/skills/kotlin-ktor-patterns/SKILL.md +690 -0
  148. package/skills/kotlin-patterns/SKILL.md +712 -0
  149. package/skills/kotlin-testing/SKILL.md +825 -0
  150. package/skills/kubernetes-patterns/SKILL.md +756 -0
  151. package/skills/laravel-patterns/SKILL.md +416 -0
  152. package/skills/laravel-plugin-discovery/SKILL.md +230 -0
  153. package/skills/laravel-security/SKILL.md +948 -0
  154. package/skills/laravel-tdd/SKILL.md +675 -0
  155. package/skills/laravel-verification/SKILL.md +180 -0
  156. package/skills/latency-critical-systems/SKILL.md +75 -0
  157. package/skills/lead-intelligence/SKILL.md +322 -0
  158. package/skills/liquid-glass-design/SKILL.md +279 -0
  159. package/skills/living-docs-governance/SKILL.md +137 -0
  160. package/skills/llm-trading-agent-security/SKILL.md +147 -0
  161. package/skills/logistics-exception-management/SKILL.md +222 -0
  162. package/skills/loop-design-check/SKILL.md +143 -0
  163. package/skills/mailtrap-email-integration/SKILL.md +77 -0
  164. package/skills/make-interfaces-feel-better/SKILL.md +152 -0
  165. package/skills/manim-video/SKILL.md +90 -0
  166. package/skills/market-research/SKILL.md +76 -0
  167. package/skills/marketing-campaign/SKILL.md +114 -0
  168. package/skills/mcp-server-patterns/SKILL.md +70 -0
  169. package/skills/messages-ops/SKILL.md +105 -0
  170. package/skills/ml-adoption-playbook/SKILL.md +57 -0
  171. package/skills/mle-workflow/SKILL.md +348 -0
  172. package/skills/motion-advanced/SKILL.md +597 -0
  173. package/skills/motion-foundations/SKILL.md +300 -0
  174. package/skills/motion-patterns/SKILL.md +435 -0
  175. package/skills/motion-ui/SKILL.md +576 -0
  176. package/skills/mysql-patterns/SKILL.md +413 -0
  177. package/skills/nanoclaw-repl/SKILL.md +34 -0
  178. package/skills/nasiko-control-plane/SKILL.md +49 -0
  179. package/skills/nestjs-patterns/SKILL.md +231 -0
  180. package/skills/netmiko-ssh-automation/SKILL.md +174 -0
  181. package/skills/network-bgp-diagnostics/SKILL.md +168 -0
  182. package/skills/network-config-validation/SKILL.md +211 -0
  183. package/skills/network-interface-health/SKILL.md +153 -0
  184. package/skills/nextjs-turbopack/SKILL.md +58 -0
  185. package/skills/nodejs-keccak256/SKILL.md +103 -0
  186. package/skills/nutrient-document-processing/SKILL.md +168 -0
  187. package/skills/nuxt4-patterns/SKILL.md +101 -0
  188. package/skills/opensource-pipeline/SKILL.md +256 -0
  189. package/skills/orch-add-feature/SKILL.md +45 -0
  190. package/skills/orch-build-mvp/SKILL.md +49 -0
  191. package/skills/orch-change-feature/SKILL.md +43 -0
  192. package/skills/orch-fix-defect/SKILL.md +43 -0
  193. package/skills/orch-pipeline/SKILL.md +121 -0
  194. package/skills/orch-refine-code/SKILL.md +44 -0
  195. package/skills/parallel-execution-optimizer/SKILL.md +74 -0
  196. package/skills/perl-patterns/SKILL.md +505 -0
  197. package/skills/perl-security/SKILL.md +504 -0
  198. package/skills/perl-testing/SKILL.md +476 -0
  199. package/skills/plan-canvas/SKILL.md +196 -0
  200. package/skills/plankton-code-quality/SKILL.md +237 -0
  201. package/skills/postgres-patterns/SKILL.md +148 -0
  202. package/skills/prediction-market-oracle-research/SKILL.md +64 -0
  203. package/skills/prediction-market-risk-review/SKILL.md +61 -0
  204. package/skills/prisma-patterns/SKILL.md +401 -0
  205. package/skills/product-capability/SKILL.md +142 -0
  206. package/skills/product-lens/SKILL.md +93 -0
  207. package/skills/production-audit/SKILL.md +207 -0
  208. package/skills/production-scheduling/SKILL.md +238 -0
  209. package/skills/project-flow-ops/SKILL.md +112 -0
  210. package/skills/prompt-optimizer/SKILL.md +398 -0
  211. package/skills/python-patterns/SKILL.md +751 -0
  212. package/skills/python-testing/SKILL.md +817 -0
  213. package/skills/pytorch-patterns/SKILL.md +397 -0
  214. package/skills/quality-nonconformance/SKILL.md +260 -0
  215. package/skills/quarkus-patterns/SKILL.md +723 -0
  216. package/skills/quarkus-security/SKILL.md +468 -0
  217. package/skills/quarkus-tdd/SKILL.md +812 -0
  218. package/skills/quarkus-verification/SKILL.md +481 -0
  219. package/skills/ralphinho-rfc-pipeline/SKILL.md +68 -0
  220. package/skills/react-native-patterns/SKILL.md +326 -0
  221. package/skills/react-patterns/SKILL.md +342 -0
  222. package/skills/react-performance/SKILL.md +575 -0
  223. package/skills/react-testing/SKILL.md +424 -0
  224. package/skills/recsys-pipeline-architect/SKILL.md +115 -0
  225. package/skills/recursive-decision-ledger/SKILL.md +81 -0
  226. package/skills/redis-patterns/SKILL.md +404 -0
  227. package/skills/regex-vs-llm-structured-text/SKILL.md +221 -0
  228. package/skills/remotion-video-creation/SKILL.md +43 -0
  229. package/skills/repo-scan/SKILL.md +170 -0
  230. package/skills/research-ops/SKILL.md +113 -0
  231. package/skills/returns-reverse-logistics/SKILL.md +240 -0
  232. package/skills/rules-distill/SKILL.md +265 -0
  233. package/skills/rust-patterns/SKILL.md +500 -0
  234. package/skills/rust-testing/SKILL.md +501 -0
  235. package/skills/safety-guard/SKILL.md +76 -0
  236. package/skills/santa-method/SKILL.md +307 -0
  237. package/skills/scientific-db-pubmed-database/SKILL.md +176 -0
  238. package/skills/scientific-db-uspto-database/SKILL.md +178 -0
  239. package/skills/scientific-pkg-gget/SKILL.md +167 -0
  240. package/skills/scientific-thinking-literature-review/SKILL.md +193 -0
  241. package/skills/scientific-thinking-scholar-evaluation/SKILL.md +161 -0
  242. package/skills/search-first/SKILL.md +183 -0
  243. package/skills/security-bounty-hunter/SKILL.md +100 -0
  244. package/skills/security-scan/SKILL.md +166 -0
  245. package/skills/seo/SKILL.md +155 -0
  246. package/skills/skill-scout/SKILL.md +141 -0
  247. package/skills/skill-stocktake/SKILL.md +195 -0
  248. package/skills/social-graph-ranker/SKILL.md +155 -0
  249. package/skills/social-publisher/SKILL.md +130 -0
  250. package/skills/springboot-patterns/SKILL.md +315 -0
  251. package/skills/springboot-security/SKILL.md +273 -0
  252. package/skills/springboot-tdd/SKILL.md +159 -0
  253. package/skills/springboot-verification/SKILL.md +232 -0
  254. package/skills/swift-actor-persistence/SKILL.md +144 -0
  255. package/skills/swift-concurrency-6-2/SKILL.md +216 -0
  256. package/skills/swift-protocol-di-testing/SKILL.md +191 -0
  257. package/skills/swiftui-patterns/SKILL.md +259 -0
  258. package/skills/taste/SKILL.md +264 -0
  259. package/skills/tdd-workflow/SKILL.md +583 -0
  260. package/skills/team-agent-orchestration/SKILL.md +111 -0
  261. package/skills/team-builder/SKILL.md +169 -0
  262. package/skills/terminal-opener/SKILL.md +55 -0
  263. package/skills/terminal-ops/SKILL.md +110 -0
  264. package/skills/tinystruct-patterns/SKILL.md +279 -0
  265. package/skills/token-budget-advisor/SKILL.md +134 -0
  266. package/skills/ui-demo/SKILL.md +466 -0
  267. package/skills/ui-to-vue/SKILL.md +135 -0
  268. package/skills/uncloud/SKILL.md +344 -0
  269. package/skills/unified-memory/SKILL.md +170 -0
  270. package/skills/unified-notifications-ops/SKILL.md +188 -0
  271. package/skills/verification-loop/SKILL.md +129 -0
  272. package/skills/video-editing/SKILL.md +311 -0
  273. package/skills/videodb/SKILL.md +375 -0
  274. package/skills/vite-patterns/SKILL.md +450 -0
  275. package/skills/vue-patterns/SKILL.md +471 -0
  276. package/skills/windows-desktop-e2e/SKILL.md +888 -0
  277. package/skills/workspace-surface-audit/SKILL.md +126 -0
  278. package/skills/x-api/SKILL.md +235 -0
@@ -0,0 +1,152 @@
1
+ ---
2
+ name: jpa-patterns
3
+ description: JPA/Hibernate patterns for entity design, relationships, query optimization, transactions, auditing, indexing, pagination, and pooling in Spring Boot. Use when designing JPA entities or relationships, or when a Hibernate query, transaction, or N+1 problem needs fixing.
4
+ metadata:
5
+ origin: ECC
6
+ ---
7
+
8
+ # JPA/Hibernate Patterns
9
+
10
+ Use for data modeling, repositories, and performance tuning in Spring Boot.
11
+
12
+ ## When to Activate
13
+
14
+ - Designing JPA entities and table mappings
15
+ - Defining relationships (@OneToMany, @ManyToOne, @ManyToMany)
16
+ - Optimizing queries (N+1 prevention, fetch strategies, projections)
17
+ - Configuring transactions, auditing, or soft deletes
18
+ - Setting up pagination, sorting, or custom repository methods
19
+ - Tuning connection pooling (HikariCP) or second-level caching
20
+
21
+ ## Entity Design
22
+
23
+ ```java
24
+ @Entity
25
+ @Table(name = "markets", indexes = {
26
+ @Index(name = "idx_markets_slug", columnList = "slug", unique = true)
27
+ })
28
+ @EntityListeners(AuditingEntityListener.class)
29
+ public class MarketEntity {
30
+ @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
31
+ private Long id;
32
+
33
+ @Column(nullable = false, length = 200)
34
+ private String name;
35
+
36
+ @Column(nullable = false, unique = true, length = 120)
37
+ private String slug;
38
+
39
+ @Enumerated(EnumType.STRING)
40
+ private MarketStatus status = MarketStatus.ACTIVE;
41
+
42
+ @CreatedDate private Instant createdAt;
43
+ @LastModifiedDate private Instant updatedAt;
44
+ }
45
+ ```
46
+
47
+ Enable auditing:
48
+ ```java
49
+ @Configuration
50
+ @EnableJpaAuditing
51
+ class JpaConfig {}
52
+ ```
53
+
54
+ ## Relationships and N+1 Prevention
55
+
56
+ ```java
57
+ @OneToMany(mappedBy = "market", cascade = CascadeType.ALL, orphanRemoval = true)
58
+ private List<PositionEntity> positions = new ArrayList<>();
59
+ ```
60
+
61
+ - Default to lazy loading; use `JOIN FETCH` in queries when needed
62
+ - Avoid `EAGER` on collections; use DTO projections for read paths
63
+
64
+ ```java
65
+ @Query("select m from MarketEntity m left join fetch m.positions where m.id = :id")
66
+ Optional<MarketEntity> findWithPositions(@Param("id") Long id);
67
+ ```
68
+
69
+ ## Repository Patterns
70
+
71
+ ```java
72
+ public interface MarketRepository extends JpaRepository<MarketEntity, Long> {
73
+ Optional<MarketEntity> findBySlug(String slug);
74
+
75
+ @Query("select m from MarketEntity m where m.status = :status")
76
+ Page<MarketEntity> findByStatus(@Param("status") MarketStatus status, Pageable pageable);
77
+ }
78
+ ```
79
+
80
+ - Use projections for lightweight queries:
81
+ ```java
82
+ public interface MarketSummary {
83
+ Long getId();
84
+ String getName();
85
+ MarketStatus getStatus();
86
+ }
87
+ Page<MarketSummary> findAllBy(Pageable pageable);
88
+ ```
89
+
90
+ ## Transactions
91
+
92
+ - Annotate service methods with `@Transactional`
93
+ - Use `@Transactional(readOnly = true)` for read paths to optimize
94
+ - Choose propagation carefully; avoid long-running transactions
95
+
96
+ ```java
97
+ @Transactional
98
+ public Market updateStatus(Long id, MarketStatus status) {
99
+ MarketEntity entity = repo.findById(id)
100
+ .orElseThrow(() -> new EntityNotFoundException("Market"));
101
+ entity.setStatus(status);
102
+ return Market.from(entity);
103
+ }
104
+ ```
105
+
106
+ ## Pagination
107
+
108
+ ```java
109
+ PageRequest page = PageRequest.of(pageNumber, pageSize, Sort.by("createdAt").descending());
110
+ Page<MarketEntity> markets = repo.findByStatus(MarketStatus.ACTIVE, page);
111
+ ```
112
+
113
+ For cursor-like pagination, include `id > :lastId` in JPQL with ordering.
114
+
115
+ ## Indexing and Performance
116
+
117
+ - Add indexes for common filters (`status`, `slug`, foreign keys)
118
+ - Use composite indexes matching query patterns (`status, created_at`)
119
+ - Avoid `select *`; project only needed columns
120
+ - Batch writes with `saveAll` and `hibernate.jdbc.batch_size`
121
+
122
+ ## Connection Pooling (HikariCP)
123
+
124
+ Recommended properties:
125
+ ```
126
+ spring.datasource.hikari.maximum-pool-size=20
127
+ spring.datasource.hikari.minimum-idle=5
128
+ spring.datasource.hikari.connection-timeout=30000
129
+ spring.datasource.hikari.validation-timeout=5000
130
+ ```
131
+
132
+ For PostgreSQL LOB handling, add:
133
+ ```
134
+ spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
135
+ ```
136
+
137
+ ## Caching
138
+
139
+ - 1st-level cache is per EntityManager; avoid keeping entities across transactions
140
+ - For read-heavy entities, consider second-level cache cautiously; validate eviction strategy
141
+
142
+ ## Migrations
143
+
144
+ - Use Flyway or Liquibase; never rely on Hibernate auto DDL in production
145
+ - Keep migrations idempotent and additive; avoid dropping columns without plan
146
+
147
+ ## Testing Data Access
148
+
149
+ - Prefer `@DataJpaTest` with Testcontainers to mirror production
150
+ - Assert SQL efficiency using logs: set `logging.level.org.hibernate.SQL=DEBUG` and `logging.level.org.hibernate.orm.jdbc.bind=TRACE` for parameter values
151
+
152
+ **Remember**: Keep entities lean, queries intentional, and transactions short. Prevent N+1 with fetch strategies and projections, and index for your read/write paths.
@@ -0,0 +1,155 @@
1
+ ---
2
+ name: knowledge-ops
3
+ description: Knowledge base management, ingestion, sync, and retrieval across multiple storage layers (local files, MCP memory, vector stores, Git repos). Use when the user wants to save, organize, sync, deduplicate, or search across their knowledge systems.
4
+ metadata:
5
+ origin: ECC
6
+ ---
7
+
8
+ # Knowledge Operations
9
+
10
+ Manage a multi-layered knowledge system for ingesting, organizing, syncing, and retrieving knowledge across multiple stores.
11
+
12
+ Prefer the live workspace model:
13
+ - code work lives in the real cloned repos
14
+ - active execution context lives in GitHub, Linear, and repo-local working-context files
15
+ - broader human-facing notes can live in a non-repo context/archive folder
16
+ - durable cross-machine memory belongs in the knowledge base, not in a shadow repo workspace
17
+
18
+ ## When to Activate
19
+
20
+ - User wants to save information to their knowledge base
21
+ - Ingesting documents, conversations, or data into structured storage
22
+ - Syncing knowledge across systems (local files, MCP memory, Supabase, Git repos)
23
+ - Deduplicating or organizing existing knowledge
24
+ - User says "save this to KB", "sync knowledge", "what do I know about X", "ingest this", "update the knowledge base"
25
+ - Any knowledge management task beyond simple memory recall
26
+
27
+ ## Knowledge Architecture
28
+
29
+ ### Layer 1: Active execution truth
30
+ - **Sources:** GitHub issues, PRs, discussions, release notes, Linear issues/projects/docs
31
+ - **Use for:** the current operational state of the work
32
+ - **Rule:** if something affects an active engineering plan, roadmap, rollout, or release, prefer putting it here first
33
+
34
+ ### Layer 2: Claude Code Memory (Quick Access)
35
+ - **Path:** `~/.claude/projects/*/memory/`
36
+ - **Format:** Markdown files with frontmatter
37
+ - **Types:** user preferences, feedback, project context, reference
38
+ - **Use for:** quick-access context that persists across conversations
39
+ - **Automatically loaded at session start**
40
+
41
+ ### Layer 3: MCP Memory Server (Structured Knowledge Graph)
42
+ - **Access:** MCP memory tools (create_entities, create_relations, add_observations, search_nodes)
43
+ - **Use for:** Semantic search across all stored memories, relationship mapping
44
+ - **Cross-session persistence with queryable graph structure**
45
+
46
+ ### Layer 4: Knowledge base repo / durable document store
47
+ - **Use for:** curated durable notes, session exports, synthesized research, operator memory, long-form docs
48
+ - **Rule:** this is the preferred durable store for cross-machine context when the content is not repo-owned code
49
+
50
+ ### Layer 5: External Data Store (Supabase, PostgreSQL, etc.)
51
+ - **Use for:** Structured data, large document storage, full-text search
52
+ - **Good for:** Documents too large for memory files, data needing SQL queries
53
+
54
+ ### Layer 6: Local context/archive folder
55
+ - **Use for:** human-facing notes, archived gameplans, local media organization, temporary non-code docs
56
+ - **Rule:** writable for information storage, but not a shadow code workspace
57
+ - **Do not use for:** active code changes or repo truth that should live upstream
58
+
59
+ ## Ingestion Workflow
60
+
61
+ When new knowledge needs to be captured:
62
+
63
+ ### 1. Classify
64
+ What type of knowledge is it?
65
+ - Business decision -> memory file (project type) + MCP memory
66
+ - Active roadmap / release / implementation state -> GitHub + Linear first
67
+ - Personal preference -> memory file (user/feedback type)
68
+ - Reference info -> memory file (reference type) + MCP memory
69
+ - Large document -> external data store + summary in memory
70
+ - Conversation/session -> knowledge base repo + short summary in memory
71
+
72
+ ### 2. Deduplicate
73
+ Check if this knowledge already exists:
74
+ - Search memory files for existing entries
75
+ - Query MCP memory with relevant terms
76
+ - Check whether the information already exists in GitHub or Linear before creating another local note
77
+ - Do not create duplicates. Update existing entries instead.
78
+
79
+ ### 3. Store
80
+ Write to appropriate layer(s):
81
+ - Always update Claude Code memory for quick access
82
+ - Use MCP memory for semantic searchability and relationship mapping
83
+ - Update GitHub / Linear first when the information changes live project truth
84
+ - Commit to the knowledge base repo for durable long-form additions
85
+
86
+ ### 4. Index
87
+ Update any relevant indexes or summary files.
88
+
89
+ ## Sync Operations
90
+
91
+ ### Conversation Sync
92
+ Periodically sync conversation history into the knowledge base:
93
+ - Sources: Claude session files, Codex sessions, other agent sessions
94
+ - Destination: knowledge base repo
95
+ - Generate a session index for quick browsing
96
+ - Commit and push
97
+
98
+ ### Workspace State Sync
99
+ Mirror important workspace configuration and scripts to the knowledge base:
100
+ - Generate directory maps
101
+ - Redact sensitive config before committing
102
+ - Track changes over time
103
+ - Do not treat the knowledge base or archive folder as the live code workspace
104
+
105
+ ### GitHub / Linear Sync
106
+ When the information affects active execution:
107
+ - update the relevant GitHub issue, PR, discussion, release notes, or roadmap thread
108
+ - attach supporting docs to Linear when the work needs durable planning context
109
+ - only mirror a local note afterwards if it still adds value
110
+
111
+ ### Cross-Source Knowledge Sync
112
+ Pull knowledge from multiple sources into one place:
113
+ - Claude/ChatGPT/Grok conversation exports
114
+ - Browser bookmarks
115
+ - GitHub activity events
116
+ - Write status summary, commit and push
117
+
118
+ ## Memory Patterns
119
+
120
+ ```
121
+ # Short-term: current session context
122
+ Use TodoWrite for in-session task tracking
123
+
124
+ # Medium-term: project memory files
125
+ Write to ~/.claude/projects/*/memory/ for cross-session recall
126
+
127
+ # Long-term: GitHub / Linear / KB
128
+ Put active execution truth in GitHub + Linear
129
+ Put durable synthesized context in the knowledge base repo
130
+
131
+ # Semantic layer: MCP knowledge graph
132
+ Use mcp__memory__create_entities for permanent structured data
133
+ Use mcp__memory__create_relations for relationship mapping
134
+ Use mcp__memory__add_observations for new facts about known entities
135
+ Use mcp__memory__search_nodes to find existing knowledge
136
+ ```
137
+
138
+ ## Best Practices
139
+
140
+ - Keep memory files concise. Archive old data rather than letting files grow unbounded.
141
+ - Use frontmatter (YAML) for metadata on all knowledge files.
142
+ - Deduplicate before storing. Search first, then create or update.
143
+ - Prefer one canonical home per fact set. Avoid parallel copies of the same plan across local notes, repo files, and tracker docs.
144
+ - Redact sensitive information (API keys, passwords) before committing to Git.
145
+ - Use consistent naming conventions for knowledge files (lowercase-kebab-case).
146
+ - Tag entries with topics/categories for easier retrieval.
147
+
148
+ ## Quality Gate
149
+
150
+ Before completing any knowledge operation:
151
+ - no duplicate entries created
152
+ - sensitive data redacted from any Git-tracked files
153
+ - indexes and summaries updated
154
+ - appropriate storage layer chosen for the data type
155
+ - cross-references added where relevant
@@ -0,0 +1,285 @@
1
+ ---
2
+ name: kotlin-coroutines-flows
3
+ description: Kotlin Coroutines and Flow patterns for Android and KMP — structured concurrency, Flow operators, StateFlow, error handling, and testing. Use when writing coroutines or Flow code on Android or KMP, or debugging cancellation and concurrency.
4
+ metadata:
5
+ origin: ECC
6
+ ---
7
+
8
+ # Kotlin Coroutines & Flows
9
+
10
+ Patterns for structured concurrency, Flow-based reactive streams, and coroutine testing in Android and Kotlin Multiplatform projects.
11
+
12
+ ## When to Activate
13
+
14
+ - Writing async code with Kotlin coroutines
15
+ - Using Flow, StateFlow, or SharedFlow for reactive data
16
+ - Handling concurrent operations (parallel loading, debounce, retry)
17
+ - Testing coroutines and Flows
18
+ - Managing coroutine scopes and cancellation
19
+
20
+ ## Structured Concurrency
21
+
22
+ ### Scope Hierarchy
23
+
24
+ ```
25
+ Application
26
+ └── viewModelScope (ViewModel)
27
+ └── coroutineScope { } (structured child)
28
+ ├── async { } (concurrent task)
29
+ └── async { } (concurrent task)
30
+ ```
31
+
32
+ Always use structured concurrency — never `GlobalScope`:
33
+
34
+ ```kotlin
35
+ // BAD
36
+ GlobalScope.launch { fetchData() }
37
+
38
+ // GOOD — scoped to ViewModel lifecycle
39
+ viewModelScope.launch { fetchData() }
40
+
41
+ // GOOD — scoped to composable lifecycle
42
+ LaunchedEffect(key) { fetchData() }
43
+ ```
44
+
45
+ ### Parallel Decomposition
46
+
47
+ Use `coroutineScope` + `async` for parallel work:
48
+
49
+ ```kotlin
50
+ suspend fun loadDashboard(): Dashboard = coroutineScope {
51
+ val items = async { itemRepository.getRecent() }
52
+ val stats = async { statsRepository.getToday() }
53
+ val profile = async { userRepository.getCurrent() }
54
+ Dashboard(
55
+ items = items.await(),
56
+ stats = stats.await(),
57
+ profile = profile.await()
58
+ )
59
+ }
60
+ ```
61
+
62
+ ### SupervisorScope
63
+
64
+ Use `supervisorScope` when child failures should not cancel siblings:
65
+
66
+ ```kotlin
67
+ suspend fun syncAll() = supervisorScope {
68
+ launch { syncItems() } // failure here won't cancel syncStats
69
+ launch { syncStats() }
70
+ launch { syncSettings() }
71
+ }
72
+ ```
73
+
74
+ ## Flow Patterns
75
+
76
+ ### Cold Flow — One-Shot to Stream Conversion
77
+
78
+ ```kotlin
79
+ fun observeItems(): Flow<List<Item>> = flow {
80
+ // Re-emits whenever the database changes
81
+ itemDao.observeAll()
82
+ .map { entities -> entities.map { it.toDomain() } }
83
+ .collect { emit(it) }
84
+ }
85
+ ```
86
+
87
+ ### StateFlow for UI State
88
+
89
+ ```kotlin
90
+ class DashboardViewModel(
91
+ observeProgress: ObserveUserProgressUseCase
92
+ ) : ViewModel() {
93
+ val progress: StateFlow<UserProgress> = observeProgress()
94
+ .stateIn(
95
+ scope = viewModelScope,
96
+ started = SharingStarted.WhileSubscribed(5_000),
97
+ initialValue = UserProgress.EMPTY
98
+ )
99
+ }
100
+ ```
101
+
102
+ `WhileSubscribed(5_000)` keeps the upstream active for 5 seconds after the last subscriber leaves — survives configuration changes without restarting.
103
+
104
+ ### Combining Multiple Flows
105
+
106
+ ```kotlin
107
+ val uiState: StateFlow<HomeState> = combine(
108
+ itemRepository.observeItems(),
109
+ settingsRepository.observeTheme(),
110
+ userRepository.observeProfile()
111
+ ) { items, theme, profile ->
112
+ HomeState(items = items, theme = theme, profile = profile)
113
+ }.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), HomeState())
114
+ ```
115
+
116
+ ### Flow Operators
117
+
118
+ ```kotlin
119
+ // Debounce search input
120
+ searchQuery
121
+ .debounce(300)
122
+ .distinctUntilChanged()
123
+ .flatMapLatest { query -> repository.search(query) }
124
+ .catch { emit(emptyList()) }
125
+ .collect { results -> _state.update { it.copy(results = results) } }
126
+
127
+ // Retry with exponential backoff
128
+ fun fetchWithRetry(): Flow<Data> = flow { emit(api.fetch()) }
129
+ .retryWhen { cause, attempt ->
130
+ if (cause is IOException && attempt < 3) {
131
+ delay(1000L * (1 shl attempt.toInt()))
132
+ true
133
+ } else {
134
+ false
135
+ }
136
+ }
137
+ ```
138
+
139
+ ### SharedFlow for One-Time Events
140
+
141
+ ```kotlin
142
+ class ItemListViewModel : ViewModel() {
143
+ private val _effects = MutableSharedFlow<Effect>()
144
+ val effects: SharedFlow<Effect> = _effects.asSharedFlow()
145
+
146
+ sealed interface Effect {
147
+ data class ShowSnackbar(val message: String) : Effect
148
+ data class NavigateTo(val route: String) : Effect
149
+ }
150
+
151
+ private fun deleteItem(id: String) {
152
+ viewModelScope.launch {
153
+ repository.delete(id)
154
+ _effects.emit(Effect.ShowSnackbar("Item deleted"))
155
+ }
156
+ }
157
+ }
158
+
159
+ // Collect in Composable
160
+ LaunchedEffect(Unit) {
161
+ viewModel.effects.collect { effect ->
162
+ when (effect) {
163
+ is Effect.ShowSnackbar -> snackbarHostState.showSnackbar(effect.message)
164
+ is Effect.NavigateTo -> navController.navigate(effect.route)
165
+ }
166
+ }
167
+ }
168
+ ```
169
+
170
+ ## Dispatchers
171
+
172
+ ```kotlin
173
+ // CPU-intensive work
174
+ withContext(Dispatchers.Default) { parseJson(largePayload) }
175
+
176
+ // IO-bound work
177
+ withContext(Dispatchers.IO) { database.query() }
178
+
179
+ // Main thread (UI) — default in viewModelScope
180
+ withContext(Dispatchers.Main) { updateUi() }
181
+ ```
182
+
183
+ In KMP, use `Dispatchers.Default` and `Dispatchers.Main` (available on all platforms). `Dispatchers.IO` is JVM/Android only — use `Dispatchers.Default` on other platforms or provide via DI.
184
+
185
+ ## Cancellation
186
+
187
+ ### Cooperative Cancellation
188
+
189
+ Long-running loops must check for cancellation:
190
+
191
+ ```kotlin
192
+ suspend fun processItems(items: List<Item>) = coroutineScope {
193
+ for (item in items) {
194
+ ensureActive() // throws CancellationException if cancelled
195
+ process(item)
196
+ }
197
+ }
198
+ ```
199
+
200
+ ### Cleanup with try/finally
201
+
202
+ ```kotlin
203
+ viewModelScope.launch {
204
+ try {
205
+ _state.update { it.copy(isLoading = true) }
206
+ val data = repository.fetch()
207
+ _state.update { it.copy(data = data) }
208
+ } finally {
209
+ _state.update { it.copy(isLoading = false) } // always runs, even on cancellation
210
+ }
211
+ }
212
+ ```
213
+
214
+ ## Testing
215
+
216
+ ### Testing StateFlow with Turbine
217
+
218
+ ```kotlin
219
+ @Test
220
+ fun `search updates item list`() = runTest {
221
+ val fakeRepository = FakeItemRepository().apply { emit(testItems) }
222
+ val viewModel = ItemListViewModel(GetItemsUseCase(fakeRepository))
223
+
224
+ viewModel.state.test {
225
+ assertEquals(ItemListState(), awaitItem()) // initial
226
+
227
+ viewModel.onSearch("query")
228
+ val loading = awaitItem()
229
+ assertTrue(loading.isLoading)
230
+
231
+ val loaded = awaitItem()
232
+ assertFalse(loaded.isLoading)
233
+ assertEquals(1, loaded.items.size)
234
+ }
235
+ }
236
+ ```
237
+
238
+ ### Testing with TestDispatcher
239
+
240
+ ```kotlin
241
+ @Test
242
+ fun `parallel load completes correctly`() = runTest {
243
+ val viewModel = DashboardViewModel(
244
+ itemRepo = FakeItemRepo(),
245
+ statsRepo = FakeStatsRepo()
246
+ )
247
+
248
+ viewModel.load()
249
+ advanceUntilIdle()
250
+
251
+ val state = viewModel.state.value
252
+ assertNotNull(state.items)
253
+ assertNotNull(state.stats)
254
+ }
255
+ ```
256
+
257
+ ### Faking Flows
258
+
259
+ ```kotlin
260
+ class FakeItemRepository : ItemRepository {
261
+ private val _items = MutableStateFlow<List<Item>>(emptyList())
262
+
263
+ override fun observeItems(): Flow<List<Item>> = _items
264
+
265
+ fun emit(items: List<Item>) { _items.value = items }
266
+
267
+ override suspend fun getItemsByCategory(category: String): Result<List<Item>> {
268
+ return Result.success(_items.value.filter { it.category == category })
269
+ }
270
+ }
271
+ ```
272
+
273
+ ## Anti-Patterns to Avoid
274
+
275
+ - Using `GlobalScope` — leaks coroutines, no structured cancellation
276
+ - Collecting Flows in `init {}` without a scope — use `viewModelScope.launch`
277
+ - Using `MutableStateFlow` with mutable collections — always use immutable copies: `_state.update { it.copy(list = it.list + newItem) }`
278
+ - Catching `CancellationException` — let it propagate for proper cancellation
279
+ - Using `flowOn(Dispatchers.Main)` to collect — collection dispatcher is the caller's dispatcher
280
+ - Creating `Flow` in `@Composable` without `remember` — recreates the flow every recomposition
281
+
282
+ ## References
283
+
284
+ See skill: `compose-multiplatform-patterns` for UI consumption of Flows.
285
+ See skill: `android-clean-architecture` for where coroutines fit in layers.