@cubis/foundry 0.3.71 → 0.3.72

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 (270) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cli/core.js +4 -18
  3. package/dist/cli/core.js.map +1 -1
  4. package/package.json +1 -1
  5. package/src/cli/core.ts +4 -18
  6. package/workflows/powers/accessibility/POWER.md +83 -94
  7. package/workflows/powers/accessibility/SKILL.md +82 -94
  8. package/workflows/powers/agent-design/POWER.md +201 -0
  9. package/workflows/powers/agent-design/SKILL.md +198 -0
  10. package/workflows/powers/agent-design/references/clarification-patterns.md +153 -0
  11. package/workflows/powers/agent-design/references/skill-testing.md +164 -0
  12. package/workflows/powers/agent-design/references/workflow-patterns.md +226 -0
  13. package/workflows/powers/agentic-eval/POWER.md +62 -0
  14. package/workflows/powers/agentic-eval/SKILL.md +59 -0
  15. package/workflows/powers/agentic-eval/references/rubric-and-regression-checklist.md +11 -0
  16. package/workflows/powers/api-designer/POWER.md +43 -71
  17. package/workflows/powers/api-designer/SKILL.md +43 -71
  18. package/workflows/powers/api-patterns/POWER.md +42 -56
  19. package/workflows/powers/api-patterns/SKILL.md +42 -57
  20. package/workflows/powers/architecture-designer/POWER.md +43 -60
  21. package/workflows/powers/architecture-designer/SKILL.md +43 -60
  22. package/workflows/powers/ask-questions-if-underspecified/POWER.md +51 -3
  23. package/workflows/powers/auth-architect/POWER.md +69 -0
  24. package/workflows/powers/auth-architect/SKILL.md +66 -0
  25. package/workflows/powers/auth-architect/references/session-token-policy-checklist.md +45 -0
  26. package/workflows/powers/behavioral-modes/POWER.md +100 -9
  27. package/workflows/powers/c-pro/POWER.md +105 -0
  28. package/workflows/powers/c-pro/SKILL.md +102 -0
  29. package/workflows/powers/c-pro/references/build-systems-and-toolchains.md +148 -0
  30. package/workflows/powers/c-pro/references/common-ub-and-portability.md +166 -0
  31. package/workflows/powers/c-pro/references/debugging-with-sanitizers.md +205 -0
  32. package/workflows/powers/c-pro/references/memory-safety-and-build-checklist.md +60 -0
  33. package/workflows/powers/c-pro/references/posix-and-platform-apis.md +244 -0
  34. package/workflows/powers/changelog-generator/POWER.md +127 -63
  35. package/workflows/powers/changelog-generator/SKILL.md +126 -63
  36. package/workflows/powers/ci-cd-pipelines/POWER.md +156 -0
  37. package/workflows/powers/ci-cd-pipelines/SKILL.md +153 -0
  38. package/workflows/powers/ci-cd-pipelines/references/github-actions-patterns.md +160 -0
  39. package/workflows/powers/ci-cd-pipelines/references/pipeline-security-checklist.md +57 -0
  40. package/workflows/powers/cli-developer/POWER.md +152 -95
  41. package/workflows/powers/cli-developer/SKILL.md +152 -95
  42. package/workflows/powers/cpp-pro/POWER.md +111 -0
  43. package/workflows/powers/cpp-pro/SKILL.md +108 -0
  44. package/workflows/powers/cpp-pro/references/concurrency-primitives.md +266 -0
  45. package/workflows/powers/cpp-pro/references/move-semantics-and-value-types.md +149 -0
  46. package/workflows/powers/cpp-pro/references/performance-and-profiling.md +191 -0
  47. package/workflows/powers/cpp-pro/references/raii-and-modern-cpp-checklist.md +87 -0
  48. package/workflows/powers/cpp-pro/references/template-and-concepts-patterns.md +205 -0
  49. package/workflows/powers/csharp-pro/POWER.md +47 -22
  50. package/workflows/powers/csharp-pro/SKILL.md +47 -22
  51. package/workflows/powers/dart-pro/POWER.md +68 -0
  52. package/workflows/powers/dart-pro/SKILL.md +65 -0
  53. package/workflows/powers/dart-pro/references/isolate-and-concurrency.md +180 -0
  54. package/workflows/powers/dart-pro/references/null-safety-and-async-patterns.md +133 -0
  55. package/workflows/powers/dart-pro/references/package-structure-and-linting.md +193 -0
  56. package/workflows/powers/dart-pro/references/sealed-records-patterns.md +173 -0
  57. package/workflows/powers/dart-pro/references/testing-and-mocking.md +235 -0
  58. package/workflows/powers/database-design/POWER.md +47 -33
  59. package/workflows/powers/database-design/SKILL.md +47 -33
  60. package/workflows/powers/database-optimizer/POWER.md +43 -64
  61. package/workflows/powers/database-optimizer/SKILL.md +43 -64
  62. package/workflows/powers/database-skills/POWER.md +59 -93
  63. package/workflows/powers/database-skills/SKILL.md +59 -93
  64. package/workflows/powers/debugging-strategies/POWER.md +69 -0
  65. package/workflows/powers/debugging-strategies/SKILL.md +66 -0
  66. package/workflows/powers/debugging-strategies/references/reproduce-isolate-verify-checklist.md +42 -0
  67. package/workflows/powers/deep-research/POWER.md +67 -0
  68. package/workflows/powers/deep-research/SKILL.md +64 -0
  69. package/workflows/powers/deep-research/references/multi-round-research-loop.md +80 -0
  70. package/workflows/powers/design-system-builder/POWER.md +130 -116
  71. package/workflows/powers/design-system-builder/SKILL.md +130 -116
  72. package/workflows/powers/devops-engineer/POWER.md +120 -57
  73. package/workflows/powers/devops-engineer/SKILL.md +120 -57
  74. package/workflows/powers/docker-kubernetes/POWER.md +94 -0
  75. package/workflows/powers/docker-kubernetes/SKILL.md +91 -0
  76. package/workflows/powers/docker-kubernetes/references/dockerfile-optimization-checklist.md +35 -0
  77. package/workflows/powers/docker-kubernetes/references/kubernetes-deployment-patterns.md +59 -0
  78. package/workflows/powers/documentation-templates/POWER.md +158 -127
  79. package/workflows/powers/documentation-templates/SKILL.md +158 -127
  80. package/workflows/powers/drizzle-expert/POWER.md +66 -0
  81. package/workflows/powers/drizzle-expert/SKILL.md +63 -0
  82. package/workflows/powers/drizzle-expert/references/runtime-pairing-matrix.md +16 -0
  83. package/workflows/powers/drizzle-expert/references/schema-and-migration-playbook.md +18 -0
  84. package/workflows/powers/error-ux-observability/POWER.md +144 -131
  85. package/workflows/powers/error-ux-observability/SKILL.md +143 -131
  86. package/workflows/powers/fastapi-expert/POWER.md +46 -60
  87. package/workflows/powers/fastapi-expert/SKILL.md +46 -60
  88. package/workflows/powers/firebase/POWER.md +65 -0
  89. package/workflows/powers/firebase/SKILL.md +62 -0
  90. package/workflows/powers/firebase/references/platform-routing.md +16 -0
  91. package/workflows/powers/firebase/references/rules-and-indexes-checklist.md +11 -0
  92. package/workflows/powers/flutter-design-system/POWER.md +63 -0
  93. package/workflows/powers/flutter-design-system/SKILL.md +60 -0
  94. package/workflows/powers/flutter-design-system/references/shared-widgets.md +29 -0
  95. package/workflows/powers/flutter-design-system/references/tokens-and-theme.md +34 -0
  96. package/workflows/powers/flutter-drift/POWER.md +65 -0
  97. package/workflows/powers/flutter-drift/SKILL.md +62 -0
  98. package/workflows/powers/flutter-drift/references/migrations.md +22 -0
  99. package/workflows/powers/flutter-drift/references/query-patterns.md +26 -0
  100. package/workflows/powers/flutter-feature/POWER.md +65 -0
  101. package/workflows/powers/flutter-feature/SKILL.md +62 -0
  102. package/workflows/powers/flutter-feature/references/architecture-rules.md +85 -0
  103. package/workflows/powers/flutter-feature/references/composite-provider.md +58 -0
  104. package/workflows/powers/flutter-feature/references/outbox-pattern.md +87 -0
  105. package/workflows/powers/flutter-feature/references/testing-patterns.md +218 -0
  106. package/workflows/powers/flutter-go-router/POWER.md +64 -0
  107. package/workflows/powers/flutter-go-router/SKILL.md +61 -0
  108. package/workflows/powers/flutter-go-router/references/guards-and-deeplinks.md +20 -0
  109. package/workflows/powers/flutter-go-router/references/typed-routes.md +27 -0
  110. package/workflows/powers/flutter-offline-sync/POWER.md +62 -0
  111. package/workflows/powers/flutter-offline-sync/SKILL.md +59 -0
  112. package/workflows/powers/flutter-offline-sync/references/outbox-full.md +44 -0
  113. package/workflows/powers/flutter-repository/POWER.md +64 -0
  114. package/workflows/powers/flutter-repository/SKILL.md +61 -0
  115. package/workflows/powers/flutter-repository/references/drift-patterns.md +21 -0
  116. package/workflows/powers/flutter-repository/references/retrofit-patterns.md +20 -0
  117. package/workflows/powers/flutter-riverpod/POWER.md +70 -0
  118. package/workflows/powers/flutter-riverpod/SKILL.md +67 -0
  119. package/workflows/powers/flutter-riverpod/references/async-and-mutations.md +19 -0
  120. package/workflows/powers/flutter-riverpod/references/async-lifecycle.md +19 -0
  121. package/workflows/powers/flutter-riverpod/references/provider-selection.md +20 -0
  122. package/workflows/powers/flutter-riverpod/references/testing.md +21 -0
  123. package/workflows/powers/flutter-riverpod/references/version-matrix.md +24 -0
  124. package/workflows/powers/flutter-state-machine/POWER.md +62 -0
  125. package/workflows/powers/flutter-state-machine/SKILL.md +59 -0
  126. package/workflows/powers/flutter-state-machine/references/app-state-contract.md +23 -0
  127. package/workflows/powers/flutter-state-machine/references/ui-rendering.md +14 -0
  128. package/workflows/powers/flutter-testing/POWER.md +64 -0
  129. package/workflows/powers/flutter-testing/SKILL.md +61 -0
  130. package/workflows/powers/flutter-testing/references/offline-sync-tests.md +16 -0
  131. package/workflows/powers/flutter-testing/references/test-layers.md +33 -0
  132. package/workflows/powers/frontend-code-review/POWER.md +137 -0
  133. package/workflows/powers/frontend-code-review/SKILL.md +134 -0
  134. package/workflows/powers/frontend-code-review/references/common-antipatterns.md +86 -0
  135. package/workflows/powers/frontend-code-review/references/performance-budgets.md +56 -0
  136. package/workflows/powers/frontend-code-review/references/review-checklists.md +47 -0
  137. package/workflows/powers/frontend-design/POWER.md +163 -362
  138. package/workflows/powers/frontend-design/SKILL.md +163 -362
  139. package/workflows/powers/game-development/POWER.md +57 -140
  140. package/workflows/powers/game-development/SKILL.md +57 -140
  141. package/workflows/powers/geo-fundamentals/POWER.md +64 -126
  142. package/workflows/powers/geo-fundamentals/SKILL.md +64 -127
  143. package/workflows/powers/git-workflow/POWER.md +135 -0
  144. package/workflows/powers/git-workflow/SKILL.md +132 -0
  145. package/workflows/powers/git-workflow/references/pr-review-checklist.md +63 -0
  146. package/workflows/powers/golang-pro/POWER.md +46 -35
  147. package/workflows/powers/golang-pro/SKILL.md +46 -35
  148. package/workflows/powers/graphql-architect/POWER.md +44 -62
  149. package/workflows/powers/graphql-architect/SKILL.md +44 -62
  150. package/workflows/powers/i18n-localization/POWER.md +118 -103
  151. package/workflows/powers/i18n-localization/SKILL.md +118 -103
  152. package/workflows/powers/java-pro/POWER.md +47 -22
  153. package/workflows/powers/java-pro/SKILL.md +47 -22
  154. package/workflows/powers/javascript-pro/POWER.md +47 -34
  155. package/workflows/powers/javascript-pro/SKILL.md +47 -34
  156. package/workflows/powers/kotlin-pro/POWER.md +46 -23
  157. package/workflows/powers/kotlin-pro/SKILL.md +46 -23
  158. package/workflows/powers/legacy-modernizer/POWER.md +43 -60
  159. package/workflows/powers/legacy-modernizer/SKILL.md +43 -60
  160. package/workflows/powers/mcp-builder/POWER.md +65 -0
  161. package/workflows/powers/mcp-builder/SKILL.md +62 -0
  162. package/workflows/powers/mcp-builder/references/testing-and-evals.md +17 -0
  163. package/workflows/powers/mcp-builder/references/transport-and-tool-design.md +17 -0
  164. package/workflows/powers/microservices-architect/POWER.md +43 -70
  165. package/workflows/powers/microservices-architect/SKILL.md +43 -70
  166. package/workflows/powers/mobile-design/POWER.md +110 -345
  167. package/workflows/powers/mobile-design/SKILL.md +110 -345
  168. package/workflows/powers/mongodb/POWER.md +67 -0
  169. package/workflows/powers/mongodb/SKILL.md +64 -0
  170. package/workflows/powers/mongodb/references/mongodb-checklist.md +20 -0
  171. package/workflows/powers/mysql/POWER.md +67 -0
  172. package/workflows/powers/mysql/SKILL.md +64 -0
  173. package/workflows/powers/mysql/references/mysql-checklist.md +20 -0
  174. package/workflows/powers/neki/POWER.md +67 -0
  175. package/workflows/powers/neki/SKILL.md +64 -0
  176. package/workflows/powers/neki/references/neki-checklist.md +18 -0
  177. package/workflows/powers/nestjs-expert/POWER.md +45 -91
  178. package/workflows/powers/nestjs-expert/SKILL.md +45 -91
  179. package/workflows/powers/nextjs-developer/POWER.md +51 -44
  180. package/workflows/powers/nextjs-developer/SKILL.md +51 -44
  181. package/workflows/powers/nodejs-best-practices/POWER.md +48 -29
  182. package/workflows/powers/nodejs-best-practices/SKILL.md +48 -29
  183. package/workflows/powers/observability/POWER.md +109 -0
  184. package/workflows/powers/observability/SKILL.md +106 -0
  185. package/workflows/powers/observability/references/alerting-and-slo-checklist.md +87 -0
  186. package/workflows/powers/observability/references/opentelemetry-setup-guide.md +121 -0
  187. package/workflows/powers/openai-docs/POWER.md +61 -0
  188. package/workflows/powers/openai-docs/SKILL.md +58 -0
  189. package/workflows/powers/openai-docs/references/official-source-playbook.md +10 -0
  190. package/workflows/powers/performance-profiling/POWER.md +61 -114
  191. package/workflows/powers/performance-profiling/SKILL.md +61 -114
  192. package/workflows/powers/php-pro/POWER.md +116 -0
  193. package/workflows/powers/php-pro/SKILL.md +113 -0
  194. package/workflows/powers/php-pro/references/architecture-and-di.md +239 -0
  195. package/workflows/powers/php-pro/references/modern-php-features.md +189 -0
  196. package/workflows/powers/php-pro/references/performance-and-deployment.md +197 -0
  197. package/workflows/powers/php-pro/references/php84-strict-typing-checklist.md +161 -0
  198. package/workflows/powers/php-pro/references/testing-and-static-analysis.md +235 -0
  199. package/workflows/powers/playwright-e2e/POWER.md +85 -0
  200. package/workflows/powers/playwright-e2e/SKILL.md +82 -0
  201. package/workflows/powers/playwright-e2e/references/locator-trace-flake-checklist.md +80 -0
  202. package/workflows/powers/postgres/POWER.md +67 -0
  203. package/workflows/powers/postgres/SKILL.md +64 -0
  204. package/workflows/powers/postgres/references/postgres-checklist.md +20 -0
  205. package/workflows/powers/prompt-engineer/POWER.md +47 -30
  206. package/workflows/powers/prompt-engineer/SKILL.md +47 -30
  207. package/workflows/powers/python-pro/POWER.md +47 -36
  208. package/workflows/powers/python-pro/SKILL.md +47 -36
  209. package/workflows/powers/react-best-practices/POWER.md +56 -33
  210. package/workflows/powers/react-best-practices/SKILL.md +56 -33
  211. package/workflows/powers/react-expert/POWER.md +47 -37
  212. package/workflows/powers/react-expert/SKILL.md +47 -37
  213. package/workflows/powers/redis/POWER.md +67 -0
  214. package/workflows/powers/redis/SKILL.md +64 -0
  215. package/workflows/powers/redis/references/redis-checklist.md +19 -0
  216. package/workflows/powers/ruby-pro/POWER.md +118 -0
  217. package/workflows/powers/ruby-pro/SKILL.md +115 -0
  218. package/workflows/powers/ruby-pro/references/modern-ruby-features.md +189 -0
  219. package/workflows/powers/ruby-pro/references/object-design-patterns.md +220 -0
  220. package/workflows/powers/ruby-pro/references/performance-and-profiling.md +224 -0
  221. package/workflows/powers/ruby-pro/references/ruby-concurrency-and-testing.md +190 -0
  222. package/workflows/powers/ruby-pro/references/testing-and-rspec.md +236 -0
  223. package/workflows/powers/rust-pro/POWER.md +45 -31
  224. package/workflows/powers/rust-pro/SKILL.md +45 -31
  225. package/workflows/powers/security-engineer/POWER.md +129 -0
  226. package/workflows/powers/security-engineer/SKILL.md +126 -0
  227. package/workflows/powers/seo-fundamentals/POWER.md +59 -102
  228. package/workflows/powers/seo-fundamentals/SKILL.md +59 -102
  229. package/workflows/powers/serverless-patterns/POWER.md +171 -0
  230. package/workflows/powers/serverless-patterns/SKILL.md +168 -0
  231. package/workflows/powers/skill-creator/POWER.md +90 -0
  232. package/workflows/powers/skill-creator/SKILL.md +87 -0
  233. package/workflows/powers/skill-creator/references/platform-formats.md +181 -0
  234. package/workflows/powers/skill-creator/references/schemas.md +430 -0
  235. package/workflows/powers/spec-miner/POWER.md +49 -57
  236. package/workflows/powers/spec-miner/SKILL.md +49 -57
  237. package/workflows/powers/sqlite/POWER.md +67 -0
  238. package/workflows/powers/sqlite/SKILL.md +64 -0
  239. package/workflows/powers/sqlite/references/sqlite-checklist.md +19 -0
  240. package/workflows/powers/sre-engineer/POWER.md +123 -64
  241. package/workflows/powers/sre-engineer/SKILL.md +123 -64
  242. package/workflows/powers/static-analysis/POWER.md +121 -77
  243. package/workflows/powers/static-analysis/SKILL.md +121 -77
  244. package/workflows/powers/stripe-best-practices/POWER.md +140 -17
  245. package/workflows/powers/stripe-best-practices/SKILL.md +139 -17
  246. package/workflows/powers/supabase/POWER.md +67 -0
  247. package/workflows/powers/supabase/SKILL.md +64 -0
  248. package/workflows/powers/supabase/references/supabase-checklist.md +19 -0
  249. package/workflows/powers/swift-pro/POWER.md +118 -0
  250. package/workflows/powers/swift-pro/SKILL.md +115 -0
  251. package/workflows/powers/swift-pro/references/concurrency-patterns.md +165 -0
  252. package/workflows/powers/swift-pro/references/protocol-and-generics.md +172 -0
  253. package/workflows/powers/swift-pro/references/sendable-and-isolation.md +116 -0
  254. package/workflows/powers/swift-pro/references/swift-concurrency-and-protocols.md +260 -0
  255. package/workflows/powers/swift-pro/references/testing-and-packages.md +192 -0
  256. package/workflows/powers/tailwind-patterns/POWER.md +71 -240
  257. package/workflows/powers/tailwind-patterns/SKILL.md +71 -240
  258. package/workflows/powers/testing-patterns/POWER.md +155 -10
  259. package/workflows/powers/testing-patterns/SKILL.md +155 -10
  260. package/workflows/powers/typescript-pro/POWER.md +47 -38
  261. package/workflows/powers/typescript-pro/SKILL.md +47 -38
  262. package/workflows/powers/vitess/POWER.md +67 -0
  263. package/workflows/powers/vitess/SKILL.md +64 -0
  264. package/workflows/powers/vitess/references/vitess-checklist.md +19 -0
  265. package/workflows/powers/vulnerability-scanner/POWER.md +146 -10
  266. package/workflows/powers/vulnerability-scanner/SKILL.md +146 -10
  267. package/workflows/powers/web-perf/POWER.md +43 -170
  268. package/workflows/powers/web-perf/SKILL.md +43 -170
  269. package/workflows/powers/webapp-testing/POWER.md +43 -164
  270. package/workflows/powers/webapp-testing/SKILL.md +43 -164
