cortex-agents 3.4.0 → 4.0.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.
Files changed (49) hide show
  1. package/.opencode/agents/architect.md +82 -89
  2. package/.opencode/agents/audit.md +57 -188
  3. package/.opencode/agents/{crosslayer.md → coder.md} +9 -52
  4. package/.opencode/agents/debug.md +151 -0
  5. package/.opencode/agents/devops.md +142 -0
  6. package/.opencode/agents/docs-writer.md +195 -0
  7. package/.opencode/agents/fix.md +119 -189
  8. package/.opencode/agents/implement.md +115 -74
  9. package/.opencode/agents/perf.md +151 -0
  10. package/.opencode/agents/refactor.md +163 -0
  11. package/.opencode/agents/{guard.md → security.md} +20 -85
  12. package/.opencode/agents/testing.md +115 -0
  13. package/.opencode/skills/data-engineering/SKILL.md +221 -0
  14. package/.opencode/skills/monitoring-observability/SKILL.md +251 -0
  15. package/.opencode/skills/ui-design/SKILL.md +402 -0
  16. package/README.md +303 -287
  17. package/dist/cli.js +6 -9
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +26 -28
  20. package/dist/registry.d.ts +4 -4
  21. package/dist/registry.d.ts.map +1 -1
  22. package/dist/registry.js +6 -6
  23. package/dist/tools/branch.d.ts +2 -2
  24. package/dist/tools/docs.d.ts +2 -2
  25. package/dist/tools/github.d.ts +3 -3
  26. package/dist/tools/plan.d.ts +28 -4
  27. package/dist/tools/plan.d.ts.map +1 -1
  28. package/dist/tools/plan.js +232 -4
  29. package/dist/tools/quality-gate.d.ts +28 -0
  30. package/dist/tools/quality-gate.d.ts.map +1 -0
  31. package/dist/tools/quality-gate.js +233 -0
  32. package/dist/tools/repl.d.ts +5 -0
  33. package/dist/tools/repl.d.ts.map +1 -1
  34. package/dist/tools/repl.js +58 -7
  35. package/dist/tools/worktree.d.ts +5 -32
  36. package/dist/tools/worktree.d.ts.map +1 -1
  37. package/dist/tools/worktree.js +75 -458
  38. package/dist/utils/change-scope.d.ts +33 -0
  39. package/dist/utils/change-scope.d.ts.map +1 -0
  40. package/dist/utils/change-scope.js +198 -0
  41. package/dist/utils/plan-extract.d.ts +21 -0
  42. package/dist/utils/plan-extract.d.ts.map +1 -1
  43. package/dist/utils/plan-extract.js +65 -0
  44. package/dist/utils/repl.d.ts +31 -0
  45. package/dist/utils/repl.d.ts.map +1 -1
  46. package/dist/utils/repl.js +126 -13
  47. package/package.json +1 -1
  48. package/.opencode/agents/qa.md +0 -265
  49. package/.opencode/agents/ship.md +0 -249
