@robosoft/skillhub-cli 0.1.1 → 0.3.2

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 (53) hide show
  1. package/CHANGELOG.md +21 -21
  2. package/README.md +166 -184
  3. package/bin/skillhub.mjs +734 -364
  4. package/docs/skillhub-cli-logic.md +115 -83
  5. package/package.json +8 -5
  6. package/skillhub-registry/CHANGELOG.md +65 -0
  7. package/skillhub-registry/CLAUDE.md +108 -0
  8. package/skillhub-registry/README.md +196 -16
  9. package/skillhub-registry/docs/cheat-sheet.md +272 -0
  10. package/skillhub-registry/docs/contributing.md +166 -0
  11. package/skillhub-registry/docs/cost-hygiene.md +175 -0
  12. package/skillhub-registry/docs/customization.md +321 -0
  13. package/skillhub-registry/docs/exception-process.md +194 -0
  14. package/skillhub-registry/docs/installation.md +277 -0
  15. package/skillhub-registry/domain/api.md +303 -0
  16. package/skillhub-registry/domain/frontend/web-app.md +17 -0
  17. package/skillhub-registry/domain/frontend-app.md +46 -0
  18. package/skillhub-registry/domain/frontend-architecture.md +126 -0
  19. package/skillhub-registry/rules/anti-patterns.md +95 -0
  20. package/skillhub-registry/rules/code-standards.md +182 -0
  21. package/skillhub-registry/rules/frontend/antipattern.md +21 -0
  22. package/skillhub-registry/rules/frontend/component-standards.md +10 -0
  23. package/skillhub-registry/rules/frontend-app.md +24 -0
  24. package/skillhub-registry/rules/general.md +51 -0
  25. package/skillhub-registry/skills/api/SKILL.md +167 -0
  26. package/skillhub-registry/skills/build/SKILL.md +114 -0
  27. package/skillhub-registry/skills/fast/SKILL.md +56 -0
  28. package/skillhub-registry/skills/feature-dev/SKILL.md +166 -0
  29. package/skillhub-registry/skills/frontend/app/SKILL.md +28 -0
  30. package/skillhub-registry/skills/frontend/app/rules/main.md +6 -0
  31. package/skillhub-registry/skills/frontend/app/skill.json +10 -0
  32. package/skillhub-registry/skills/frontend/app/templates/feature/{{kebabName}}.tsx.hbs +11 -0
  33. package/skillhub-registry/skills/frontend-app/SKILL.md +48 -0
  34. package/skillhub-registry/skills/frontend-app/rules/main.md +6 -0
  35. package/skillhub-registry/skills/frontend-app/skill.json +11 -0
  36. package/skillhub-registry/skills/frontend-app/templates/feature/{{kebabName}}.tsx.hbs +11 -0
  37. package/skillhub-registry/skills/performance/SKILL.md +168 -0
  38. package/skillhub-registry/skills/react/SKILL.md +224 -0
  39. package/skillhub-registry/skills/refactor/SKILL.md +149 -0
  40. package/skillhub-registry/skills/review/SKILL.md +199 -0
  41. package/skillhub-registry/skills/strict/SKILL.md +74 -0
  42. package/skillhub-registry/skills/testing/SKILL.md +132 -0
  43. package/skillhub-registry/accessibility-review/1.0.0/SKILL.md +0 -22
  44. package/skillhub-registry/accessibility-review/1.0.0/checklist/ui-review.md +0 -8
  45. package/skillhub-registry/accessibility-review/1.0.0/skill.json +0 -9
  46. package/skillhub-registry/nextjs-clean-architecture/1.0.0/SKILL.md +0 -37
  47. package/skillhub-registry/nextjs-clean-architecture/1.0.0/checklist/definition-of-done.md +0 -9
  48. package/skillhub-registry/nextjs-clean-architecture/1.0.0/rules/folder-structure.md +0 -7
  49. package/skillhub-registry/nextjs-clean-architecture/1.0.0/skill.json +0 -9
  50. package/skillhub-registry/shadcn-crud-generator/1.0.0/SKILL.md +0 -25
  51. package/skillhub-registry/shadcn-crud-generator/1.0.0/skill.json +0 -9
  52. package/skillhub-registry/shadcn-crud-generator/1.0.0/templates/feature/actions.ts.hbs +0 -16
  53. package/skillhub-registry/shadcn-crud-generator/1.0.0/templates/feature/page.tsx.hbs +0 -13