@@ -0,0 +1,192 @@
1
+ # Testing and Packages
2
+
3
+ ## Swift Testing framework
4
+
5
+ ### Basic test structure
6
+
7
+ ```swift
8
+ import Testing
9
+
10
+ @Test("User creation sets default role")
11
+ func userCreationDefault() {
12
+ let user = User(name: "Alice")
13
+ #expect(user.role == .viewer)
14
+ }
15
+
16
+ @Test("Deposit increases balance")
17
+ func depositIncreasesBalance() async throws {
18
+ let account = BankAccount(balance: 100)
19
+ try await account.deposit(50)
20
+ let balance = await account.balance
21
+ #expect(balance == 150)
22
+ }
23
+ ```
24
+
25
+ - Use `@Test` attribute with descriptive display names.
26
+ - Use `#expect` for assertions — clearer failure messages than XCTest.
27
+ - Use `#require` for preconditions that should abort the test on failure.
28
+
29
+ ### Parameterized tests
30
+
31
+ ```swift
32
+ @Test("Parse valid integers", arguments: [
33
+ ("42", 42),
34
+ ("-1", -1),
35
+ ("0", 0),
36
+ ])
37
+ func parseValid(input: String, expected: Int) throws {
38
+ let result = try parse(input)
39
+ #expect(result == expected)
40
+ }
41
+ ```
42
+
43
+ - Use `arguments:` to run the same test logic across multiple inputs.
44
+ - Each argument combination runs as a separate test case with individual pass/fail.
45
+
46
+ ### Test organization with suites
47
+
48
+ ```swift
49
+ @Suite("User Repository")
50
+ struct UserRepositoryTests {
51
+ let repo: MockUserRepository
52
+
53
+ init() {
54
+ repo = MockUserRepository()
55
+ }
56
+
57
+ @Test func findExistingUser() async throws {
58
+ repo.seed(User(id: 1, name: "Alice"))
59
+ let user = try await repo.find(id: 1)
60
+ #expect(user?.name == "Alice")
61
+ }
62
+
63
+ @Test func findMissingReturnsNil() async throws {
64
+ let user = try await repo.find(id: 999)
65
+ #expect(user == nil)
66
+ }
67
+ }
68
+ ```
69
+
70
+ - `@Suite` groups related tests with shared setup in `init()`.
71
+ - Each test gets a fresh instance — no shared mutable state between tests.
72
+
73
+ ### Testing async and actor code
74
+
75
+ ```swift
76
+ @Test func actorStateUpdates() async {
77
+ let cache = ImageCache()
78
+ await cache.store(image, forKey: "logo")
79
+ let retrieved = await cache.get("logo")
80
+ #expect(retrieved != nil)
81
+ }
82
+
83
+ // Test expected errors
84
+ @Test func withdrawInsufficientFunds() async {
85
+ let account = BankAccount(balance: 50)
86
+ await #expect(throws: BankError.insufficientFunds) {
87
+ try await account.withdraw(100)
88
+ }
89
+ }
90
+ ```
91
+
92
+ ### Confirmation for event-driven behavior
93
+
94
+ ```swift
95
+ @Test func notificationFired() async {
96
+ await confirmation("User saved notification") { confirm in
97
+ let observer = NotificationCenter.default.addObserver(
98
+ forName: .userSaved, object: nil, queue: nil
99
+ ) { _ in
100
+ confirm()
101
+ }
102
+ await service.saveUser(user)
103
+ NotificationCenter.default.removeObserver(observer)
104
+ }
105
+ }
106
+ ```
107
+
108
+ ## Dependency injection for tests
109
+
110
+ ### Protocol-based injection
111
+
112
+ ```swift
113
+ protocol NetworkClient: Sendable {
114
+ func data(from url: URL) async throws -> (Data, URLResponse)
115
+ }
116
+
117
+ // Production
118
+ struct URLSessionClient: NetworkClient {
119
+ func data(from url: URL) async throws -> (Data, URLResponse) {
120
+ try await URLSession.shared.data(from: url)
121
+ }
122
+ }
123
+
124
+ // Test
125
+ struct MockNetworkClient: NetworkClient {
126
+ var responses: [URL: (Data, URLResponse)] = [:]
127
+
128
+ func data(from url: URL) async throws -> (Data, URLResponse) {
129
+ guard let response = responses[url] else {
130
+ throw URLError(.badURL)
131
+ }
132
+ return response
133
+ }
134
+ }
135
+
136
+ // Injection
137
+ class UserService {
138
+ private let network: NetworkClient
139
+
140
+ init(network: NetworkClient = URLSessionClient()) {
141
+ self.network = network
142
+ }
143
+ }
144
+ ```
145
+
146
+ - Inject dependencies through initializer parameters with production defaults.
147
+ - Keep mock types simple — only implement what the test needs.
148
+ - Avoid mocking frameworks unless the mock implementation becomes complex.
149
+
150
+ ## Package.swift module organization
151
+
152
+ ### Multi-target package
153
+
154
+ ```swift
155
+ // swift-tools-version: 6.0
156
+ import PackageDescription
157
+
158
+ let package = Package(
159
+ name: "MyApp",
160
+ platforms: [.iOS(.v17), .macOS(.v14)],
161
+ products: [
162
+ .library(name: "Domain", targets: ["Domain"]),
163
+ .library(name: "Networking", targets: ["Networking"]),
164
+ ],
165
+ dependencies: [
166
+ .package(url: "https://github.com/apple/swift-algorithms", from: "1.2.0"),
167
+ ],
168
+ targets: [
169
+ // Core domain — no external dependencies
170
+ .target(name: "Domain"),
171
+
172
+ // Networking depends on Domain
173
+ .target(name: "Networking", dependencies: ["Domain"]),
174
+
175
+ // Tests
176
+ .testTarget(name: "DomainTests", dependencies: ["Domain"]),
177
+ .testTarget(name: "NetworkingTests", dependencies: [
178
+ "Networking",
179
+ .product(name: "Algorithms", package: "swift-algorithms"),
180
+ ]),
181
+ ]
182
+ )
183
+ ```
184
+
185
+ ### Package organization guidelines
186
+
187
+ - Keep `Domain` (models, protocols, business logic) as a standalone target with zero external dependencies.
188
+ - Put I/O, networking, and persistence in separate targets that depend on `Domain`.
189
+ - Use `@testable import` only in test targets.
190
+ - Pin dependency versions with `.upToNextMinor(from:)` for stability. Use `.upToNextMajor(from:)` only for well-trusted packages.
191
+ - Keep `Package.resolved` in version control for applications. Omit it for library packages.
192
+ - Use conditional compilation (`#if canImport(UIKit)`) for platform-specific code in multi-platform targets.
@@ -2,271 +2,102 @@
2
2
  ---
