tribunal-kit 4.3.0 → 4.3.1
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.
- package/.agent/scripts/case_law_manager.js +684 -684
- package/.agent/scripts/graph_builder.js +199 -0
- package/.agent/scripts/graph_zoom.js +154 -0
- package/.agent/skills/agent-organizer/SKILL.md +9 -1
- package/.agent/skills/agentic-patterns/SKILL.md +9 -1
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +9 -1
- package/.agent/skills/api-patterns/SKILL.md +206 -198
- package/.agent/skills/api-security-auditor/SKILL.md +9 -1
- package/.agent/skills/app-builder/SKILL.md +9 -1
- package/.agent/skills/app-builder/templates/SKILL.md +77 -69
- package/.agent/skills/appflow-wireframe/SKILL.md +9 -1
- package/.agent/skills/architecture/SKILL.md +9 -1
- package/.agent/skills/authentication-best-practices/SKILL.md +9 -1
- package/.agent/skills/bash-linux/SKILL.md +9 -1
- package/.agent/skills/behavioral-modes/SKILL.md +9 -1
- package/.agent/skills/brainstorming/SKILL.md +9 -1
- package/.agent/skills/building-native-ui/SKILL.md +9 -1
- package/.agent/skills/clean-code/SKILL.md +9 -1
- package/.agent/skills/code-review-checklist/SKILL.md +9 -1
- package/.agent/skills/config-validator/SKILL.md +9 -1
- package/.agent/skills/csharp-developer/SKILL.md +9 -1
- package/.agent/skills/data-validation-schemas/SKILL.md +287 -279
- package/.agent/skills/database-design/SKILL.md +199 -191
- package/.agent/skills/deployment-procedures/SKILL.md +9 -1
- package/.agent/skills/devops-engineer/SKILL.md +9 -1
- package/.agent/skills/devops-incident-responder/SKILL.md +9 -1
- package/.agent/skills/documentation-templates/SKILL.md +9 -1
- package/.agent/skills/edge-computing/SKILL.md +9 -1
- package/.agent/skills/error-resilience/SKILL.md +387 -379
- package/.agent/skills/extract-design-system/SKILL.md +9 -1
- package/.agent/skills/framer-motion-expert/SKILL.md +203 -195
- package/.agent/skills/frontend-design/SKILL.md +160 -152
- package/.agent/skills/game-design-expert/SKILL.md +9 -1
- package/.agent/skills/game-engineering-expert/SKILL.md +9 -1
- package/.agent/skills/geo-fundamentals/SKILL.md +9 -1
- package/.agent/skills/github-operations/SKILL.md +9 -1
- package/.agent/skills/gsap-core/SKILL.md +54 -46
- package/.agent/skills/gsap-frameworks/SKILL.md +54 -46
- package/.agent/skills/gsap-performance/SKILL.md +54 -46
- package/.agent/skills/gsap-plugins/SKILL.md +54 -46
- package/.agent/skills/gsap-react/SKILL.md +54 -46
- package/.agent/skills/gsap-scrolltrigger/SKILL.md +54 -46
- package/.agent/skills/gsap-timeline/SKILL.md +54 -46
- package/.agent/skills/gsap-utils/SKILL.md +54 -46
- package/.agent/skills/i18n-localization/SKILL.md +9 -1
- package/.agent/skills/intelligent-routing/SKILL.md +38 -30
- package/.agent/skills/knowledge-graph/SKILL.md +36 -0
- package/.agent/skills/lint-and-validate/SKILL.md +9 -1
- package/.agent/skills/llm-engineering/SKILL.md +9 -1
- package/.agent/skills/local-first/SKILL.md +9 -1
- package/.agent/skills/mcp-builder/SKILL.md +9 -1
- package/.agent/skills/mobile-design/SKILL.md +222 -214
- package/.agent/skills/monorepo-management/SKILL.md +293 -285
- package/.agent/skills/motion-engineering/SKILL.md +193 -185
- package/.agent/skills/nextjs-react-expert/SKILL.md +193 -185
- package/.agent/skills/nodejs-best-practices/SKILL.md +9 -1
- package/.agent/skills/observability/SKILL.md +9 -1
- package/.agent/skills/parallel-agents/SKILL.md +9 -1
- package/.agent/skills/performance-profiling/SKILL.md +9 -1
- package/.agent/skills/plan-writing/SKILL.md +9 -1
- package/.agent/skills/platform-engineer/SKILL.md +9 -1
- package/.agent/skills/playwright-best-practices/SKILL.md +9 -1
- package/.agent/skills/powershell-windows/SKILL.md +9 -1
- package/.agent/skills/project-idioms/SKILL.md +9 -1
- package/.agent/skills/python-patterns/SKILL.md +9 -1
- package/.agent/skills/python-pro/SKILL.md +282 -274
- package/.agent/skills/react-specialist/SKILL.md +236 -228
- package/.agent/skills/readme-builder/SKILL.md +9 -1
- package/.agent/skills/realtime-patterns/SKILL.md +9 -1
- package/.agent/skills/red-team-tactics/SKILL.md +9 -1
- package/.agent/skills/rust-pro/SKILL.md +9 -1
- package/.agent/skills/seo-fundamentals/SKILL.md +9 -1
- package/.agent/skills/server-management/SKILL.md +9 -1
- package/.agent/skills/shadcn-ui-expert/SKILL.md +9 -1
- package/.agent/skills/skill-creator/SKILL.md +9 -1
- package/.agent/skills/sql-pro/SKILL.md +9 -1
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +9 -1
- package/.agent/skills/swiftui-expert/SKILL.md +9 -1
- package/.agent/skills/systematic-debugging/SKILL.md +9 -1
- package/.agent/skills/tailwind-patterns/SKILL.md +9 -1
- package/.agent/skills/tdd-workflow/SKILL.md +9 -1
- package/.agent/skills/test-result-analyzer/SKILL.md +9 -1
- package/.agent/skills/testing-patterns/SKILL.md +9 -1
- package/.agent/skills/trend-researcher/SKILL.md +9 -1
- package/.agent/skills/typescript-advanced/SKILL.md +294 -286
- package/.agent/skills/ui-ux-pro-max/SKILL.md +9 -1
- package/.agent/skills/ui-ux-researcher/SKILL.md +9 -1
- package/.agent/skills/vue-expert/SKILL.md +234 -226
- package/.agent/skills/vulnerability-scanner/SKILL.md +9 -1
- package/.agent/skills/web-accessibility-auditor/SKILL.md +9 -1
- package/.agent/skills/web-design-guidelines/SKILL.md +9 -1
- package/.agent/skills/webapp-testing/SKILL.md +9 -1
- package/.agent/skills/whimsy-injector/SKILL.md +9 -1
- package/.agent/skills/workflow-optimizer/SKILL.md +9 -1
- package/README.md +242 -242
- package/bin/tribunal-kit.js +30 -22
- package/package.json +81 -80
- package/scripts/validate-payload.js +73 -0
|
@@ -1,287 +1,287 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: monorepo-management
|
|
3
|
-
description: Monorepo architecture and tooling mastery. Turborepo, Nx, pnpm workspaces, shared package design, task pipelines, dependency hoisting, change detection, versioning strategies (independent vs. fixed), shared TypeScript configs, internal packages, and CI optimization for monorepos. Use when setting up monorepos, managing shared code across apps, or optimizing build pipelines.
|
|
4
|
-
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
-
version: 1.0.0
|
|
6
|
-
last-updated: 2026-04-17
|
|
7
|
-
applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## Hallucination Traps (Read First)
|
|
11
|
-
- ❌ Publishing internal packages to npm when they're meant to stay private -> ✅ Internal packages use `"private": true` and workspace protocol `"workspace:*"`
|
|
12
|
-
- ❌ Putting all shared code in a single `packages/shared` dump -> ✅ Split by domain: `packages/ui`, `packages/config`, `packages/utils`
|
|
13
|
-
- ❌ Running all tests on every PR regardless of what changed -> ✅ Use affected/changed detection (Turborepo `--filter`, Nx `affected`)
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
# Monorepo Management — Scaling Multi-Package Projects
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Tool Selection
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
┌──────────────────────────────────────────────────────────────┐
|
|
25
|
-
│ When to Use What │
|
|
26
|
-
├──────────────────────────────────────────────────────────────┤
|
|
27
|
-
│ pnpm workspaces │ Package linking only, no build orchestration│
|
|
28
|
-
│ Turborepo │ Fast builds, simple config, Vercel ecosystem│
|
|
29
|
-
│ Nx │ Enterprise, generators, dependency graph UI │
|
|
30
|
-
│ npm workspaces │ Zero-dep, basic linking (limited features) │
|
|
31
|
-
│ Yarn workspaces │ Legacy projects already using Yarn │
|
|
32
|
-
├──────────────────────────────────────────────────────────────┤
|
|
33
|
-
│ Recommendation: pnpm + Turborepo for most projects │
|
|
34
|
-
└──────────────────────────────────────────────────────────────┘
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## Directory Structure
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
my-monorepo/
|
|
43
|
-
├── apps/
|
|
44
|
-
│ ├── web/ # Next.js frontend
|
|
45
|
-
│ │ ├── package.json
|
|
46
|
-
│ │ └── tsconfig.json
|
|
47
|
-
│ ├── api/ # Fastify/Express backend
|
|
48
|
-
│ │ ├── package.json
|
|
49
|
-
│ │ └── tsconfig.json
|
|
50
|
-
│ └── mobile/ # React Native app
|
|
51
|
-
│ └── package.json
|
|
52
|
-
├── packages/
|
|
53
|
-
│ ├── ui/ # Shared React components
|
|
54
|
-
│ │ ├── src/
|
|
55
|
-
│ │ ├── package.json
|
|
56
|
-
│ │ └── tsconfig.json
|
|
57
|
-
│ ├── config/ # Shared ESLint, TypeScript, Prettier configs
|
|
58
|
-
│ │ ├── eslint/
|
|
59
|
-
│ │ ├── typescript/
|
|
60
|
-
│ │ └── package.json
|
|
61
|
-
│ ├── utils/ # Shared pure functions
|
|
62
|
-
│ │ └── package.json
|
|
63
|
-
│ └── db/ # Shared database client + schemas
|
|
64
|
-
│ └── package.json
|
|
65
|
-
├── turbo.json
|
|
66
|
-
├── pnpm-workspace.yaml
|
|
67
|
-
├── package.json # Root — devDependencies only
|
|
68
|
-
└── tsconfig.base.json # Shared TS config extended by all
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## pnpm Workspace Setup
|
|
74
|
-
|
|
75
|
-
```yaml
|
|
76
|
-
# pnpm-workspace.yaml
|
|
77
|
-
packages:
|
|
78
|
-
- "apps/*"
|
|
79
|
-
- "packages/*"
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
```json
|
|
83
|
-
// Root package.json
|
|
84
|
-
{
|
|
85
|
-
"name": "my-monorepo",
|
|
86
|
-
"private": true,
|
|
87
|
-
"scripts": {
|
|
88
|
-
"dev": "turbo run dev",
|
|
89
|
-
"build": "turbo run build",
|
|
90
|
-
"lint": "turbo run lint",
|
|
91
|
-
"test": "turbo run test",
|
|
92
|
-
"clean": "turbo run clean"
|
|
93
|
-
},
|
|
94
|
-
"devDependencies": {
|
|
95
|
-
"turbo": "^2.0.0"
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
```json
|
|
101
|
-
// packages/ui/package.json
|
|
102
|
-
{
|
|
103
|
-
"name": "@myorg/ui",
|
|
104
|
-
"version": "0.0.0",
|
|
105
|
-
"private": true,
|
|
106
|
-
"main": "./src/index.ts",
|
|
107
|
-
"types": "./src/index.ts",
|
|
108
|
-
"exports": {
|
|
109
|
-
".": "./src/index.ts",
|
|
110
|
-
"./button": "./src/button.tsx",
|
|
111
|
-
"./card": "./src/card.tsx"
|
|
112
|
-
},
|
|
113
|
-
"peerDependencies": {
|
|
114
|
-
"react": "^19.0.0",
|
|
115
|
-
"react-dom": "^19.0.0"
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
```json
|
|
121
|
-
// apps/web/package.json — consuming internal package
|
|
122
|
-
{
|
|
123
|
-
"name": "web",
|
|
124
|
-
"dependencies": {
|
|
125
|
-
"@myorg/ui": "workspace:*",
|
|
126
|
-
"@myorg/utils": "workspace:*"
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## Turborepo Configuration
|
|
134
|
-
|
|
135
|
-
```json
|
|
136
|
-
// turbo.json
|
|
137
|
-
{
|
|
138
|
-
"$schema": "https://turbo.build/schema.json",
|
|
139
|
-
"globalDependencies": ["**/.env.*local"],
|
|
140
|
-
"tasks": {
|
|
141
|
-
"build": {
|
|
142
|
-
"dependsOn": ["^build"],
|
|
143
|
-
"outputs": ["dist/**", ".next/**", "!.next/cache/**"]
|
|
144
|
-
},
|
|
145
|
-
"dev": {
|
|
146
|
-
"cache": false,
|
|
147
|
-
"persistent": true
|
|
148
|
-
},
|
|
149
|
-
"lint": {
|
|
150
|
-
"dependsOn": ["^build"]
|
|
151
|
-
},
|
|
152
|
-
"test": {
|
|
153
|
-
"dependsOn": ["^build"],
|
|
154
|
-
"outputs": ["coverage/**"]
|
|
155
|
-
},
|
|
156
|
-
"clean": {
|
|
157
|
-
"cache": false
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
```
|
|
164
|
-
Key concepts:
|
|
165
|
-
"^build" = Run build in dependencies FIRST (topological)
|
|
166
|
-
"dependsOn" = Task ordering — lint waits for build
|
|
167
|
-
"outputs" = What gets cached — skip re-runs if unchanged
|
|
168
|
-
"persistent" = Long-running (dev servers) — never cached
|
|
169
|
-
"cache: false" = Always run, never skip
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
## Shared TypeScript Configuration
|
|
175
|
-
|
|
176
|
-
```json
|
|
177
|
-
// tsconfig.base.json (root)
|
|
178
|
-
{
|
|
179
|
-
"compilerOptions": {
|
|
180
|
-
"strict": true,
|
|
181
|
-
"target": "ES2022",
|
|
182
|
-
"module": "ESNext",
|
|
183
|
-
"moduleResolution": "bundler",
|
|
184
|
-
"esModuleInterop": true,
|
|
185
|
-
"skipLibCheck": true,
|
|
186
|
-
"forceConsistentCasingInFileNames": true,
|
|
187
|
-
"declaration": true,
|
|
188
|
-
"declarationMap": true,
|
|
189
|
-
"sourceMap": true,
|
|
190
|
-
"isolatedModules": true,
|
|
191
|
-
"resolveJsonModule": true
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
```json
|
|
197
|
-
// apps/web/tsconfig.json
|
|
198
|
-
{
|
|
199
|
-
"extends": "../../tsconfig.base.json",
|
|
200
|
-
"compilerOptions": {
|
|
201
|
-
"jsx": "preserve",
|
|
202
|
-
"lib": ["dom", "dom.iterable", "ES2022"],
|
|
203
|
-
"outDir": "./dist"
|
|
204
|
-
},
|
|
205
|
-
"include": ["src/**/*", "../../packages/*/src/**/*"]
|
|
206
|
-
}
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
|
-
## Change Detection (Only Build What Changed)
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
# Turborepo — filter by affected packages
|
|
215
|
-
turbo run build --filter=...[HEAD~1] # packages changed since last commit
|
|
216
|
-
turbo run test --filter=web... # web app + its dependencies
|
|
217
|
-
turbo run lint --filter=@myorg/ui # specific package only
|
|
218
|
-
|
|
219
|
-
# CI: Only run tests for changed packages
|
|
220
|
-
turbo run test --filter="[origin/main...HEAD]"
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
```yaml
|
|
224
|
-
# GitHub Actions — with Turborepo cache
|
|
225
|
-
- name: Build & Test (cached)
|
|
226
|
-
run: npx turbo run build test lint --filter="[origin/main...HEAD]"
|
|
227
|
-
env:
|
|
228
|
-
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
|
229
|
-
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
---
|
|
233
|
-
|
|
234
|
-
## Versioning Strategies
|
|
235
|
-
|
|
236
|
-
```
|
|
237
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
238
|
-
│ Fixed (recommended for apps) │
|
|
239
|
-
│ All packages share one version. Simple. One changelog. │
|
|
240
|
-
│ Example: v1.2.3 applies to web, api, ui, utils, db │
|
|
241
|
-
├─────────────────────────────────────────────────────────────┤
|
|
242
|
-
│ Independent (for published libraries) │
|
|
243
|
-
│ Each package has its own version + changelog. │
|
|
244
|
-
│ Example: @myorg/ui@2.1.0, @myorg/utils@1.4.2 │
|
|
245
|
-
│ Tools: Changesets, Lerna │
|
|
246
|
-
├─────────────────────────────────────────────────────────────┤
|
|
247
|
-
│ Recommendation: │
|
|
248
|
-
│ Internal monorepo (1 team) → Fixed versioning │
|
|
249
|
-
│ Open-source multi-package → Independent + Changesets │
|
|
250
|
-
└─────────────────────────────────────────────────────────────┘
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
---
|
|
254
|
-
|
|
255
|
-
## Internal Package Design Rules
|
|
256
|
-
|
|
257
|
-
```
|
|
258
|
-
✅ Internal packages are "private": true — never published to npm
|
|
259
|
-
✅ Use workspace protocol: "@myorg/ui": "workspace:*"
|
|
260
|
-
✅ Export raw TypeScript (src/index.ts) — let the consuming app bundle it
|
|
261
|
-
✅ One package per domain: ui, utils, config, db — NOT one giant "shared"
|
|
262
|
-
✅ Peer dependencies for React/framework — don't bundle the framework
|
|
263
|
-
|
|
264
|
-
❌ Don't create a package for 1-2 functions — inline until it's reused 3+ times
|
|
265
|
-
❌ Don't publish internal packages to npm "just in case"
|
|
266
|
-
❌ Don't share mutable state across packages — each package is a pure module
|
|
267
|
-
❌ Don't put app-specific code in packages/ — only truly shared code
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
## Anti-Patterns
|
|
273
|
-
|
|
274
|
-
```
|
|
275
|
-
❌ Running all CI checks on every package for every PR — use affected detection
|
|
276
|
-
❌ Circular dependencies between packages — topological ordering must be acyclic
|
|
277
|
-
❌ Mixing CommonJS and ESM in the same monorepo — standardize on ESM
|
|
278
|
-
❌ Installing devDependencies in every package — hoist shared devDeps to root
|
|
279
|
-
❌ No lockfile — pnpm-lock.yaml MUST be committed
|
|
280
|
-
❌ Using relative paths (../../packages/ui) — use workspace:* protocol
|
|
281
|
-
❌ Giant "shared" package — splits into domain-focused packages
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
---
|
|
1
|
+
---
|
|
2
|
+
name: monorepo-management
|
|
3
|
+
description: Monorepo architecture and tooling mastery. Turborepo, Nx, pnpm workspaces, shared package design, task pipelines, dependency hoisting, change detection, versioning strategies (independent vs. fixed), shared TypeScript configs, internal packages, and CI optimization for monorepos. Use when setting up monorepos, managing shared code across apps, or optimizing build pipelines.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
last-updated: 2026-04-17
|
|
7
|
+
applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Hallucination Traps (Read First)
|
|
11
|
+
- ❌ Publishing internal packages to npm when they're meant to stay private -> ✅ Internal packages use `"private": true` and workspace protocol `"workspace:*"`
|
|
12
|
+
- ❌ Putting all shared code in a single `packages/shared` dump -> ✅ Split by domain: `packages/ui`, `packages/config`, `packages/utils`
|
|
13
|
+
- ❌ Running all tests on every PR regardless of what changed -> ✅ Use affected/changed detection (Turborepo `--filter`, Nx `affected`)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Monorepo Management — Scaling Multi-Package Projects
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Tool Selection
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
25
|
+
│ When to Use What │
|
|
26
|
+
├──────────────────────────────────────────────────────────────┤
|
|
27
|
+
│ pnpm workspaces │ Package linking only, no build orchestration│
|
|
28
|
+
│ Turborepo │ Fast builds, simple config, Vercel ecosystem│
|
|
29
|
+
│ Nx │ Enterprise, generators, dependency graph UI │
|
|
30
|
+
│ npm workspaces │ Zero-dep, basic linking (limited features) │
|
|
31
|
+
│ Yarn workspaces │ Legacy projects already using Yarn │
|
|
32
|
+
├──────────────────────────────────────────────────────────────┤
|
|
33
|
+
│ Recommendation: pnpm + Turborepo for most projects │
|
|
34
|
+
└──────────────────────────────────────────────────────────────┘
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Directory Structure
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
my-monorepo/
|
|
43
|
+
├── apps/
|
|
44
|
+
│ ├── web/ # Next.js frontend
|
|
45
|
+
│ │ ├── package.json
|
|
46
|
+
│ │ └── tsconfig.json
|
|
47
|
+
│ ├── api/ # Fastify/Express backend
|
|
48
|
+
│ │ ├── package.json
|
|
49
|
+
│ │ └── tsconfig.json
|
|
50
|
+
│ └── mobile/ # React Native app
|
|
51
|
+
│ └── package.json
|
|
52
|
+
├── packages/
|
|
53
|
+
│ ├── ui/ # Shared React components
|
|
54
|
+
│ │ ├── src/
|
|
55
|
+
│ │ ├── package.json
|
|
56
|
+
│ │ └── tsconfig.json
|
|
57
|
+
│ ├── config/ # Shared ESLint, TypeScript, Prettier configs
|
|
58
|
+
│ │ ├── eslint/
|
|
59
|
+
│ │ ├── typescript/
|
|
60
|
+
│ │ └── package.json
|
|
61
|
+
│ ├── utils/ # Shared pure functions
|
|
62
|
+
│ │ └── package.json
|
|
63
|
+
│ └── db/ # Shared database client + schemas
|
|
64
|
+
│ └── package.json
|
|
65
|
+
├── turbo.json
|
|
66
|
+
├── pnpm-workspace.yaml
|
|
67
|
+
├── package.json # Root — devDependencies only
|
|
68
|
+
└── tsconfig.base.json # Shared TS config extended by all
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## pnpm Workspace Setup
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
# pnpm-workspace.yaml
|
|
77
|
+
packages:
|
|
78
|
+
- "apps/*"
|
|
79
|
+
- "packages/*"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
// Root package.json
|
|
84
|
+
{
|
|
85
|
+
"name": "my-monorepo",
|
|
86
|
+
"private": true,
|
|
87
|
+
"scripts": {
|
|
88
|
+
"dev": "turbo run dev",
|
|
89
|
+
"build": "turbo run build",
|
|
90
|
+
"lint": "turbo run lint",
|
|
91
|
+
"test": "turbo run test",
|
|
92
|
+
"clean": "turbo run clean"
|
|
93
|
+
},
|
|
94
|
+
"devDependencies": {
|
|
95
|
+
"turbo": "^2.0.0"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
// packages/ui/package.json
|
|
102
|
+
{
|
|
103
|
+
"name": "@myorg/ui",
|
|
104
|
+
"version": "0.0.0",
|
|
105
|
+
"private": true,
|
|
106
|
+
"main": "./src/index.ts",
|
|
107
|
+
"types": "./src/index.ts",
|
|
108
|
+
"exports": {
|
|
109
|
+
".": "./src/index.ts",
|
|
110
|
+
"./button": "./src/button.tsx",
|
|
111
|
+
"./card": "./src/card.tsx"
|
|
112
|
+
},
|
|
113
|
+
"peerDependencies": {
|
|
114
|
+
"react": "^19.0.0",
|
|
115
|
+
"react-dom": "^19.0.0"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
// apps/web/package.json — consuming internal package
|
|
122
|
+
{
|
|
123
|
+
"name": "web",
|
|
124
|
+
"dependencies": {
|
|
125
|
+
"@myorg/ui": "workspace:*",
|
|
126
|
+
"@myorg/utils": "workspace:*"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Turborepo Configuration
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
// turbo.json
|
|
137
|
+
{
|
|
138
|
+
"$schema": "https://turbo.build/schema.json",
|
|
139
|
+
"globalDependencies": ["**/.env.*local"],
|
|
140
|
+
"tasks": {
|
|
141
|
+
"build": {
|
|
142
|
+
"dependsOn": ["^build"],
|
|
143
|
+
"outputs": ["dist/**", ".next/**", "!.next/cache/**"]
|
|
144
|
+
},
|
|
145
|
+
"dev": {
|
|
146
|
+
"cache": false,
|
|
147
|
+
"persistent": true
|
|
148
|
+
},
|
|
149
|
+
"lint": {
|
|
150
|
+
"dependsOn": ["^build"]
|
|
151
|
+
},
|
|
152
|
+
"test": {
|
|
153
|
+
"dependsOn": ["^build"],
|
|
154
|
+
"outputs": ["coverage/**"]
|
|
155
|
+
},
|
|
156
|
+
"clean": {
|
|
157
|
+
"cache": false
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
Key concepts:
|
|
165
|
+
"^build" = Run build in dependencies FIRST (topological)
|
|
166
|
+
"dependsOn" = Task ordering — lint waits for build
|
|
167
|
+
"outputs" = What gets cached — skip re-runs if unchanged
|
|
168
|
+
"persistent" = Long-running (dev servers) — never cached
|
|
169
|
+
"cache: false" = Always run, never skip
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Shared TypeScript Configuration
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
// tsconfig.base.json (root)
|
|
178
|
+
{
|
|
179
|
+
"compilerOptions": {
|
|
180
|
+
"strict": true,
|
|
181
|
+
"target": "ES2022",
|
|
182
|
+
"module": "ESNext",
|
|
183
|
+
"moduleResolution": "bundler",
|
|
184
|
+
"esModuleInterop": true,
|
|
185
|
+
"skipLibCheck": true,
|
|
186
|
+
"forceConsistentCasingInFileNames": true,
|
|
187
|
+
"declaration": true,
|
|
188
|
+
"declarationMap": true,
|
|
189
|
+
"sourceMap": true,
|
|
190
|
+
"isolatedModules": true,
|
|
191
|
+
"resolveJsonModule": true
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
```json
|
|
197
|
+
// apps/web/tsconfig.json
|
|
198
|
+
{
|
|
199
|
+
"extends": "../../tsconfig.base.json",
|
|
200
|
+
"compilerOptions": {
|
|
201
|
+
"jsx": "preserve",
|
|
202
|
+
"lib": ["dom", "dom.iterable", "ES2022"],
|
|
203
|
+
"outDir": "./dist"
|
|
204
|
+
},
|
|
205
|
+
"include": ["src/**/*", "../../packages/*/src/**/*"]
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Change Detection (Only Build What Changed)
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# Turborepo — filter by affected packages
|
|
215
|
+
turbo run build --filter=...[HEAD~1] # packages changed since last commit
|
|
216
|
+
turbo run test --filter=web... # web app + its dependencies
|
|
217
|
+
turbo run lint --filter=@myorg/ui # specific package only
|
|
218
|
+
|
|
219
|
+
# CI: Only run tests for changed packages
|
|
220
|
+
turbo run test --filter="[origin/main...HEAD]"
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
```yaml
|
|
224
|
+
# GitHub Actions — with Turborepo cache
|
|
225
|
+
- name: Build & Test (cached)
|
|
226
|
+
run: npx turbo run build test lint --filter="[origin/main...HEAD]"
|
|
227
|
+
env:
|
|
228
|
+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
|
229
|
+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Versioning Strategies
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
238
|
+
│ Fixed (recommended for apps) │
|
|
239
|
+
│ All packages share one version. Simple. One changelog. │
|
|
240
|
+
│ Example: v1.2.3 applies to web, api, ui, utils, db │
|
|
241
|
+
├─────────────────────────────────────────────────────────────┤
|
|
242
|
+
│ Independent (for published libraries) │
|
|
243
|
+
│ Each package has its own version + changelog. │
|
|
244
|
+
│ Example: @myorg/ui@2.1.0, @myorg/utils@1.4.2 │
|
|
245
|
+
│ Tools: Changesets, Lerna │
|
|
246
|
+
├─────────────────────────────────────────────────────────────┤
|
|
247
|
+
│ Recommendation: │
|
|
248
|
+
│ Internal monorepo (1 team) → Fixed versioning │
|
|
249
|
+
│ Open-source multi-package → Independent + Changesets │
|
|
250
|
+
└─────────────────────────────────────────────────────────────┘
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Internal Package Design Rules
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
✅ Internal packages are "private": true — never published to npm
|
|
259
|
+
✅ Use workspace protocol: "@myorg/ui": "workspace:*"
|
|
260
|
+
✅ Export raw TypeScript (src/index.ts) — let the consuming app bundle it
|
|
261
|
+
✅ One package per domain: ui, utils, config, db — NOT one giant "shared"
|
|
262
|
+
✅ Peer dependencies for React/framework — don't bundle the framework
|
|
263
|
+
|
|
264
|
+
❌ Don't create a package for 1-2 functions — inline until it's reused 3+ times
|
|
265
|
+
❌ Don't publish internal packages to npm "just in case"
|
|
266
|
+
❌ Don't share mutable state across packages — each package is a pure module
|
|
267
|
+
❌ Don't put app-specific code in packages/ — only truly shared code
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Anti-Patterns
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
❌ Running all CI checks on every package for every PR — use affected detection
|
|
276
|
+
❌ Circular dependencies between packages — topological ordering must be acyclic
|
|
277
|
+
❌ Mixing CommonJS and ESM in the same monorepo — standardize on ESM
|
|
278
|
+
❌ Installing devDependencies in every package — hoist shared devDeps to root
|
|
279
|
+
❌ No lockfile — pnpm-lock.yaml MUST be committed
|
|
280
|
+
❌ Using relative paths (../../packages/ui) — use workspace:* protocol
|
|
281
|
+
❌ Giant "shared" package — splits into domain-focused packages
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
285
|
|
|
286
286
|
|
|
287
287
|
---
|
|
@@ -323,4 +323,12 @@ Review these questions before confirming output:
|
|
|
323
323
|
|
|
324
324
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
325
325
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
326
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
326
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
## Pre-Flight Checklist
|
|
330
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
331
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
332
|
+
|
|
333
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
334
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|