@@ -0,0 +1,166 @@
1
+ ---
2
+ name: feature-dev
3
+ description: End-to-end feature development workflow that orchestrates understanding, planning, building, refactoring, reviewing, and finalizing a feature. Use this skill whenever the user invokes /feature-dev, /feature, asks to "develop a feature", "ship a feature", "build a feature end-to-end", "implement a complete feature", or signals they want a structured multi-step development process. Apply when the work spans multiple files, multiple concerns, or is too large for a single /build invocation. Apply when the user wants the full lifecycle, not just one piece. Do NOT trigger for simple single-function tasks (use /build) or for code review only (use /review).
4
+ ---
5
+
6
+ # Feature Development Workflow
7
+
8
+ This is a **workflow**, not a single-purpose skill. It orchestrates the full feature development lifecycle, drawing on `/build`, `/refactor`, `/review`, and the always-on rules.
9
+
10
+ Use this when a feature is non-trivial — meaning it touches multiple files, has user-visible behavior, will be code-reviewed by a human, and needs to ship cleanly.
11
+
12
+ ---
13
+
14
+ ## How This Workflow Differs From `/build`
15
+
16
+ - **`/build`** is for one-shot implementation: write a function, write a component, write an endpoint.
17
+ - **`/feature-dev`** is for shipping a feature: many files, design decisions, tests, review pass, validation.
18
+
19
+ If the task is small, prefer `/build`. Use `/feature-dev` when the work has phases.
20
+
21
+ ---
22
+
23
+ ## The Six Phases
24
+
25
+ The workflow has six phases. Don't skip phases unless explicitly justified. Be explicit when transitioning between phases — say "Moving to Phase N" so the user knows where things stand.
26
+
27
+ ### Phase 1: Understand
28
+
29
+ **Goal:** Establish what the feature actually is, before any code.
30
+
31
+ Produce:
32
+ - A 2-3 sentence statement of what the feature does, in plain English
33
+ - The user-visible behavior (input → output, or interaction → outcome)
34
+ - The success criteria — how do we know it works?
35
+ - What's explicitly out of scope
36
+
37
+ **Stop and ask** if any of these are unclear. Don't proceed on assumptions for a multi-file feature — the cost of misunderstanding compounds.
38
+
39
+ ### Phase 2: Plan
40
+
41
+ **Goal:** Decide the approach before writing code.
42
+
43
+ Produce:
44
+ - The files that will be created or modified
45
+ - The shape of any new APIs (function signatures, props, endpoints, types)
46
+ - The data flow (what calls what, in what order)
47
+ - The edge cases identified (use the checklist from `skills/testing`)
48
+ - One alternative considered and why it was rejected
49
+ - Any open questions that block implementation
50
+
51
+ **Show the plan to the user before writing code** for non-trivial features. Get a thumbs-up. This catches misalignment cheaply.
52
+
53
+ For simple features, a brief plan inline is enough. Use judgment.
54
+
55
+ ### Phase 3: Build
56
+
57
+ **Goal:** Implement the plan.
58
+
59
+ Apply `skills/build` workflow within this phase. All `rules/` apply. Domain skills (`react`, etc.) layer on if relevant.
60
+
61
+ Build incrementally:
62
+ - Get the core path working first (happy path, no edge cases)
63
+ - Add edge case handling next
64
+ - Add error handling
65
+ - Wire up to real data sources / dependencies last
66
+
67
+ Don't build the whole thing in one shot if you can avoid it. Smaller increments are easier to debug if something goes wrong.
68
+
69
+ ### Phase 4: Test
70
+
71
+ **Goal:** Verify the feature works as specified.
72
+
73
+ Apply `skills/testing` rules:
74
+ - Happy path tests
75
+ - Edge case tests (the ones identified in Phase 2)
76
+ - Failure path tests
77
+ - Integration test if the feature crosses system boundaries
78
+
79
+ If tests are skipped (Fast Mode, prototype, user explicitly waived), state that clearly. Skipping tests is a deliberate choice, not a default.
80
+
81
+ ### Phase 5: Refactor
82
+
83
+ **Goal:** Clean up before review.
84
+
85
+ Apply `skills/refactor` rules:
86
+ - Re-read the code as a stranger would
87
+ - Apply `rules/code-standards.md` strictly
88
+ - Eliminate any anti-patterns that crept in
89
+ - Remove dead code, debugging artifacts, commented-out code, TODOs that don't belong
90
+
91
+ Behavior must not change in this phase. If you find a bug, that's a separate fix — not part of refactor.
92
+
93
+ ### Phase 6: Review
94
+
95
+ **Goal:** Catch what self-review missed.
96
+
97
+ Apply `skills/review` rules to the full feature:
98
+ - Run the review checklist (correctness, security, performance, standards, maintainability, tests)
99
+ - Categorize findings (Critical / Improvement / Minor)
100
+ - Fix Critical and Improvement findings before declaring done
101
+ - Note Minor findings for follow-up if they're not addressed
102
+
103
+ If `/strict` mode is active, apply maximum rigor in this phase.
104
+
105
+ ---
106
+
107
+ ## Output Format
108
+
109
+ Use phase headers to structure the response. The user should always know which phase you're in:
110
+
111
+ Phase 1: Understand[Statement of what the feature does, success criteria, etc.]
112
+ Phase 2: Plan[The plan, with files to touch, edge cases, alternatives.][Pause here for confirmation if non-trivial.]
113
+ Phase 3: Build[Code, file by file.]
114
+ Phase 4: Test[Test code.]
115
+ Phase 5: Refactor[Cleanup notes; usually inline edits to the code above.]
116
+ Phase 6: Review[Self-review findings, categorized.]
117
+
118
+ For shorter features, phases can collapse together — but always label them so the user can follow the structure.
119
+
120
+ ---
121
+
122
+ ## When to Pause for User Input
123
+
124
+ Pause and confirm in these situations:
125
+
126
+ - **End of Phase 1** if the feature scope is fuzzy
127
+ - **End of Phase 2** if the plan involves design decisions the user should approve
128
+ - **Mid-Phase 3** if you hit an unexpected complication that changes the approach
129
+ - **End of Phase 6** before declaring complete, if findings warrant user attention
130
+
131
+ Don't pause for trivial confirmation ("Should I write the function now?"). Pause for decisions.
132
+
133
+ ---
134
+
135
+ ## When to Abandon the Workflow
136
+
137
+ If during Phase 1 or Phase 2 it becomes clear that:
138
+
139
+ - The feature is too small for this workflow → say so, switch to `/build`
140
+ - The feature is actually a refactor in disguise → switch to `/refactor`
141
+ - The requirements are too unclear to proceed → stop, gather requirements
142
+ - The scope is too large for one session → break it into smaller features
143
+
144
+ Don't grind through phases on a task that doesn't need them. The workflow is a tool, not a ritual.
145
+
146
+ ---
147
+
148
+ ## Composition With Other Skills
149
+
150
+ This workflow naturally composes with:
151
+
152
+ - **`/strict`** — applies maximum rigor at every phase, especially Phase 5 and 6
153
+ - **`/fast`** — collapses phases (Plan → Build → minimal Test, skip rigorous Review). For prototypes only.
154
+ - **Domain skills** (`react`, `testing`, `performance`) — layer in their rules during the relevant phases
155
+
156
+ Multiple skills active simultaneously is normal. The workflow provides the structure; the skills provide the content.
157
+
158
+ ---
159
+
160
+ ## What This Workflow Does NOT Cover
161
+
162
+ - **Architecture-level design** that needs discussion before any feature exists — that's a design conversation, not feature dev
163
+ - **Bug fixes** — those have their own rhythm; don't force them through six phases
164
+ - **Pure refactors** — use `/refactor`
165
+ - **Code review of existing PRs** — use `/review`
166
+
@@ -0,0 +1,28 @@
1
+ # Frontend App Development Skill
2
+
3
+ ## Purpose
4
+
5
+ Use this skill when developing frontend web application features in React, Next.js, TypeScript, or similar UI stacks.
6
+
7
+ ## Workflow
8
+
9
+ 1. Read the requirement and identify the user flow.
10
+ 2. Inspect existing project structure before creating files.
11
+ 3. Reuse existing components, hooks, schemas, and services.
12
+ 4. Create a small implementation plan.
13
+ 5. Implement UI with loading, empty, error, and success states.
14
+ 6. Validate accessibility, typing, and responsive behavior.
15
+ 7. Summarize changed files and risks.
16
+
17
+ ## Development Rules
18
+
19
+ - Do not put business logic directly inside JSX.
20
+ - Do not invent APIs or data fields.
21
+ - Keep server, client, and service responsibilities separate.
22
+ - Prefer typed models and schema validation.
23
+ - Avoid new dependencies unless clearly justified.
24
+ - Follow attached rules and domain files before generic advice.
25
+
26
+ ## Expected Output
27
+
28
+ The final implementation should include clear file changes, usage instructions, and validation steps.
@@ -0,0 +1,6 @@
1
+ # Frontend App Skill Rules
2
+
3
+ - Follow the installed frontend anti-pattern rules.
4
+ - Keep components focused and typed.
5
+ - Respect existing project architecture.
6
+ - Add accessible labels and keyboard-friendly interactions.
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "frontend/app",
3
+ "version": "1.0.0",
4
+ "type": "skill",
5
+ "section": "skills",
6
+ "description": "Develop production-ready frontend web application features with architecture, UI states, accessibility, and validation.",
7
+ "entry": "SKILL.md",
8
+ "category": "frontend",
9
+ "tags": ["frontend", "react", "nextjs", "typescript", "web-app"]
10
+ }
@@ -0,0 +1,11 @@
1
+ export type {{pascalName}}Props = {
2
+ title: string;
3
+ };
4
+
5
+ export function {{pascalName}}({ title }: {{pascalName}}Props) {
6
+ return (
7
+ <section aria-labelledby="{{kebabName}}-title">
8
+ <h1 id="{{kebabName}}-title">{title}</h1>
9
+ </section>
10
+ );
11
+ }
@@ -0,0 +1,48 @@
1
+ # Frontend App Development Skill
2
+
3
+ ## Description
4
+
5
+ Use this skill when the user asks to build, modify, review, or debug a frontend application or frontend feature.
6
+
7
+ ## When to Use
8
+
9
+ Trigger this skill for React, Next.js, UI screens, forms, dashboards, routing, API integration, state management, component design, accessibility, responsive layout, and frontend architecture tasks.
10
+
11
+ ## Workflow
12
+
13
+ 1. Understand the user story, target screen, data source, and acceptance criteria.
14
+ 2. Inspect the existing project structure before creating new folders.
15
+ 3. Prefer feature-based organization when the project supports it.
16
+ 4. Build the smallest complete implementation with clear loading, empty, error, and success states.
17
+ 5. Keep business logic outside presentational components.
18
+ 6. Validate with type-checking, linting, build, tests, or manual steps.
19
+ 7. Summarize changed files and risks clearly.
20
+
21
+ ## Frontend Rules
22
+
23
+ - Use TypeScript types for props, API response contracts, and form values.
24
+ - Do not hardcode API URLs inside components.
25
+ - Keep reusable UI in shared/ui or components/ui depending on the project.
26
+ - Use semantic HTML before custom div soup, because div soup is how frontend dignity dies.
27
+ - Add accessible labels, keyboard flow, focus states, and readable error messages.
28
+ - Avoid silent loading states. Every async flow needs loading, error, and empty handling.
29
+ - Match the existing design system before introducing new styling patterns.
30
+ - Avoid global state unless data is genuinely shared across unrelated screens.
31
+
32
+ ## Output Format
33
+
34
+ When implementing, provide:
35
+
36
+ - Files changed
37
+ - Important decisions
38
+ - Validation performed
39
+ - Any assumptions or risks
40
+
41
+ ## Definition of Done
42
+
43
+ - Requirement is implemented end-to-end
44
+ - UI is responsive
45
+ - Loading, empty, and error states exist
46
+ - Accessibility basics are covered
47
+ - Existing patterns are respected
48
+ - Build or validation command is documented
@@ -0,0 +1,6 @@
1
+ # Frontend App Skill Rules
2
+
3
+ - Read installed rules before writing code.
4
+ - Read installed domain knowledge if the feature touches business behavior.
5
+ - Prefer small composable components over giant screen files.
6
+ - Keep mutation and data fetching logic easy to test.
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "frontend-app",
3
+ "version": "1.0.0",
4
+ "type": "skill",
5
+ "section": "skills",
6
+ "description": "Develop production-ready frontend applications using existing architecture, reusable components, validation, accessibility, and clean delivery flow.",
7
+ "category": "frontend",
8
+ "tags": ["frontend", "react", "nextjs", "architecture", "ui"],
9
+ "entry": "SKILL.md",
10
+ "compatibleWith": ["cursor", "claude", "codex", "gemini", "opencode"]
11
+ }
@@ -0,0 +1,11 @@
1
+ export type {{pascalName}}Props = {
2
+ title?: string;
3
+ };
4
+
5
+ export function {{pascalName}}({ title = "{{title}}" }: {{pascalName}}Props) {
6
+ return (
7
+ <section aria-labelledby="{{kebabName}}-title">
8
+ <h1 id="{{kebabName}}-title">{title}</h1>
9
+ </section>
10
+ );
11
+ }
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: performance
3
+ description: Performance optimization standards covering when to optimize, how to measure, common bottleneck patterns, frontend rendering performance, network optimization, bundle size, lazy loading, memoization, caching strategies, and database query performance. Use this skill whenever the user mentions performance, slow code, optimization, profiling, bottlenecks, page speed, render performance, lag, jank, bundle size, lazy loading, code splitting, memoization, caching, query optimization, N+1 queries, or asks why something is slow. Apply when the user reports an app feels slow, asks to make code faster, requests profiling help, mentions Lighthouse / Web Vitals / Core Web Vitals / FCP / LCP / TTI / CLS, or asks to reduce load times. Trigger even when performance is implied — for example, when the user complains about response times or asks if there's a faster way.
4
+ ---
5
+
6
+ # Performance Skill
7
+
8
+ This skill applies the org's performance standards. It loads when the task involves measuring, diagnosing, or optimizing performance.
9
+
10
+ These rules layer on top of `rules/general.md`, `rules/code-standards.md`, and `rules/anti-patterns.md`.
11
+
12
+ ---
13
+
14
+ ## The Iron Rule: Measure Before Optimizing
15
+
16
+ **No optimization without measurement.** This is non-negotiable.
17
+
18
+ - Without measurement, you don't know where the bottleneck is — and intuition is wrong more often than not.
19
+ - Without measurement, you can't prove the optimization helped (it often makes things slower).
20
+ - Without measurement, you have no way to know if a regression sneaks in later.
21
+
22
+ **Workflow:**
23
+ 1. Reproduce the slow scenario reliably.
24
+ 2. Profile it. Identify the actual bottleneck.
25
+ 3. Form a hypothesis about the cause.
26
+ 4. Make ONE change.
27
+ 5. Re-measure. Did it actually improve? By how much?
28
+ 6. Document the before/after numbers in the PR.
29
+
30
+ If you skip steps 1-2 and jump to "I'll add memoization here," you are guessing.
31
+
32
+ ## Common False Bottlenecks
33
+
34
+ These are the optimizations developers reach for first that usually don't matter:
35
+
36
+ - **Adding `useMemo` / `useCallback` everywhere** — usually adds overhead without benefit
37
+ - **Switching `forEach` to `for` loops** — negligible in modern JS engines
38
+ - **Micro-optimizing a function** — when the bottleneck is actually network or rendering
39
+ - **Replacing a library** — when your own code is the slow part
40
+
41
+ The actual bottlenecks are usually:
42
+
43
+ - **Network** — too many requests, slow endpoints, large payloads
44
+ - **Rendering** — too many components re-rendering, large lists without virtualization
45
+ - **Database** — N+1 queries, missing indexes, full table scans
46
+ - **Bundle size** — shipping code that isn't needed yet
47
+ - **Blocking the main thread** — synchronous heavy work in a UI context
48
+
49
+ ## Frontend Rendering Performance
50
+
51
+ ### Re-render avoidance
52
+
53
+ Before reaching for memoization, ask:
54
+
55
+ 1. **Is the parent re-rendering unnecessarily?** Fix that instead.
56
+ 2. **Is state located too high in the tree?** Move it down.
57
+ 3. **Is the component pure?** Same input → same output. If not, fix that first.
58
+
59
+ When memoization is genuinely needed:
60
+
61
+ - Wrap the **child component** in `React.memo`
62
+ - Use `useMemo` for **expensive calculations** (not primitives)
63
+ - Use `useCallback` for **functions passed to memoized children**
64
+ - Profile with React DevTools Profiler to confirm the wins
65
+
66
+ ### Large lists
67
+
68
+ - **Virtualize** lists over ~100 items (`react-window`, `@tanstack/react-virtual`)
69
+ - **Stable keys** — never use array index as key for dynamic lists (causes re-render of all items on reorder)
70
+ - **Pagination or infinite scroll** for data sets you can't bound
71
+
72
+ ### Images and media
73
+
74
+ - **Lazy load** below-the-fold images (`loading="lazy"`)
75
+ - **Modern formats** (WebP, AVIF) with fallbacks
76
+ - **Responsive images** (`srcset` / `<picture>`) — don't ship desktop images to mobile
77
+ - **Compress** before upload; never trust raw uploads
78
+
79
+ ## Network Performance
80
+
81
+ ### Request reduction
82
+
83
+ - **Batch requests** when an API supports it
84
+ - **Cache aggressively** — both browser cache (HTTP headers) and in-memory (TanStack Query, SWR)
85
+ - **Eliminate waterfalls** — parallelize independent requests with `Promise.all`
86
+ - **Avoid over-fetching** — request only the fields you need (GraphQL, sparse fieldsets)
87
+ - **Avoid under-fetching** — don't make 10 sequential calls when one batched call would do
88
+
89
+ ### Payload size
90
+
91
+ - **Compress responses** (gzip/brotli at the server)
92
+ - **Paginate** large collections
93
+ - **Don't return what you don't render** — strip server-only fields
94
+
95
+ ### Critical path
96
+
97
+ - **Defer non-critical JS** — `defer`/`async` script tags, dynamic imports
98
+ - **Preload critical assets** — `<link rel="preload">` for the fonts/scripts that block render
99
+ - **Inline critical CSS** if first paint is the bottleneck
100
+
101
+ ## Bundle Size
102
+
103
+ - **Code-split by route.** Don't ship the admin dashboard JS to logged-out users.
104
+ - **Code-split heavy components** — modals, charts, editors that aren't needed on initial render.
105
+ - **Tree-shake aggressively** — import only what you use (`import { foo } from 'lib'` not `import lib from 'lib'`).
106
+ - **Audit large dependencies.** Use `bundle-analyzer` or equivalent. A 200KB date library is rarely justified.
107
+ - **Polyfill conditionally** — modern browsers don't need legacy polyfills.
108
+
109
+ ## Backend Performance
110
+
111
+ ### Database
112
+
113
+ - **N+1 is the most common bottleneck.** If a request makes one query, then loops over results making more queries → that's N+1. Use joins, `IN` queries, or a DataLoader pattern.
114
+ - **Index the columns you filter / sort by.** Missing indexes turn O(log n) lookups into O(n) scans.
115
+ - **Don't `SELECT *`** — return the columns you need.
116
+ - **Paginate.** Never return unbounded result sets.
117
+ - **Watch for accidental table scans** — explain plan your slow queries.
118
+
119
+ ### Caching
120
+
121
+ - **Cache the expensive thing, not the cheap thing.** Cache hits should save real work.
122
+ - **Invalidation is the hard part** — design the invalidation strategy before adding the cache.
123
+ - **Layer caches:** CDN → server cache → app-level cache → DB.
124
+ - **Don't cache user-specific data in shared caches** without keying by user.
125
+
126
+ ### Concurrency
127
+
128
+ - **Async everything that can be async.** Blocking I/O wastes the request thread.
129
+ - **Don't await in a loop** when the calls are independent — use `Promise.all`.
130
+ - **Backpressure matters** — unbounded concurrency exhausts connection pools.
131
+
132
+ ## Measurement Tools
133
+
134
+ By environment:
135
+
136
+ - **Browser frontend:** Chrome DevTools Performance tab, React DevTools Profiler, Lighthouse, Web Vitals (LCP, FID, CLS, INP)
137
+ - **Node backend:** `--prof`, `clinic.js`, APM tools (Datadog, New Relic), distributed tracing
138
+ - **Database:** `EXPLAIN ANALYZE`, slow query logs, query analyzers
139
+ - **Network:** browser Network tab, Wireshark, server access logs
140
+
141
+ Pick a baseline metric *before* optimizing. "It feels faster" is not data.
142
+
143
+ ## Performance Budgets
144
+
145
+ For frontend, set explicit budgets and fail the build if exceeded:
146
+
147
+ - **JS bundle:** target < 200KB gzipped for first load
148
+ - **LCP (Largest Contentful Paint):** < 2.5s on 4G
149
+ - **TTI (Time to Interactive):** < 3.5s on mid-range mobile
150
+ - **CLS (Cumulative Layout Shift):** < 0.1
151
+
152
+ These are starting points. Adjust to your product's actual users and devices.
153
+
154
+ ## When You're Unsure
155
+
156
+ - **Don't guess what's slow.** Ask the user to share profiler output, network waterfall, or `EXPLAIN ANALYZE` output.
157
+ - **Confirm the user's measurement approach.** "It feels slow" needs investigation before optimization.
158
+ - **Confirm the target device / network.** Optimizing for a desktop on fiber and a phone on 3G are different problems.
159
+ - **Don't apply backend wisdom to frontend** (or vice versa). Bottlenecks differ by environment.
160
+
161
+ ## What NOT to Do
162
+
163
+ - ❌ Add memoization "just in case"
164
+ - ❌ Replace simple code with "faster" cleverness without measurement
165
+ - ❌ Optimize before code is correct and tested
166
+ - ❌ Apply micro-optimizations to non-hot-path code
167
+ - ❌ Cache without an invalidation strategy
168
+ - ❌ Ship optimization PRs without before/after numbers