3
3
  inclusion: manual
4
4
  name: tailwind-patterns
5
- description: Tailwind CSS v4 principles. CSS-first configuration, container queries, modern patterns, design token architecture.
6
- allowed-tools: Read, Write, Edit, Glob, Grep
5
+ description: "Use for Tailwind CSS v4 architecture, CSS-first theme setup, utility composition, container-query usage, design-token hygiene, and dark-mode strategy."
6
+ license: MIT
7
+ metadata:
8
+ author: cubis-foundry
9
+ version: "4.0"
10
+ compatibility: Claude Code, Codex, GitHub Copilot
7
11
  ---
8
12
 
9
- # Tailwind CSS Patterns (v4 - 2025)
13
+ # Tailwind Patterns
10
14
 
11
- > Modern utility-first CSS with CSS-native configuration.
15
+ ## Purpose
12
16
 
13
- ---
14
-
15
- ## 1. Tailwind v4 Architecture
16
-
17
- ### What Changed from v3
18
-
19
- | v3 (Legacy) | v4 (Current) |
20
- |-------------|--------------|
21
- | `tailwind.config.js` | CSS-based `@theme` directive |
22
- | PostCSS plugin | Oxide engine (10x faster) |
23
- | JIT mode | Native, always-on |
24
- | Plugin system | CSS-native features |
25
- | `@apply` directive | Still works, discouraged |
26
-
27
- ### v4 Core Concepts
28
-
29
- | Concept | Description |
30
- |---------|-------------|
31
- | **CSS-first** | Configuration in CSS, not JavaScript |
32
- | **Oxide Engine** | Rust-based compiler, much faster |
33
- | **Native Nesting** | CSS nesting without PostCSS |
34
- | **CSS Variables** | All tokens exposed as `--*` vars |
35
-
36
- ---
37
-
38
- ## 2. CSS-Based Configuration
39
-
40
- ### Theme Definition
41
-
42
- ```
43
- @theme {
44
- /* Colors - use semantic names */
45
- --color-primary: oklch(0.7 0.15 250);
46
- --color-surface: oklch(0.98 0 0);
47
- --color-surface-dark: oklch(0.15 0 0);
48
-
49
- /* Spacing scale */
50
- --spacing-xs: 0.25rem;
51
- --spacing-sm: 0.5rem;
52
- --spacing-md: 1rem;
53
- --spacing-lg: 2rem;
54
-
55
- /* Typography */
56
- --font-sans: 'Inter', system-ui, sans-serif;
57
- --font-mono: 'JetBrains Mono', monospace;
58
- }
59
- ```
60
-
61
- ### When to Extend vs Override
62
-
63
- | Action | Use When |
64
- |--------|----------|
65
- | **Extend** | Adding new values alongside defaults |
66
- | **Override** | Replacing default scale entirely |
67
- | **Semantic tokens** | Project-specific naming (primary, surface) |
68
-
69
- ---
70
-
71
- ## 3. Container Queries (v4 Native)
72
-
73
- ### Breakpoint vs Container
74
-
75
- | Type | Responds To |
76
- |------|-------------|
77
- | **Breakpoint** (`md:`) | Viewport width |
78
- | **Container** (`@container`) | Parent element width |
79
-
80
- ### Container Query Usage
81
-
82
- | Pattern | Classes |
83
- |---------|---------|
84
- | Define container | `@container` on parent |
85
- | Container breakpoint | `@sm:`, `@md:`, `@lg:` on children |
86
- | Named containers | `@container/card` for specificity |
87
-
88
- ### When to Use
89
-
90
- | Scenario | Use |
91
- |----------|-----|
92
- | Page-level layouts | Viewport breakpoints |
93
- | Component-level responsive | Container queries |
94
- | Reusable components | Container queries (context-independent) |
95
-
96
- ---
97
-
98
- ## 4. Responsive Design
99
-
100
- ### Breakpoint System
101
-
102
- | Prefix | Min Width | Target |
103
- |--------|-----------|--------|
104
- | (none) | 0px | Mobile-first base |
105
- | `sm:` | 640px | Large phone / small tablet |
106
- | `md:` | 768px | Tablet |
107
- | `lg:` | 1024px | Laptop |
108
- | `xl:` | 1280px | Desktop |
109
- | `2xl:` | 1536px | Large desktop |
110
-
111
- ### Mobile-First Principle
112
-
113
- 1. Write mobile styles first (no prefix)
114
- 2. Add larger screen overrides with prefixes
115
- 3. Example: `w-full md:w-1/2 lg:w-1/3`
116
-
117
- ---
118
-
119
- ## 5. Dark Mode
120
-
121
- ### Configuration Strategies
122
-
123
- | Method | Behavior | Use When |
124
- |--------|----------|----------|
125
- | `class` | `.dark` class toggles | Manual theme switcher |
126
- | `media` | Follows system preference | No user control |
127
- | `selector` | Custom selector (v4) | Complex theming |
128
-
129
- ### Dark Mode Pattern
130
-
131
- | Element | Light | Dark |
132
- |---------|-------|------|
133
- | Background | `bg-white` | `dark:bg-zinc-900` |
134
- | Text | `text-zinc-900` | `dark:text-zinc-100` |
135
- | Borders | `border-zinc-200` | `dark:border-zinc-700` |
136
-
137
- ---
138
-
139
- ## 6. Modern Layout Patterns
140
-
141
- ### Flexbox Patterns
142
-
143
- | Pattern | Classes |
144
- |---------|---------|
145
- | Center (both axes) | `flex items-center justify-center` |
146
- | Vertical stack | `flex flex-col gap-4` |
147
- | Horizontal row | `flex gap-4` |
148
- | Space between | `flex justify-between items-center` |
149
- | Wrap grid | `flex flex-wrap gap-4` |
150
-
151
- ### Grid Patterns
152
-
153
- | Pattern | Classes |
154
- |---------|---------|
155
- | Auto-fit responsive | `grid grid-cols-[repeat(auto-fit,minmax(250px,1fr))]` |
156
- | Asymmetric (Bento) | `grid grid-cols-3 grid-rows-2` with spans |
157
- | Sidebar layout | `grid grid-cols-[auto_1fr]` |
158
-
159
- > **Note:** Prefer asymmetric/Bento layouts over symmetric 3-column grids.
160
-
161
- ---
162
-
163
- ## 7. Modern Color System
164
-
165
- ### OKLCH vs RGB/HSL
166
-
167
- | Format | Advantage |
168
- |--------|-----------|
169
- | **OKLCH** | Perceptually uniform, better for design |
170
- | **HSL** | Intuitive hue/saturation |
171
- | **RGB** | Legacy compatibility |
17
+ Use for Tailwind CSS v4 architecture, CSS-first theme setup, utility composition, container-query usage, design-token hygiene, and dark-mode strategy.
172
18
 
