@sylix/coworker 2.0.10 → 2.0.12

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 (178) hide show
  1. package/dist/commands/slash/config.d.ts.map +1 -1
  2. package/dist/commands/slash/config.js +23 -5
  3. package/dist/commands/slash/config.js.map +1 -1
  4. package/dist/commands/slash/todo.js +1 -1
  5. package/dist/commands/slash/todo.js.map +1 -1
  6. package/dist/core/CoWorkerAgent.d.ts.map +1 -1
  7. package/dist/core/CoWorkerAgent.js +6 -3
  8. package/dist/core/CoWorkerAgent.js.map +1 -1
  9. package/dist/permissions/PermissionInterceptor.js +1 -1
  10. package/dist/permissions/PermissionInterceptor.js.map +1 -1
  11. package/dist/skills/defaults/accessibility/screen-reader-testing.md +545 -0
  12. package/dist/skills/defaults/accessibility/wcag-audit-patterns.md +555 -0
  13. package/dist/skills/defaults/ai-ml/rag.md +276 -0
  14. package/dist/skills/defaults/backend-development/api-design-principles.md +528 -0
  15. package/dist/skills/defaults/backend-development/api-design.md +285 -0
  16. package/dist/skills/defaults/backend-development/architecture-patterns.md +494 -0
  17. package/dist/skills/defaults/backend-development/async-python.md +237 -0
  18. package/dist/skills/defaults/backend-development/auth-implementation-patterns.md +638 -0
  19. package/dist/skills/defaults/backend-development/bazel-build-optimization.md +387 -0
  20. package/dist/skills/defaults/backend-development/billing-automation/SKILL.md +566 -0
  21. package/dist/skills/defaults/backend-development/code-review-excellence.md +538 -0
  22. package/dist/skills/defaults/backend-development/cqrs-implementation.md +554 -0
  23. package/dist/skills/defaults/backend-development/database-design.md +305 -0
  24. package/dist/skills/defaults/backend-development/debugging-strategies.md +536 -0
  25. package/dist/skills/defaults/backend-development/e2e-testing-patterns.md +544 -0
  26. package/dist/skills/defaults/backend-development/error-handling-patterns.md +641 -0
  27. package/dist/skills/defaults/backend-development/fastapi-templates.md +559 -0
  28. package/dist/skills/defaults/backend-development/fastapi.md +309 -0
  29. package/dist/skills/defaults/backend-development/git-advanced-workflows.md +405 -0
  30. package/dist/skills/defaults/backend-development/microservices-patterns.md +595 -0
  31. package/dist/skills/defaults/backend-development/microservices.md +284 -0
  32. package/dist/skills/defaults/backend-development/monorepo-management.md +623 -0
  33. package/dist/skills/defaults/backend-development/nodejs-backend-patterns.md +1048 -0
  34. package/dist/skills/defaults/backend-development/nx-workspace-patterns.md +457 -0
  35. package/dist/skills/defaults/backend-development/paypal-integration/SKILL.md +478 -0
  36. package/dist/skills/defaults/backend-development/pci-compliance/SKILL.md +480 -0
  37. package/dist/skills/defaults/backend-development/python-anti-patterns.md +349 -0
  38. package/dist/skills/defaults/backend-development/python-background-jobs.md +364 -0
  39. package/dist/skills/defaults/backend-development/python-code-style.md +360 -0
  40. package/dist/skills/defaults/backend-development/python-configuration.md +368 -0
  41. package/dist/skills/defaults/backend-development/python-design-patterns.md +296 -0
  42. package/dist/skills/defaults/backend-development/python-error-handling.md +323 -0
  43. package/dist/skills/defaults/backend-development/python-packaging.md +887 -0
  44. package/dist/skills/defaults/backend-development/python-performance-optimization.md +874 -0
  45. package/dist/skills/defaults/backend-development/python-project-structure.md +252 -0
  46. package/dist/skills/defaults/backend-development/python-resilience.md +376 -0
  47. package/dist/skills/defaults/backend-development/python-resource-management.md +421 -0
  48. package/dist/skills/defaults/backend-development/python-type-safety.md +428 -0
  49. package/dist/skills/defaults/backend-development/sql-optimization-patterns.md +509 -0
  50. package/dist/skills/defaults/backend-development/stripe-integration/SKILL.md +522 -0
  51. package/dist/skills/defaults/backend-development/turborepo-caching.md +376 -0
  52. package/dist/skills/defaults/blockchain/defi-protocol-templates.md +430 -0
  53. package/dist/skills/defaults/blockchain/nft-standards.md +364 -0
  54. package/dist/skills/defaults/blockchain/solidity-security.md +514 -0
  55. package/dist/skills/defaults/blockchain/web3-testing.md +360 -0
  56. package/dist/skills/defaults/business/competitive-landscape/SKILL.md +527 -0
  57. package/dist/skills/defaults/business/market-sizing-analysis/SKILL.md +451 -0
  58. package/dist/skills/defaults/business/startup-financial-modeling/SKILL.md +494 -0
  59. package/dist/skills/defaults/business/startup-metrics-framework/SKILL.md +564 -0
  60. package/dist/skills/defaults/business/team-composition-analysis.md +437 -0
  61. package/dist/skills/defaults/compliance/employment-contract-templates/SKILL.md +527 -0
  62. package/dist/skills/defaults/compliance/gdpr-data-handling/SKILL.md +630 -0
  63. package/dist/skills/defaults/data-engineering/airflow-dag-patterns.md +436 -0
  64. package/dist/skills/defaults/data-engineering/airflow.md +519 -0
  65. package/dist/skills/defaults/data-engineering/data-quality.md +583 -0
  66. package/dist/skills/defaults/data-engineering/dbt-transformation-patterns.md +482 -0
  67. package/dist/skills/defaults/data-engineering/dbt.md +556 -0
  68. package/dist/skills/defaults/data-engineering/ml-pipeline-workflow/SKILL.md +247 -0
  69. package/dist/skills/defaults/data-engineering/spark-optimization.md +348 -0
  70. package/dist/skills/defaults/data-engineering/spark.md +411 -0
  71. package/dist/skills/defaults/database/postgresql.md +202 -0
  72. package/dist/skills/defaults/debugging/systematic-debugging.md +249 -0
  73. package/dist/skills/defaults/devops/architecture-decision-records.md +448 -0
  74. package/dist/skills/defaults/devops/changelog-automation.md +580 -0
  75. package/dist/skills/defaults/devops/cicd.md +314 -0
  76. package/dist/skills/defaults/devops/cloud.md +263 -0
  77. package/dist/skills/defaults/devops/code-review-excellence.md +299 -0
  78. package/dist/skills/defaults/devops/cost-optimization.md +295 -0
  79. package/dist/skills/defaults/devops/deployment-pipeline-design.md +356 -0
  80. package/dist/skills/defaults/devops/docker.md +281 -0
  81. package/dist/skills/defaults/devops/git-workflows.md +205 -0
  82. package/dist/skills/defaults/devops/github-actions.md +311 -0
  83. package/dist/skills/defaults/devops/gitlab-ci-patterns.md +266 -0
  84. package/dist/skills/defaults/devops/hybrid-cloud-networking.md +241 -0
  85. package/dist/skills/defaults/devops/istio-traffic-management.md +327 -0
  86. package/dist/skills/defaults/devops/kubernetes.md +339 -0
  87. package/dist/skills/defaults/devops/linkerd-patterns.md +311 -0
  88. package/dist/skills/defaults/devops/multi-cloud-architecture.md +181 -0
  89. package/dist/skills/defaults/devops/observability.md +243 -0
  90. package/dist/skills/defaults/devops/openapi-spec-generation.md +1024 -0
  91. package/dist/skills/defaults/devops/postmortem-writing.md +396 -0
  92. package/dist/skills/defaults/devops/prometheus-configuration.md +265 -0
  93. package/dist/skills/defaults/devops/secrets-management.md +341 -0
  94. package/dist/skills/defaults/devops/service-mesh-observability.md +385 -0
  95. package/dist/skills/defaults/devops/terraform-module-library.md +244 -0
  96. package/dist/skills/defaults/finance/backtesting-frameworks/SKILL.md +663 -0
  97. package/dist/skills/defaults/finance/risk-metrics-calculation/SKILL.md +557 -0
  98. package/dist/skills/defaults/frontend/accessibility-compliance.md +420 -0
  99. package/dist/skills/defaults/frontend/design-system-patterns.md +337 -0
  100. package/dist/skills/defaults/frontend/interaction-design.md +327 -0
  101. package/dist/skills/defaults/frontend/javascript.md +311 -0
  102. package/dist/skills/defaults/frontend/modern-javascript-patterns.md +927 -0
  103. package/dist/skills/defaults/frontend/react-native-design.md +440 -0
  104. package/dist/skills/defaults/frontend/react.md +345 -0
  105. package/dist/skills/defaults/frontend/responsive-design.md +472 -0
  106. package/dist/skills/defaults/frontend/tailwind-design-system.md +337 -0
  107. package/dist/skills/defaults/frontend/typescript-advanced-types.md +724 -0
  108. package/dist/skills/defaults/frontend/typescript.md +334 -0
  109. package/dist/skills/defaults/frontend/visual-design-foundations.md +326 -0
  110. package/dist/skills/defaults/frontend/web-component-design.md +279 -0
  111. package/dist/skills/defaults/game-development/godot-gdscript-patterns.md +188 -0
  112. package/dist/skills/defaults/game-development/unity-ecs-patterns.md +594 -0
  113. package/dist/skills/defaults/kubernetes/gitops-workflow.md +285 -0
  114. package/dist/skills/defaults/kubernetes/gitops.md +280 -0
  115. package/dist/skills/defaults/kubernetes/helm-chart-scaffolding.md +553 -0
  116. package/dist/skills/defaults/kubernetes/helm.md +343 -0
  117. package/dist/skills/defaults/kubernetes/k8s-manifest-generator.md +501 -0
  118. package/dist/skills/defaults/kubernetes/k8s-security-policies.md +342 -0
  119. package/dist/skills/defaults/kubernetes/manifests.md +330 -0
  120. package/dist/skills/defaults/kubernetes/security.md +337 -0
  121. package/dist/skills/defaults/llm-application/embedding-strategies.md +608 -0
  122. package/dist/skills/defaults/llm-application/hybrid-search-implementation.md +570 -0
  123. package/dist/skills/defaults/llm-application/hybrid-search.md +570 -0
  124. package/dist/skills/defaults/llm-application/langchain-architecture.md +666 -0
  125. package/dist/skills/defaults/llm-application/langchain.md +259 -0
  126. package/dist/skills/defaults/llm-application/llm-evaluation.md +695 -0
  127. package/dist/skills/defaults/llm-application/prompt-engineering-patterns.md +449 -0
  128. package/dist/skills/defaults/llm-application/prompt-engineering.md +219 -0
  129. package/dist/skills/defaults/llm-application/rag-implementation.md +434 -0
  130. package/dist/skills/defaults/llm-application/similarity-search-patterns.md +560 -0
  131. package/dist/skills/defaults/llm-application/similarity-search.md +560 -0
  132. package/dist/skills/defaults/llm-application/vector-index-tuning.md +523 -0
  133. package/dist/skills/defaults/mobile/mobile-android-design.md +440 -0
  134. package/dist/skills/defaults/mobile/mobile-ios-design.md +266 -0
  135. package/dist/skills/defaults/monitoring/distributed-tracing.md +436 -0
  136. package/dist/skills/defaults/monitoring/grafana-dashboards.md +370 -0
  137. package/dist/skills/defaults/monitoring/prometheus-configuration.md +379 -0
  138. package/dist/skills/defaults/monitoring/slo-implementation.md +323 -0
  139. package/dist/skills/defaults/refactoring/code-refactoring.md +349 -0
  140. package/dist/skills/defaults/security/anti-reversing-techniques/SKILL.md +559 -0
  141. package/dist/skills/defaults/security/auditor.md +168 -0
  142. package/dist/skills/defaults/security/binary-analysis-patterns/SKILL.md +438 -0
  143. package/dist/skills/defaults/security/memory-forensics/SKILL.md +483 -0
  144. package/dist/skills/defaults/security/mtls-configuration.md +349 -0
  145. package/dist/skills/defaults/security/protocol-reverse-engineering/SKILL.md +520 -0
  146. package/dist/skills/defaults/security/sast-configuration.md +182 -0
  147. package/dist/skills/defaults/security/security.md +313 -0
  148. package/dist/skills/defaults/security/stride-analysis.md +273 -0
  149. package/dist/skills/defaults/security/threat-mitigation-mapping.md +290 -0
  150. package/dist/skills/defaults/systems/bash-defensive-patterns/SKILL.md +539 -0
  151. package/dist/skills/defaults/systems/bats-testing-patterns/SKILL.md +631 -0
  152. package/dist/skills/defaults/systems/go-concurrency-patterns.md +657 -0
  153. package/dist/skills/defaults/systems/memory-safety-patterns.md +605 -0
  154. package/dist/skills/defaults/systems/rust-async-patterns.md +519 -0
  155. package/dist/skills/defaults/systems/shellcheck-configuration/SKILL.md +456 -0
  156. package/dist/skills/defaults/team-collaboration/multi-reviewer-patterns.md +126 -0
  157. package/dist/skills/defaults/team-collaboration/parallel-feature-development.md +151 -0
  158. package/dist/skills/defaults/testing/javascript-testing-patterns.md +1021 -0
  159. package/dist/skills/defaults/testing/python-testing-patterns.md +351 -0
  160. package/dist/skills/defaults/testing/testing.md +332 -0
  161. package/dist/skills/defaults/workflows/context-driven-development.md +384 -0
  162. package/dist/skills/defaults/workflows/track-management.md +592 -0
  163. package/dist/skills/defaults/workflows/workflow-patterns.md +622 -0
  164. package/dist/skills/index.d.ts +11 -0
  165. package/dist/skills/index.d.ts.map +1 -0
  166. package/dist/skills/index.js +129 -0
  167. package/dist/skills/index.js.map +1 -0
  168. package/dist/utils/character.js +6 -9
  169. package/dist/utils/character.js.map +1 -1
  170. package/dist/utils/contextManager.js +3 -7
  171. package/dist/utils/contextManager.js.map +1 -1
  172. package/dist/utils/inputbar.d.ts.map +1 -1
  173. package/dist/utils/inputbar.js +8 -1
  174. package/dist/utils/inputbar.js.map +1 -1
  175. package/dist/utils/output.d.ts.map +1 -1
  176. package/dist/utils/output.js +3 -35
  177. package/dist/utils/output.js.map +1 -1
  178. package/package.json +1 -1