@@ -0,0 +1,251 @@
1
+ ---
2
+ name: monitoring-observability
3
+ description: Structured logging, metrics instrumentation, distributed tracing, health checks, and alerting patterns
4
+ license: Apache-2.0
5
+ compatibility: opencode
6
+ ---
7
+
8
+ # Monitoring & Observability Skill
9
+
10
+ This skill provides patterns for making applications observable in production through logging, metrics, tracing, and alerting.
11
+
12
+ ## When to Use
13
+
14
+ Use this skill when:
15
+ - Adding logging to new features or services
16
+ - Instrumenting code with metrics (counters, histograms, gauges)
17
+ - Implementing distributed tracing across services
18
+ - Designing health check endpoints
19
+ - Setting up alerting and SLO definitions
20
+ - Debugging production issues through observability data
21
+
22
+ ## The Three Pillars of Observability
23
+
24
+ ### 1. Logs — What Happened
25
+ Structured, contextual records of discrete events.
26
+
27
+ ### 2. Metrics — How Much / How Fast
28
+ Numeric measurements aggregated over time.
29
+
30
+ ### 3. Traces — The Journey
31
+ End-to-end request paths across service boundaries.
32
+
33
+ ## Structured Logging
34
+
35
+ ### Principles
36
+ - **Always use structured logging** (JSON) — never unstructured `console.log` in production
37
+ - **Log levels matter**: ERROR (action needed), WARN (degraded), INFO (business events), DEBUG (development)
38
+ - **Include context**: correlation IDs, user IDs, request IDs, operation names
39
+ - **Never log secrets**: passwords, tokens, PII, credit card numbers
40
+
41
+ ### Log Levels Guide
42
+
43
+ | Level | When to Use | Example |
44
+ |-------|-------------|---------|
45
+ | **ERROR** | Something failed and needs attention | Database connection lost, payment failed |
46
+ | **WARN** | Degraded but still functioning | Cache miss fallback, retry attempt, rate limit approaching |
47
+ | **INFO** | Significant business events | User signed up, order placed, deployment completed |
48
+ | **DEBUG** | Development/troubleshooting detail | SQL query executed, cache hit/miss, function entry/exit |
49
+
50
+ ### Structured Log Format
51
+
52
+ ```json
53
+ {
54
+ "timestamp": "2025-01-15T10:30:00.000Z",
55
+ "level": "info",
56
+ "message": "Order placed successfully",
57
+ "service": "order-service",
58
+ "traceId": "abc123",
59
+ "spanId": "def456",
60
+ "userId": "user_789",
61
+ "orderId": "order_012",
62
+ "amount": 99.99,
63
+ "currency": "USD",
64
+ "duration_ms": 145
65
+ }
66
+ ```
67
+
68
+ ### Correlation IDs
69
+ - Generate a unique request ID at the entry point (API gateway, load balancer)
70
+ - Propagate it through all downstream calls via headers (`X-Request-ID`, `traceparent`)
71
+ - Include it in every log line for cross-service correlation
72
+
73
+ ### What to Log
74
+
75
+ **DO log:**
76
+ - Request/response boundaries (method, path, status, duration)
77
+ - Business events (user actions, state transitions, transactions)
78
+ - Error details with stack traces and context
79
+ - Performance-relevant data (query times, cache hit rates)
80
+ - Security events (auth failures, permission denials, rate limits)
81
+
82
+ **DO NOT log:**
83
+ - Passwords, tokens, API keys, secrets
84
+ - Full credit card numbers, SSNs, or PII without masking
85
+ - High-frequency debug data in production (use sampling)
86
+ - Request/response bodies containing sensitive data
87
+
88
+ ## Metrics Instrumentation
89
+
90
+ ### Metric Types
91
+
92
+ | Type | Use Case | Example |
93
+ |------|----------|---------|
94
+ | **Counter** | Monotonically increasing value | Total requests, errors, orders placed |
95
+ | **Gauge** | Value that goes up and down | Active connections, queue depth, memory usage |
96
+ | **Histogram** | Distribution of values | Request latency, response size, batch processing time |
97
+ | **Summary** | Pre-calculated quantiles | P50/P95/P99 latency (client-side) |
98
+
99
+ ### Naming Conventions
100
+ - Use snake_case: `http_requests_total`, `request_duration_seconds`
101
+ - Include units in the name: `_seconds`, `_bytes`, `_total`
102
+ - Use `_total` suffix for counters
103
+ - Prefix with service/subsystem: `api_http_requests_total`
104
+
105
+ ### Key Metrics to Track
106
+
107
+ **RED Method (Request-driven services):**
108
+ - **R**ate — Requests per second
109
+ - **E**rrors — Error rate (4xx, 5xx)
110
+ - **D**uration — Request latency distribution
111
+
112
+ **USE Method (Resource-oriented):**
113
+ - **U**tilization — % of resource capacity used
114
+ - **S**aturation — Queue depth, backpressure
115
+ - **E**rrors — Error count per resource
116
+
117
+ ### Cardinality Warning
118
+ - Avoid high-cardinality labels (user IDs, request IDs, URLs with path params)
119
+ - Keep label combinations < 1000 per metric
120
+ - Use bounded values: HTTP methods (GET, POST), status codes (2xx, 4xx, 5xx), endpoints (normalized)
121
+
122
+ ## Distributed Tracing
123
+
124
+ ### OpenTelemetry Patterns
125
+ - **Span** — A single operation within a trace (e.g., HTTP request, DB query, function call)
126
+ - **Trace** — A tree of spans representing an end-to-end request
127
+ - **Context Propagation** — Passing trace context across service boundaries via headers
128
+
129
+ ### What to Trace
130
+ - HTTP requests (client and server)
131
+ - Database queries
132
+ - Cache operations
133
+ - Message queue publish/consume
134
+ - External API calls
135
+ - Significant business operations
136
+
137
+ ### Span Attributes
138
+ ```
139
+ http.method: GET
140
+ http.url: /api/users/123
141
+ http.status_code: 200
142
+ db.system: postgresql
143
+ db.statement: SELECT * FROM users WHERE id = $1
144
+ messaging.system: kafka
145
+ messaging.destination: orders
146
+ ```
147
+
148
+ ### Sampling Strategies
149
+ - **Head-based sampling**: Decide at trace start (e.g., sample 10% of requests)
150
+ - **Tail-based sampling**: Decide after trace completes (keep errors, slow requests, sample normal)
151
+ - **Priority sampling**: Always sample errors, high-value transactions; sample routine requests
152
+
153
+ ## Health Check Endpoints
154
+
155
+ ### Liveness vs Readiness
156
+
157
+ | Check | Purpose | Failure Action |
158
+ |-------|---------|----------------|
159
+ | **Liveness** (`/healthz`) | Is the process alive? | Restart the container |
160
+ | **Readiness** (`/readyz`) | Can it serve traffic? | Remove from load balancer |
161
+ | **Startup** (`/startupz`) | Has it finished initializing? | Wait before liveness checks |
162
+
163
+ ### Health Check Response Format
164
+ ```json
165
+ {
166
+ "status": "healthy",
167
+ "checks": {
168
+ "database": { "status": "healthy", "latency_ms": 5 },
169
+ "cache": { "status": "healthy", "latency_ms": 1 },
170
+ "external_api": { "status": "degraded", "latency_ms": 2500, "message": "Slow response" }
171
+ },
172
+ "version": "1.2.3",
173
+ "uptime_seconds": 86400
174
+ }
175
+ ```
176
+
177
+ ### Best Practices
178
+ - Health checks should be **fast** (< 1 second)
179
+ - Liveness should check the process only — NOT external dependencies
180
+ - Readiness should check critical dependencies (database, cache)
181
+ - Return appropriate HTTP status: 200 (healthy), 503 (unhealthy)
182
+ - Include dependency health in readiness but not liveness
183
+
184
+ ## Alerting & SLOs
185
+
186
+ ### SLO Definitions
187
+ - **SLI** (Service Level Indicator): The metric you measure (e.g., request latency P99)
188
+ - **SLO** (Service Level Objective): The target (e.g., P99 latency < 500ms for 99.9% of requests)
189
+ - **Error Budget**: Allowable failures (e.g., 0.1% of requests can exceed 500ms)
190
+
191
+ ### Alert Design Principles
192
+ - **Alert on symptoms, not causes** — Alert on "users can't log in", not "CPU is high"
193
+ - **Alert on SLO burn rate** — Alert when error budget is being consumed too fast
194
+ - **Avoid alert fatigue** — Every alert should require human action
195
+ - **Include runbook links** — Every alert should link to resolution steps
196
+
197
+ ### Severity Levels
198
+
199
+ | Severity | Response Time | Example |
200
+ |----------|--------------|---------|
201
+ | **P1 — Critical** | Immediate (< 5 min) | Service down, data loss, security breach |
202
+ | **P2 — High** | Within 1 hour | Degraded performance, partial outage |
203
+ | **P3 — Medium** | Within 1 business day | Non-critical feature broken, elevated error rate |
204
+ | **P4 — Low** | Next sprint | Performance degradation, tech debt alert |
205
+
206
+ ### Useful Alert Patterns
207
+ - Error rate exceeds N% for M minutes
208
+ - Latency P99 exceeds threshold for M minutes
209
+ - Error budget burn rate > 1x for 1 hour (fast burn)
210
+ - Error budget burn rate > 0.1x for 6 hours (slow burn)
211
+ - Queue depth exceeds threshold (backpressure)
212
+ - Certificate expiry within N days
213
+ - Disk usage exceeds N%
214
+
215
+ ## Technology Selection
216
+
217
+ ### Logging
218
+ - **Node.js**: pino, winston, bunyan
219
+ - **Python**: structlog, python-json-logger
220
+ - **Go**: zerolog, zap, slog (stdlib)
221
+ - **Rust**: tracing, log + env_logger
222
+
223
+ ### Metrics
224
+ - **Prometheus** — Pull-based, widely adopted, great with Kubernetes
225
+ - **StatsD/Datadog** — Push-based, hosted
226
+ - **OpenTelemetry Metrics** — Vendor-neutral, emerging standard
227
+
228
+ ### Tracing
229
+ - **OpenTelemetry** — Vendor-neutral standard (recommended)
230
+ - **Jaeger** — Open-source trace backend
231
+ - **Zipkin** — Lightweight trace backend
232
+
233
+ ### Dashboards
234
+ - **Grafana** — Open-source, works with Prometheus/Loki/Tempo
235
+ - **Datadog** — Hosted all-in-one
236
+ - **New Relic** — Hosted APM
237
+
238
+ ## Checklist
239
+
240
+ When adding observability to a feature:
241
+ - [ ] Structured logging with correlation IDs at request boundaries
242
+ - [ ] Error logging with stack traces and context
243
+ - [ ] Business event logging (significant state changes)
244
+ - [ ] RED metrics for request-driven endpoints
245
+ - [ ] Histogram for latency-sensitive operations
246
+ - [ ] Trace spans for cross-service calls and database queries
247
+ - [ ] Health check endpoint updated if new dependency added
248
+ - [ ] No secrets or PII in logs
249
+ - [ ] Appropriate log levels (not everything is INFO)
250
+ - [ ] Dashboard updated with new metrics
251
+ - [ ] Alerts defined for SLO violations
@@ -0,0 +1,402 @@
1
+ ---
2
+ name: ui-design
3
+ description: Visual design principles, UI patterns, spacing systems, typography, color, motion, and professional polish for web interfaces
4
+ license: Apache-2.0
5
+ compatibility: opencode
6
+ ---
7
+
8
+ # UI Design Skill
9
+
10
+ This skill provides visual design patterns and aesthetic guidelines for building professionally designed web interfaces. It complements the `frontend-development` skill which covers engineering implementation.
11
+
12
+ ## When to Use
13
+
14
+ Use this skill when:
15
+ - Building new pages, layouts, or UI components from scratch
16
+ - Improving the visual quality or polish of an existing interface
17
+ - Implementing a design system or component library
18
+ - Making aesthetic decisions (colors, typography, spacing, motion)
19
+ - Creating landing pages, dashboards, or marketing pages
20
+
21
+ > For accessibility (WCAG, ARIA, keyboard navigation), see `frontend-development`.
22
+ > For component implementation patterns (React, Vue, Svelte), see `frontend-development`.
23
+
24
+ ## Visual Hierarchy & Layout
25
+
26
+ ### Scanning Patterns
27
+ - **F-pattern** — users scan left-to-right, then down the left edge. Place key content in the first two lines and along the left margin.
28
+ - **Z-pattern** — for minimal content pages (landing, hero). Place logo top-left, CTA top-right, key info bottom-left, action bottom-right.
29
+
30
+ ### Visual Weight
31
+ Elements draw attention through: **size** > **color/contrast** > **whitespace** > **position**. Use this hierarchy deliberately.
32
+
33
+ | Element | Size | Weight | Tailwind Example |
34
+ |---------|------|--------|-----------------|
35
+ | Page title (h1) | 36-48px | Bold (700-800) | `text-4xl font-bold` |
36
+ | Section heading (h2) | 24-30px | Semibold (600) | `text-2xl font-semibold` |
37
+ | Card title (h3) | 18-20px | Medium (500) | `text-lg font-medium` |
38
+ | Body text | 16px | Regular (400) | `text-base` |
39
+ | Caption / helper | 12-14px | Regular (400) | `text-sm text-gray-500` |
40
+ | Label / overline | 12px | Medium, uppercase | `text-xs font-medium uppercase tracking-wide` |
41
+
42
+ ### Content Density
43
+ - **Spacious** (marketing, landing pages) — generous whitespace, large type, one idea per section
44
+ - **Balanced** (SaaS apps, settings) — moderate padding, clear grouping
45
+ - **Dense** (dashboards, data tables, admin panels) — compact spacing, smaller type, more info per viewport
46
+
47
+ > **When to deviate:** Dense layouts are fine for power-user tools. Spacious layouts hurt productivity in data-heavy interfaces.
48
+
49
+ ## Spacing System
50
+
51
+ ### Default: 8px Base Unit
52
+
53
+ All spacing derives from an 8px base. This creates visual rhythm and alignment.
54
+
55
+ | Token | Value | Use For | Tailwind |
56
+ |-------|-------|---------|----------|
57
+ | `space-0.5` | 4px | Icon padding, tight inline gaps | `p-1`, `gap-1` |
58
+ | `space-1` | 8px | Inline element gaps, input padding | `p-2`, `gap-2` |
59
+ | `space-2` | 16px | Card inner padding, form field gaps | `p-4`, `gap-4` |
60
+ | `space-3` | 24px | Card padding, group spacing | `p-6`, `gap-6` |
61
+ | `space-4` | 32px | Section inner padding | `p-8`, `gap-8` |
62
+ | `space-5` | 48px | Section gaps | `py-12`, `gap-12` |
63
+ | `space-6` | 64px | Major section separation | `py-16`, `gap-16` |
64
+ | `space-7` | 96px | Hero/page section padding | `py-24` |
65
+
66
+ ### Container Widths
67
+ - **Prose content** — `max-w-prose` (65ch) for readable line lengths
68
+ - **Form content** — `max-w-lg` (512px) or `max-w-xl` (576px)
69
+ - **Dashboard content** — `max-w-7xl` (1280px) with side padding
70
+ - **Full-bleed sections** — no max-width, content inside a centered container
71
+
72
+ ### The Whitespace Rule
73
+ Generous whitespace signals professionalism. Cramped layouts signal amateur work. When in doubt, add more space between sections, not less.
74
+
75
+ > **When to deviate:** Data-dense UIs (spreadsheets, trading platforms, IDEs) intentionally minimize whitespace. Follow the density level appropriate for the use case.
76
+
77
+ ## Typography
78
+
79
+ ### Default Type Scale (1.25 ratio)
80
+
81
+ | Level | Size | Line Height | Weight | Tailwind |
82
+ |-------|------|-------------|--------|----------|
83
+ | Display | 48-60px | 1.1 | Bold (700) | `text-5xl font-bold leading-tight` |
84
+ | H1 | 36px | 1.2 | Bold (700) | `text-4xl font-bold leading-tight` |
85
+ | H2 | 30px | 1.25 | Semibold (600) | `text-3xl font-semibold` |
86
+ | H3 | 24px | 1.3 | Semibold (600) | `text-2xl font-semibold` |
87
+ | H4 | 20px | 1.4 | Medium (500) | `text-xl font-medium` |
88
+ | Body | 16px | 1.5-1.75 | Regular (400) | `text-base leading-relaxed` |
89
+ | Small | 14px | 1.5 | Regular (400) | `text-sm` |
90
+ | Caption | 12px | 1.5 | Regular (400) | `text-xs text-gray-500` |
91
+
92
+ ### Font Recommendations
93
+
94
+ | Project Type | Font | Tailwind Config |
95
+ |-------------|------|----------------|
96
+ | SaaS / Dashboard | Inter | `font-sans` with Inter loaded via Google Fonts or `@fontsource/inter` |
97
+ | Developer tools | Geist Sans + Geist Mono | Load via `@fontsource/geist-sans` |
98
+ | Marketing / Brand | System font stack | `font-sans` (default Tailwind) |
99
+ | Editorial / Blog | Serif pairing (e.g., Lora + Inter) | Custom `font-serif` in Tailwind config |
100
+
101
+ ### Rules
102
+ - **Max 2 font families** — one for headings (optional), one for body
103
+ - **Max 3 weights** — Regular (400), Medium (500), Bold (700)
104
+ - **Body line length** — 45-75 characters per line (`max-w-prose`)
105
+ - **Body line height** — 1.5 minimum for body text, 1.2-1.3 for headings
106
+
107
+ > **When to deviate:** Branding may require specific fonts. Always test readability at 16px body size. Never go below 14px for body text.
108
+
109
+ ## Color System
110
+
111
+ ### Default Palette Structure
112
+
113
+ ```
114
+ Primary → Brand color, CTAs, active states (1 hue, 50-950 scale)
115
+ Accent → Secondary actions, highlights (1 hue, optional)
116
+ Neutral → Text, backgrounds, borders (gray scale, 50-950)
117
+ Success → Confirmations, positive states (green)
118
+ Warning → Caution, attention needed (amber/yellow)
119
+ Error → Destructive actions, validation errors (red)
120
+ Info → Informational, neutral callouts (blue)
121
+ ```
122
+
123
+ ### Shade Scale Convention
124
+
125
+ Generate 50-950 shades for each color. Use the middle ranges (400-600) as the base, lighter shades for backgrounds, darker for text.
126
+
127
+ | Shade | Light Mode Use | Dark Mode Use |
128
+ |-------|---------------|---------------|
129
+ | 50 | Tinted backgrounds | — |
130
+ | 100 | Hover backgrounds | — |
131
+ | 200 | Borders, dividers | Text (muted) |
132
+ | 300 | — | Borders |
133
+ | 400 | — | Secondary text |
134
+ | 500 | Icons, secondary text | Icons |
135
+ | 600 | Primary text, buttons | Buttons, links |
136
+ | 700 | Headings | Body text |
137
+ | 800 | — | Headings |
138
+ | 900 | — | Primary text |
139
+ | 950 | — | Backgrounds (surface) |
140
+
141
+ ### Contrast Requirements
142
+ - **Normal text** — 4.5:1 minimum (WCAG AA)
143
+ - **Large text** (18px+ or 14px bold) — 3:1 minimum
144
+ - **UI components** (borders, icons, focus rings) — 3:1 minimum
145
+
146
+ ### Dark Mode
147
+ - Invert the neutral scale (light text on dark backgrounds)
148
+ - Reduce saturation by 10-20% — vivid colors are harsh on dark backgrounds
149
+ - Never use pure white (`#fff`) on pure black (`#000`) — use `gray-100` on `gray-900`
150
+ - Semantic colors: slightly lighter variants than light mode (e.g., `green-400` instead of `green-600`)
151
+
152
+ > **When to deviate:** Brand guidelines may dictate specific colors. Always verify contrast ratios. Use tools like Realtime Colors or Tailwind's built-in dark mode utilities.
153
+
154
+ ## Component Design Patterns
155
+
156
+ ### Cards
157
+
158
+ ```html
159
+ <!-- Standard card -->
160
+ <div class="rounded-xl border border-gray-200 bg-white p-6 shadow-sm">
161
+ <h3 class="text-lg font-semibold text-gray-900">Title</h3>
162
+ <p class="mt-2 text-sm leading-relaxed text-gray-600">Description</p>
163
+ </div>
164
+
165
+ <!-- Interactive card (clickable) -->
166
+ <div class="rounded-xl border border-gray-200 bg-white p-6 shadow-sm
167
+ transition-shadow duration-200 hover:shadow-md cursor-pointer">
168
+ <!-- content -->
169
+ </div>
170
+ ```
171
+
172
+ **Defaults:** `rounded-xl` (12px), `border-gray-200`, `shadow-sm`, `p-6` (24px padding).
173
+
174
+ ### Buttons
175
+
176
+ | Variant | Classes | Use For |
177
+ |---------|---------|---------|
178
+ | Primary | `bg-primary-600 text-white hover:bg-primary-700 rounded-lg px-4 py-2.5 font-medium text-sm` | Main actions |
179
+ | Secondary | `border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 rounded-lg px-4 py-2.5 font-medium text-sm` | Secondary actions |
180
+ | Ghost | `text-gray-600 hover:bg-gray-100 hover:text-gray-900 rounded-lg px-4 py-2.5 font-medium text-sm` | Tertiary actions |
181
+ | Destructive | `bg-red-600 text-white hover:bg-red-700 rounded-lg px-4 py-2.5 font-medium text-sm` | Delete, remove |
182
+
183
+ **States:** Always implement `disabled:opacity-50 disabled:cursor-not-allowed`. Loading state: replace text with a spinner + "Loading..." or keep the button width stable with a spinner replacing the icon.
184
+
185
+ ### Forms
186
+
187
+ - Labels **above** inputs (not inline, not floating)
188
+ - Consistent input height: `h-10` (40px) for default, `h-9` (36px) for compact
189
+ - Focus ring: `focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 focus:outline-none`
190
+ - Validation: inline error message below the field in `text-sm text-red-600`
191
+ - Group related fields with spacing `space-y-4` inside a section, `space-y-6` between sections
192
+
193
+ ### Navigation
194
+
195
+ | Pattern | When | Key Classes |
196
+ |---------|------|-------------|
197
+ | Top navbar | Marketing, simple apps | `sticky top-0 z-50 border-b bg-white/80 backdrop-blur` |
198
+ | Sidebar | Dashboards, admin, complex apps | `fixed inset-y-0 left-0 w-64 border-r bg-white` |
199
+ | Bottom tabs | Mobile-first apps | `fixed bottom-0 inset-x-0 border-t bg-white` |
200
+
201
+ **Active state:** Use `bg-primary-50 text-primary-700 font-medium` for sidebar items, `border-b-2 border-primary-600` for top nav tabs.
202
+
203
+ ### Tables
204
+
205
+ - Header: `bg-gray-50 text-xs font-medium uppercase tracking-wide text-gray-500`
206
+ - Rows: alternate `bg-white` / `bg-gray-50` or use `divide-y divide-gray-200`
207
+ - Sticky header: `sticky top-0 z-10`
208
+ - Mobile: horizontal scroll with `overflow-x-auto` or collapse to card layout below `md:`
209
+
210
+ ### Empty States
211
+
212
+ Always provide: illustration or icon + descriptive message + primary action CTA.
213
+
214
+ ```html
215
+ <div class="flex flex-col items-center justify-center py-12 text-center">
216
+ <div class="text-gray-400"><!-- icon or illustration --></div>
217
+ <h3 class="mt-4 text-lg font-medium text-gray-900">No projects yet</h3>
218
+ <p class="mt-2 text-sm text-gray-500">Get started by creating your first project.</p>
219
+ <button class="mt-6 rounded-lg bg-primary-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-primary-700">
220
+ Create Project
221
+ </button>
222
+ </div>
223
+ ```
224
+
225
+ ### Loading States
226
+
227
+ Prefer **skeleton loaders** over spinners — they communicate layout and reduce perceived wait time.
228
+
229
+ ```html
230
+ <!-- Skeleton card -->
231
+ <div class="animate-pulse rounded-xl border border-gray-200 bg-white p-6">
232
+ <div class="h-5 w-2/3 rounded bg-gray-200"></div>
233
+ <div class="mt-3 h-4 w-full rounded bg-gray-200"></div>
234
+ <div class="mt-2 h-4 w-4/5 rounded bg-gray-200"></div>
235
+ </div>
236
+ ```
237
+
238
+ Use spinners only for inline actions (button loading, saving indicator).
239
+
240
+ ## Shadows, Borders & Depth
241
+
242
+ ### Elevation Model
243
+
244
+ | Level | Use | Tailwind | When |
245
+ |-------|-----|----------|------|
246
+ | Base | Page background, inset content | — (no shadow) | Default state |
247
+ | Raised | Cards, panels | `shadow-sm` | Resting content containers |
248
+ | Floating | Dropdowns, popovers | `shadow-md` | Overlays triggered by interaction |
249
+ | Overlay | Modals, dialogs | `shadow-lg` | Full-screen overlays |
250
+ | Toast | Notifications, toasts | `shadow-xl` | Highest priority, topmost layer |
251
+
252
+ ### Defaults
253
+ - **Border radius** — `rounded-xl` (12px) for cards/modals, `rounded-lg` (8px) for buttons/inputs, `rounded-full` for avatars/pills
254
+ - **Borders** — `border border-gray-200` for separation, `border-2 border-primary-500` for emphasis/focus
255
+ - **Dividers** — `divide-y divide-gray-200` between list items
256
+
257
+ > **When to deviate:** Sharper radius (`rounded-md` or `rounded-lg`) suits enterprise/data-heavy UIs. Softer radius (`rounded-2xl`, `rounded-3xl`) suits consumer/playful products.
258
+
259
+ ## Responsive Design
260
+
261
+ ### Mobile-First Approach
262
+
263
+ Write styles for mobile first, then layer on complexity at larger breakpoints.
264
+
265
+ | Breakpoint | Tailwind | Target |
266
+ |-----------|----------|--------|
267
+ | Default | — | Mobile (320-639px) |
268
+ | `sm:` | 640px | Large phones / small tablets |
269
+ | `md:` | 768px | Tablets |
270
+ | `lg:` | 1024px | Laptops |
271
+ | `xl:` | 1280px | Desktops |
272
+ | `2xl:` | 1536px | Large monitors |
273
+
274
+ ### Fluid Typography
275
+
276
+ Use `clamp()` for font sizes that scale smoothly without breakpoints:
277
+
278
+ ```html
279
+ <!-- Fluid heading: 24px at 320px viewport → 48px at 1280px viewport -->
280
+ <h1 class="text-[clamp(1.5rem,1rem+2.5vw,3rem)] font-bold">Heading</h1>
281
+ ```
282
+
283
+ ### Responsive Patterns
284
+
285
+ | Mobile | Desktop | Pattern |
286
+ |--------|---------|---------|
287
+ | Stacked cards | Grid `md:grid-cols-2 lg:grid-cols-3` | Card layout |
288
+ | Hamburger menu | Full navbar | Navigation |
289
+ | Bottom sheet | Sidebar | Secondary nav |
290
+ | Full-width table scroll | Standard table | Data display |
291
+ | Tabs (horizontal scroll) | Sidebar tabs | Settings/filters |
292
+
293
+ ### Touch Targets
294
+ - Minimum **44x44px** for all interactive elements on mobile
295
+ - Use `min-h-[44px] min-w-[44px]` or adequate padding
296
+
297
+ ## Motion & Animation
298
+
299
+ ### Purpose
300
+ Motion should **communicate**, not decorate. Use it for: feedback (click/hover), relationships (parent-child), and state transitions (loading → loaded).
301
+
302
+ ### Duration Scale
303
+
304
+ | Type | Duration | Easing | Use For |
305
+ |------|----------|--------|---------|
306
+ | Micro | 100-150ms | `ease-out` | Hover, focus, toggle, color change |
307
+ | Standard | 200-300ms | `ease-in-out` | Panel open/close, accordion, tab switch |
308
+ | Emphasis | 300-500ms | `ease-out` | Page transition, modal enter, hero animation |
309
+
310
+ ### Common Patterns
311
+
312
+ ```html
313
+ <!-- Fade in on mount -->
314
+ <div class="animate-in fade-in duration-300">Content</div>
315
+
316
+ <!-- Hover scale for interactive cards -->
317
+ <div class="transition-transform duration-200 hover:scale-[1.02]">Card</div>
318
+
319
+ <!-- Smooth color transitions (always add to interactive elements) -->
320
+ <button class="transition-colors duration-150">Button</button>
321
+
322
+ <!-- Skeleton shimmer -->
323
+ <div class="animate-pulse bg-gray-200 rounded">Loading...</div>
324
+ ```
325
+
326
+ ### Reduced Motion (MANDATORY)
327
+
328
+ Always respect user preferences:
329
+
330
+ ```html
331
+ <div class="motion-safe:animate-in motion-safe:fade-in motion-reduce:opacity-100">
332
+ Content
333
+ </div>
334
+ ```
335
+
336
+ Or in CSS: `@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition-duration: 0.01ms !important; } }`
337
+
338
+ > **When to deviate:** Skip animations entirely for data-heavy apps where performance matters more than polish. Loading indicators (spinners, progress bars) should always animate regardless of preference.
339
+
340
+ ## Page Composition Templates
341
+
342
+ ### Landing Page
343
+ ```
344
+ Hero (headline + subheadline + CTA + visual) → py-24, text-center or split layout
345
+ Social proof (logos, "trusted by" bar) → py-8, grayscale logos, border-y
346
+ Features grid (3-4 cards or icon + text blocks) → py-16, grid-cols-3
347
+ Detailed feature (alternating text + image) → py-16, repeat 2-3x
348
+ Testimonials (quotes in cards or carousel) → py-16, bg-gray-50
349
+ CTA repeat (same CTA as hero) → py-16, text-center
350
+ Footer (links, legal, social) → py-8, border-t, text-sm
351
+ ```
352
+
353
+ ### Dashboard
354
+ ```
355
+ Sidebar (w-64, fixed left, logo + nav links)
356
+ Top bar (sticky, breadcrumb + search + user menu)
357
+ Main content:
358
+ KPI row (grid-cols-4, stat cards) → gap-6
359
+ Primary content (charts, tables, activity) → grid-cols-1 or grid-cols-2
360
+ ```
361
+
362
+ ### Settings / Admin
363
+ ```
364
+ Sidebar nav (vertical tabs or grouped links)
365
+ Content area:
366
+ Section heading + description → border-b, pb-6
367
+ Form group (labeled inputs) → space-y-4
368
+ Action buttons (right-aligned Save/Cancel) → pt-6, flex justify-end gap-3
369
+ ```
370
+
371
+ ### Blog / Article
372
+ ```
373
+ Header (title + meta + author) → max-w-prose, mx-auto
374
+ Body (prose content) → max-w-prose, prose class
375
+ TOC sidebar (sticky, lg:block hidden) → fixed right, top-24
376
+ ```
377
+
378
+ ### Authentication
379
+ ```
380
+ Centered card on subtle background → min-h-screen, flex items-center justify-center
381
+ Card (max-w-sm, logo + form + links) → rounded-xl, shadow-lg, p-8
382
+ Minimal distractions (no nav, no footer)
383
+ ```
384
+
385
+ ## Professional Polish Checklist
386
+
387
+ Before shipping any UI, verify:
388
+
389
+ - [ ] **Spacing** — all spacing uses the defined scale (no arbitrary pixel values)
390
+ - [ ] **Typography** — max 3 visible text sizes per view, consistent weight usage
391
+ - [ ] **Color** — all colors from the defined palette, no one-off hex values
392
+ - [ ] **Interactive states** — hover, focus, active, disabled on every clickable element
393
+ - [ ] **Loading states** — skeleton or spinner for all async content
394
+ - [ ] **Empty states** — message + action for every zero-data view
395
+ - [ ] **Error states** — inline validation, toast/alert for API errors, error pages (404, 500)
396
+ - [ ] **Responsive** — tested at mobile (375px), tablet (768px), desktop (1280px)
397
+ - [ ] **Motion** — subtle transitions on interactive elements, `prefers-reduced-motion` respected
398
+ - [ ] **Contrast** — all text passes WCAG AA (4.5:1 normal, 3:1 large)
399
+ - [ ] **Border radius** — consistent across all components (same family of values)
400
+ - [ ] **Shadows** — used consistently per the elevation model
401
+ - [ ] **Favicon & metadata** — page titles, favicon, OG tags set
402
+ - [ ] **Content** — no Lorem Ipsum in production, realistic placeholder data