173
- ### Color Token Architecture
19
+ ## When to Use
174
20
 
175
- | Layer | Example | Purpose |
176
- |-------|---------|---------|
177
- | **Primitive** | `--blue-500` | Raw color values |
178
- | **Semantic** | `--color-primary` | Purpose-based naming |
179
- | **Component** | `--button-bg` | Component-specific |
21
+ - Building or refactoring Tailwind-based UI systems.
22
+ - Choosing theme token structure and CSS-first configuration.
23
+ - Applying container queries, responsive composition, and utility extraction.
24
+ - Reviewing class composition for maintainability and scale.
25
+ - Setting up dark mode, color-scheme toggling, or multi-theme systems.
26
+ - Optimizing Tailwind output for production bundle size.
180
27
 
181
- ---
28
+ ## Instructions
182
29
 
183
- ## 8. Typography System
30
+ 1. Confirm whether the codebase is truly Tailwind-first and which v4 features are active.
31
+ 2. Establish semantic tokens (color, spacing, type, radius) before piling on utilities.
32
+ 3. Define dark-mode and color-scheme strategy at the theme level, not per-component.
33
+ 4. Use responsive and container-query rules deliberately at the component boundary.
34
+ 5. Extract repeated patterns only when reuse and readability clearly improve.
35
+ 6. Verify the result stays readable, consistent, and easy to extend.
184
36
 