@@ -0,0 +1,623 @@
1
+ ---
2
+ name: monorepo-management
3
+ description: Master monorepo management with Turborepo, Nx, and pnpm workspaces to build efficient, scalable multi-package repositories with optimized builds and dependency management. Use when setting up monorepos, optimizing builds, or managing shared dependencies.
4
+ ---
5
+
6
+ # Monorepo Management
7
+
8
+ Build efficient, scalable monorepos that enable code sharing, consistent tooling, and atomic changes across multiple packages and applications.
9
+
10
+ ## When to Use This Skill
11
+
12
+ - Setting up new monorepo projects
13
+ - Migrating from multi-repo to monorepo
14
+ - Optimizing build and test performance
15
+ - Managing shared dependencies
16
+ - Implementing code sharing strategies
17
+ - Setting up CI/CD for monorepos
18
+ - Versioning and publishing packages
19
+ - Debugging monorepo-specific issues
20
+
21
+ ## Core Concepts
22
+
23
+ ### 1. Why Monorepos?
24
+
25
+ **Advantages:**
26
+
27
+ - Shared code and dependencies
28
+ - Atomic commits across projects
29
+ - Consistent tooling and standards
30
+ - Easier refactoring
31
+ - Simplified dependency management
32
+ - Better code visibility
33
+
34
+ **Challenges:**
35
+
36
+ - Build performance at scale
37
+ - CI/CD complexity
38
+ - Access control
39
+ - Large Git repository
40
+
41
+ ### 2. Monorepo Tools
42
+
43
+ **Package Managers:**
44
+
45
+ - pnpm workspaces (recommended)
46
+ - npm workspaces
47
+ - Yarn workspaces
48
+
49
+ **Build Systems:**
50
+
51
+ - Turborepo (recommended for most)
52
+ - Nx (feature-rich, complex)
53
+ - Lerna (older, maintenance mode)
54
+
55
+ ## Turborepo Setup
56
+
57
+ ### Initial Setup
58
+
59
+ ```bash
60
+ # Create new monorepo
61
+ npx create-turbo@latest my-monorepo
62
+ cd my-monorepo
63
+
64
+ # Structure:
65
+ # apps/
66
+ # web/ - Next.js app
67
+ # docs/ - Documentation site
68
+ # packages/
69
+ # ui/ - Shared UI components
70
+ # config/ - Shared configurations
71
+ # tsconfig/ - Shared TypeScript configs
72
+ # turbo.json - Turborepo configuration
73
+ # package.json - Root package.json
74
+ ```
75
+
76
+ ### Configuration
77
+
78
+ ```json
79
+ // turbo.json
80
+ {
81
+ "$schema": "https://turbo.build/schema.json",
82
+ "globalDependencies": ["**/.env.*local"],
83
+ "pipeline": {
84
+ "build": {
85
+ "dependsOn": ["^build"],
86
+ "outputs": ["dist/**", ".next/**", "!.next/cache/**"]
87
+ },
88
+ "test": {
89
+ "dependsOn": ["build"],
90
+ "outputs": ["coverage/**"]
91
+ },
92
+ "lint": {
93
+ "outputs": []
94
+ },
95
+ "dev": {
96
+ "cache": false,
97
+ "persistent": true
98
+ },
99
+ "type-check": {
100
+ "dependsOn": ["^build"],
101
+ "outputs": []
102
+ }
103
+ }
104
+ }
105
+ ```
106
+
107
+ ```json
108
+ // package.json (root)
109
+ {
110
+ "name": "my-monorepo",
111
+ "private": true,
112
+ "workspaces": ["apps/*", "packages/*"],
113
+ "scripts": {
114
+ "build": "turbo run build",
115
+ "dev": "turbo run dev",
116
+ "test": "turbo run test",
117
+ "lint": "turbo run lint",
118
+ "format": "prettier --write \"**/*.{ts,tsx,md}\"",
119
+ "clean": "turbo run clean && rm -rf node_modules"
120
+ },
121
+ "devDependencies": {
122
+ "turbo": "^1.10.0",
123
+ "prettier": "^3.0.0",
124
+ "typescript": "^5.0.0"
125
+ },
126
+ "packageManager": "pnpm@8.0.0"
127
+ }
128
+ ```
129
+
130
+ ### Package Structure
131
+
132
+ ```json
133
+ // packages/ui/package.json
134
+ {
135
+ "name": "@repo/ui",
136
+ "version": "0.0.0",
137
+ "private": true,
138
+ "main": "./dist/index.js",
139
+ "types": "./dist/index.d.ts",
140
+ "exports": {
141
+ ".": {
142
+ "import": "./dist/index.js",
143
+ "types": "./dist/index.d.ts"
144
+ },
145
+ "./button": {
146
+ "import": "./dist/button.js",
147
+ "types": "./dist/button.d.ts"
148
+ }
149
+ },
150
+ "scripts": {
151
+ "build": "tsup src/index.ts --format esm,cjs --dts",
152
+ "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
153
+ "lint": "eslint src/",
154
+ "type-check": "tsc --noEmit"
155
+ },
156
+ "devDependencies": {
157
+ "@repo/tsconfig": "workspace:*",
158
+ "tsup": "^7.0.0",
159
+ "typescript": "^5.0.0"
160
+ },
161
+ "dependencies": {
162
+ "react": "^18.2.0"
163
+ }
164
+ }
165
+ ```
166
+
167
+ ## pnpm Workspaces
168
+
169
+ ### Setup
170
+
171
+ ```yaml
172
+ # pnpm-workspace.yaml
173
+ packages:
174
+ - "apps/*"
175
+ - "packages/*"
176
+ - "tools/*"
177
+ ```
178
+
179
+ ```json
180
+ // .npmrc
181
+ # Hoist shared dependencies
182
+ shamefully-hoist=true
183
+
184
+ # Strict peer dependencies
185
+ auto-install-peers=true
186
+ strict-peer-dependencies=true
187
+
188
+ # Performance
189
+ store-dir=~/.pnpm-store
190
+ ```
191
+
192
+ ### Dependency Management
193
+
194
+ ```bash
195
+ # Install dependency in specific package
196
+ pnpm add react --filter @repo/ui
197
+ pnpm add -D typescript --filter @repo/ui
198
+
199
+ # Install workspace dependency
200
+ pnpm add @repo/ui --filter web
201
+
202
+ # Install in all packages
203
+ pnpm add -D eslint -w
204
+
205
+ # Update all dependencies
206
+ pnpm update -r
207
+
208
+ # Remove dependency
209
+ pnpm remove react --filter @repo/ui
210
+ ```
211
+
212
+ ### Scripts
213
+
214
+ ```bash
215
+ # Run script in specific package
216
+ pnpm --filter web dev
217
+ pnpm --filter @repo/ui build
218
+
219
+ # Run in all packages
220
+ pnpm -r build
221
+ pnpm -r test
222
+
223
+ # Run in parallel
224
+ pnpm -r --parallel dev
225
+
226
+ # Filter by pattern
227
+ pnpm --filter "@repo/*" build
228
+ pnpm --filter "...web" build # Build web and dependencies
229
+ ```
230
+
231
+ ## Nx Monorepo
232
+
233
+ ### Setup
234
+
235
+ ```bash
236
+ # Create Nx monorepo
237
+ npx create-nx-workspace@latest my-org
238
+
239
+ # Generate applications
240
+ nx generate @nx/react:app my-app
241
+ nx generate @nx/next:app my-next-app
242
+
243
+ # Generate libraries
244
+ nx generate @nx/react:lib ui-components
245
+ nx generate @nx/js:lib utils
246
+ ```
247
+
248
+ ### Configuration
249
+
250
+ ```json
251
+ // nx.json
252
+ {
253
+ "extends": "nx/presets/npm.json",
254
+ "$schema": "./node_modules/nx/schemas/nx-schema.json",
255
+ "targetDefaults": {
256
+ "build": {
257
+ "dependsOn": ["^build"],
258
+ "inputs": ["production", "^production"],
259
+ "cache": true
260
+ },
261
+ "test": {
262
+ "inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
263
+ "cache": true
264
+ },
265
+ "lint": {
266
+ "inputs": ["default", "{workspaceRoot}/.eslintrc.json"],
267
+ "cache": true
268
+ }
269
+ },
270
+ "namedInputs": {
271
+ "default": ["{projectRoot}/**/*", "sharedGlobals"],
272
+ "production": [
273
+ "default",
274
+ "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
275
+ "!{projectRoot}/tsconfig.spec.json"
276
+ ],
277
+ "sharedGlobals": []
278
+ }
279
+ }
280
+ ```
281
+
282
+ ### Running Tasks
283
+
284
+ ```bash
285
+ # Run task for specific project
286
+ nx build my-app
287
+ nx test ui-components
288
+ nx lint utils
289
+
290
+ # Run for affected projects
291
+ nx affected:build
292
+ nx affected:test --base=main
293
+
294
+ # Visualize dependencies
295
+ nx graph
296
+
297
+ # Run in parallel
298
+ nx run-many --target=build --all --parallel=3
299
+ ```
300
+
301
+ ## Shared Configurations
302
+
303
+ ### TypeScript Configuration
304
+
305
+ ```json
306
+ // packages/tsconfig/base.json
307
+ {
308
+ "compilerOptions": {
309
+ "strict": true,
310
+ "esModuleInterop": true,
311
+ "skipLibCheck": true,
312
+ "forceConsistentCasingInFileNames": true,
313
+ "module": "ESNext",
314
+ "moduleResolution": "bundler",
315
+ "resolveJsonModule": true,
316
+ "isolatedModules": true,
317
+ "incremental": true,
318
+ "declaration": true
319
+ },
320
+ "exclude": ["node_modules"]
321
+ }
322
+
323
+ // packages/tsconfig/react.json
324
+ {
325
+ "extends": "./base.json",
326
+ "compilerOptions": {
327
+ "jsx": "react-jsx",
328
+ "lib": ["ES2022", "DOM", "DOM.Iterable"]
329
+ }
330
+ }
331
+
332
+ // apps/web/tsconfig.json
333
+ {
334
+ "extends": "@repo/tsconfig/react.json",
335
+ "compilerOptions": {
336
+ "outDir": "dist",
337
+ "rootDir": "src"
338
+ },
339
+ "include": ["src"],
340
+ "exclude": ["node_modules", "dist"]
341
+ }
342
+ ```
343
+
344
+ ### ESLint Configuration
345
+
346
+ ```javascript
347
+ // packages/config/eslint-preset.js
348
+ module.exports = {
349
+ extends: [
350
+ "eslint:recommended",
351
+ "plugin:@typescript-eslint/recommended",
352
+ "plugin:react/recommended",
353
+ "plugin:react-hooks/recommended",
354
+ "prettier",
355
+ ],
356
+ plugins: ["@typescript-eslint", "react", "react-hooks"],
357
+ parser: "@typescript-eslint/parser",
358
+ parserOptions: {
359
+ ecmaVersion: 2022,
360
+ sourceType: "module",
361
+ ecmaFeatures: {
362
+ jsx: true,
363
+ },
364
+ },
365
+ settings: {
366
+ react: {
367
+ version: "detect",
368
+ },
369
+ },
370
+ rules: {
371
+ "@typescript-eslint/no-unused-vars": "error",
372
+ "react/react-in-jsx-scope": "off",
373
+ },
374
+ };
375
+
376
+ // apps/web/.eslintrc.js
377
+ module.exports = {
378
+ extends: ["@repo/config/eslint-preset"],
379
+ rules: {
380
+ // App-specific rules
381
+ },
382
+ };
383
+ ```
384
+
385
+ ## Code Sharing Patterns
386
+
387
+ ### Pattern 1: Shared UI Components
388
+
389
+ ```typescript
390
+ // packages/ui/src/button.tsx
391
+ import * as React from 'react';
392
+
393
+ export interface ButtonProps {
394
+ variant?: 'primary' | 'secondary';
395
+ children: React.ReactNode;
396
+ onClick?: () => void;
397
+ }
398
+
399
+ export function Button({ variant = 'primary', children, onClick }: ButtonProps) {
400
+ return (
401
+ <button
402
+ className={`btn btn-${variant}`}
403
+ onClick={onClick}
404
+ >
405
+ {children}
406
+ </button>
407
+ );
408
+ }
409
+
410
+ // packages/ui/src/index.ts
411
+ export { Button, type ButtonProps } from './button';
412
+ export { Input, type InputProps } from './input';
413
+
414
+ // apps/web/src/app.tsx
415
+ import { Button } from '@repo/ui';
416
+
417
+ export function App() {
418
+ return <Button variant="primary">Click me</Button>;
419
+ }
420
+ ```
421
+
422
+ ### Pattern 2: Shared Utilities
423
+
424
+ ```typescript
425
+ // packages/utils/src/string.ts
426
+ export function capitalize(str: string): string {
427
+ return str.charAt(0).toUpperCase() + str.slice(1);
428
+ }
429
+
430
+ export function truncate(str: string, length: number): string {
431
+ return str.length > length ? str.slice(0, length) + "..." : str;
432
+ }
433
+
434
+ // packages/utils/src/index.ts
435
+ export * from "./string";
436
+ export * from "./array";
437
+ export * from "./date";
438
+
439
+ // Usage in apps
440
+ import { capitalize, truncate } from "@repo/utils";
441
+ ```
442
+
443
+ ### Pattern 3: Shared Types
444
+
445
+ ```typescript
446
+ // packages/types/src/user.ts
447
+ export interface User {
448
+ id: string;
449
+ email: string;
450
+ name: string;
451
+ role: "admin" | "user";
452
+ }
453
+
454
+ export interface CreateUserInput {
455
+ email: string;
456
+ name: string;
457
+ password: string;
458
+ }
459
+
460
+ // Used in both frontend and backend
461
+ import type { User, CreateUserInput } from "@repo/types";
462
+ ```
463
+
464
+ ## Build Optimization
465
+
466
+ ### Turborepo Caching
467
+
468
+ ```json
469
+ // turbo.json
470
+ {
471
+ "pipeline": {
472
+ "build": {
473
+ // Build depends on dependencies being built first
474
+ "dependsOn": ["^build"],
475
+
476
+ // Cache these outputs
477
+ "outputs": ["dist/**", ".next/**"],
478
+
479
+ // Cache based on these inputs (default: all files)
480
+ "inputs": ["src/**/*.tsx", "src/**/*.ts", "package.json"]
481
+ },
482
+ "test": {
483
+ // Run tests in parallel, don't depend on build
484
+ "cache": true,
485
+ "outputs": ["coverage/**"]
486
+ }
487
+ }
488
+ }
489
+ ```
490
+
491
+ ### Remote Caching
492
+
493
+ ```bash
494
+ # Turborepo Remote Cache (Vercel)
495
+ npx turbo login
496
+ npx turbo link
497
+
498
+ # Custom remote cache
499
+ # turbo.json
500
+ {
501
+ "remoteCache": {
502
+ "signature": true,
503
+ "enabled": true
504
+ }
505
+ }
506
+ ```
507
+
508
+ ## CI/CD for Monorepos
509
+
510
+ ### GitHub Actions
511
+
512
+ ```yaml
513
+ # .github/workflows/ci.yml
514
+ name: CI
515
+
516
+ on:
517
+ push:
518
+ branches: [main]
519
+ pull_request:
520
+ branches: [main]
521
+
522
+ jobs:
523
+ build:
524
+ runs-on: ubuntu-latest
525
+
526
+ steps:
527
+ - uses: actions/checkout@v3
528
+ with:
529
+ fetch-depth: 0 # For Nx affected commands
530
+
531
+ - uses: pnpm/action-setup@v2
532
+ with:
533
+ version: 8
534
+
535
+ - uses: actions/setup-node@v3
536
+ with:
537
+ node-version: 18
538
+ cache: "pnpm"
539
+
540
+ - name: Install dependencies
541
+ run: pnpm install --frozen-lockfile
542
+
543
+ - name: Build
544
+ run: pnpm turbo run build
545
+
546
+ - name: Test
547
+ run: pnpm turbo run test
548
+
549
+ - name: Lint
550
+ run: pnpm turbo run lint
551
+
552
+ - name: Type check
553
+ run: pnpm turbo run type-check
554
+ ```
555
+
556
+ ### Deploy Affected Only
557
+
558
+ ```yaml
559
+ # Deploy only changed apps
560
+ - name: Deploy affected apps
561
+ run: |
562
+ if pnpm nx affected:apps --base=origin/main --head=HEAD | grep -q "web"; then
563
+ echo "Deploying web app"
564
+ pnpm --filter web deploy
565
+ fi
566
+ ```
567
+
568
+ ## Best Practices
569
+
570
+ 1. **Consistent Versioning**: Lock dependency versions across workspace
571
+ 2. **Shared Configs**: Centralize ESLint, TypeScript, Prettier configs
572
+ 3. **Dependency Graph**: Keep it acyclic, avoid circular dependencies
573
+ 4. **Cache Effectively**: Configure inputs/outputs correctly
574
+ 5. **Type Safety**: Share types between frontend/backend
575
+ 6. **Testing Strategy**: Unit tests in packages, E2E in apps
576
+ 7. **Documentation**: README in each package
577
+ 8. **Release Strategy**: Use changesets for versioning
578
+
579
+ ## Common Pitfalls
580
+
581
+ - **Circular Dependencies**: A depends on B, B depends on A
582
+ - **Phantom Dependencies**: Using deps not in package.json
583
+ - **Incorrect Cache Inputs**: Missing files in Turborepo inputs
584
+ - **Over-Sharing**: Sharing code that should be separate
585
+ - **Under-Sharing**: Duplicating code across packages
586
+ - **Large Monorepos**: Without proper tooling, builds slow down
587
+
588
+ ## Publishing Packages
589
+
590
+ ```bash
591
+ # Using Changesets
592
+ pnpm add -Dw @changesets/cli
593
+ pnpm changeset init
594
+
595
+ # Create changeset
596
+ pnpm changeset
597
+
598
+ # Version packages
599
+ pnpm changeset version
600
+
601
+ # Publish
602
+ pnpm changeset publish
603
+ ```
604
+
605
+ ```yaml
606
+ # .github/workflows/release.yml
607
+ - name: Create Release Pull Request or Publish
608
+ uses: changesets/action@v1
609
+ with:
610
+ publish: pnpm release
611
+ env:
612
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
613
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
614
+ ```
615
+
616
+ ## Resources
617
+
618
+ - **references/turborepo-guide.md**: Comprehensive Turborepo documentation
619
+ - **references/nx-guide.md**: Nx monorepo patterns
620
+ - **references/pnpm-workspaces.md**: pnpm workspace features
621
+ - **assets/monorepo-checklist.md**: Setup checklist
622
+ - **assets/migration-guide.md**: Multi-repo to monorepo migration
623
+ - **scripts/dependency-graph.ts**: Visualize package dependencies