185
- ### Font Stack Pattern
37
+ ### Baseline standards
186
38
 
187
- | Type | Recommended |
188
- |------|-------------|
189
- | Sans | `'Inter', 'SF Pro', system-ui, sans-serif` |
190
- | Mono | `'JetBrains Mono', 'Fira Code', monospace` |
191
- | Display | `'Outfit', 'Poppins', sans-serif` |
39
+ - Prefer CSS-first theme and token definition in v4-era setups.
40
+ - Keep utility composition semantic at the component boundary.
41
+ - Use container queries for component context, not everything.
42
+ - Treat arbitrary values as exceptions, not the system.
43
+ - Keep spacing, typography, and color scales coherent.
44
+ - Define dark mode via `@custom-variant` or built-in `dark:` — never inline JavaScript toggling of raw classes.
45
+ - Use CSS custom properties for tokens that need runtime switching.
192
46
 
193
- ### Type Scale
47
+ ### Implementation guidance
194
48
 
195
- | Class | Size | Use |
196
- |-------|------|-----|
197
- | `text-xs` | 0.75rem | Labels, captions |
198
- | `text-sm` | 0.875rem | Secondary text |
199
- | `text-base` | 1rem | Body text |
200
- | `text-lg` | 1.125rem | Lead text |
201
- | `text-xl`+ | 1.25rem+ | Headings |
49
+ - Use `@theme` blocks to define design tokens as CSS custom properties.
50
+ - Prefer `@layer` directives to control specificity ordering.
51
+ - Use `@variant` for semantic state grouping (e.g., `@variant hover, focus-visible`).
52
+ - Keep component-level `@apply` usage to shared design-system primitives, not arbitrary shortcuts.
53
+ - Use `@container` at the component wrapper level with named containers for clarity.
54
+ - Compose responsive with container queries: responsive for page layout, container queries for component-internal layout.
202
55
 
203
- ---
56
+ ### Dark mode and theming
204
57
 
205
- ## 9. Animation & Transitions
58
+ - Define color tokens as HSL or OKLCH custom properties for easy theme switching.
59
+ - Use `@custom-variant dark` with a class or media-query strategy — pick one per project and enforce it.
60
+ - Keep contrast ratios WCAG AA minimum (4.5:1 text, 3:1 large text / UI).
61
+ - Test both themes with real content, not just color swatches.
206
62
 
207
- ### Built-in Animations
63
+ ### Performance and production
208
64
 
209
- | Class | Effect |
210
- |-------|--------|
211
- | `animate-spin` | Continuous rotation |
212
- | `animate-ping` | Attention pulse |
213
- | `animate-pulse` | Subtle opacity pulse |
214
- | `animate-bounce` | Bouncing effect |
65
+ - Purge unused styles by keeping utility usage in template files Tailwind can scan.
66
+ - Avoid dynamic class construction (`bg-${color}-500`) — Tailwind cannot detect these at build time.
67
+ - Keep `@apply` chains short long chains defeat tree-shaking.
68
+ - Use `content` configuration to limit scan scope in monorepos.
69
+ - Prefer targeted `@import` over importing the entire Tailwind base when only utilities are needed.
215
70
 
216
- ### Transition Patterns
71
+ ### Constraints
217
72
 
218
- | Pattern | Classes |
219
- |---------|---------|
220
- | All properties | `transition-all duration-200` |
221
- | Specific | `transition-colors duration-150` |
222
- | With easing | `ease-out` or `ease-in-out` |
223
- | Hover effect | `hover:scale-105 transition-transform` |
73
+ - Avoid dumping arbitrary values into every class list.
74
+ - Avoid mixing old config habits into a CSS-first setup without reason.
75
+ - Avoid repeating long class strings when a component or token should exist.
76
+ - Avoid styling choices that fight the design system instead of clarifying it.
77
+ - Avoid dynamic class name construction that breaks purge scanning.
78
+ - Avoid overriding Tailwind with inline styles or `!important` instead of fixing token conflicts.
79
+ - Avoid using `@apply` with responsive or state variants — compose those in the template.
224
80
 
225
- ---
81
+ ## Output Format
226
82
 
227
- ## 10. Component Extraction
83
+ Provide implementation guidance, code examples, and configuration as appropriate to the task.
228
84
 
229
- ### When to Extract
85
+ ## References
230
86
 
231
- | Signal | Action |
232
- |--------|--------|
233
- | Same class combo 3+ times | Extract component |
234
- | Complex state variants | Extract component |
235
- | Design system element | Extract + document |
87
+ Load on demand. Do not preload all reference files.
236
88
 
237
- ### Extraction Methods
89
+ | File | Load when |
90
+ | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
91
+ | `references/token-and-composition-checklist.md` | You need deeper Tailwind guidance for v4 token setup, utility composition, container queries, and class extraction rules. |
92
+ | `references/dark-mode-and-theming-guide.md` | The task involves dark mode setup, multi-theme systems, color-scheme toggling, or OKLCH token architecture. |
93
+ | `references/performance-and-purge-checklist.md` | The task involves production build optimization, bundle size reduction, or monorepo content configuration. |
238
94
 
239
- | Method | Use When |
240
- |--------|----------|
241
- | **React/Vue component** | Dynamic, JS needed |
242
- | **@apply in CSS** | Static, no JS needed |
243
- | **Design tokens** | Reusable values |
95
+ ## Scripts
244
96
 
245
- ---
97
+ No helper scripts are required for this skill right now. Keep execution in `SKILL.md` and `references/` unless repeated automation becomes necessary.
246
98
 
247
- ## 11. Anti-Patterns
248
-
249
- | Don't | Do |
250
- |-------|-----|
251
- | Arbitrary values everywhere | Use design system scale |
252
- | `!important` | Fix specificity properly |
253
- | Inline `style=` | Use utilities |
254
- | Duplicate long class lists | Extract component |
255
- | Mix v3 config with v4 | Migrate fully to CSS-first |
256
- | Use `@apply` heavily | Prefer components |
257
-
258
- ---
259
-
260
- ## 12. Performance Principles
261
-
262
- | Principle | Implementation |
263
- |-----------|----------------|
264
- | **Purge unused** | Automatic in v4 |
265
- | **Avoid dynamism** | No template string classes |
266
- | **Use Oxide** | Default in v4, 10x faster |
267
- | **Cache builds** | CI/CD caching |
268
-
269
- ---
99
+ ## Examples
270
100
 
271
- > **Remember:** Tailwind v4 is CSS-first. Embrace CSS variables, container queries, and native features. The config file is now optional.
101
+ - "Help me with tailwind patterns best practices in this project"
102
+ - "Review my tailwind patterns implementation for issues"
272
103
  ````