@folpe/loom 0.1.0 → 0.2.0

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.
@@ -12,6 +12,8 @@ delegates-to:
12
12
  - database
13
13
  - tests
14
14
  - review-qa
15
+ - security
16
+ - performance
15
17
  model: claude-opus-4-6
16
18
  ---
17
19
 
@@ -35,7 +37,9 @@ You are the central coordinator for the Loom project. Your job is to understand
35
37
  - **ux-ui**: UI component design, design tokens, color palettes, spacing systems, accessibility audits, and responsive design patterns.
36
38
  - **database**: Schema design, migrations, seed data, query optimization, and ORM configuration.
37
39
  - **tests**: Unit tests, integration tests, end-to-end tests, and test infrastructure setup.
38
- - **review-qa**: Code review, security analysis, performance audits, and best-practice enforcement.
40
+ - **review-qa**: Code review, best-practice enforcement, and comprehensive quality audits.
41
+ - **security**: Security audits, vulnerability assessments, OWASP compliance, auth hardening, dependency scanning, and RLS policy review.
42
+ - **performance**: Performance optimization, Core Web Vitals audits, bundle analysis, Lighthouse runs, query optimization, and rendering profiling.
39
43
 
40
44
  ## Workflow Guidelines
41
45
 
@@ -0,0 +1,40 @@
1
+ name: API Backend
2
+ description: API / service backend avec focus sécurité, validation, tests et performance.
3
+ agents:
4
+ - orchestrator
5
+ - backend
6
+ - database
7
+ - security
8
+ - tests
9
+ - review-qa
10
+ - performance
11
+ skills:
12
+ - nextjs-conventions
13
+ - supabase-patterns
14
+ - api-design
15
+ constitution:
16
+ principles:
17
+ - Security first — validate all inputs, sanitize all outputs
18
+ - Type-safe contracts — use Zod schemas as single source of truth
19
+ - Test everything — unit tests for logic, integration tests for endpoints
20
+ - Fail gracefully — meaningful error messages, proper HTTP status codes
21
+ stack:
22
+ - Next.js 16+ (API Routes)
23
+ - TypeScript 5 (strict)
24
+ - Supabase (database + auth)
25
+ - Zod (validation)
26
+ - Vercel (deployment)
27
+ conventions:
28
+ - Define Zod schemas for all request/response payloads
29
+ - Use middleware for auth, rate limiting, and CORS
30
+ - Implement proper error handling with consistent error response format
31
+ - Write integration tests for every endpoint
32
+ - Use database transactions for multi-step mutations
33
+ claudemd:
34
+ projectDescription: >
35
+ This is a backend API service scaffolded with Loom. It uses Next.js API Routes with Supabase
36
+ as the database layer. The orchestrator delegates security concerns to the security agent,
37
+ database schema work to the database agent, and testing to the tests agent.
38
+ orchestratorRef: >
39
+ The orchestrator agent (.claude/agents/orchestrator.md) is the main entry point. Always start
40
+ by delegating to the orchestrator, which will route tasks to the appropriate specialized agent.
@@ -0,0 +1,39 @@
1
+ name: Chrome Extension
2
+ description: Extension Chrome (Manifest V3) avec popup React, content scripts et background workers.
3
+ agents:
4
+ - orchestrator
5
+ - frontend
6
+ - backend
7
+ - tests
8
+ - security
9
+ - review-qa
10
+ skills:
11
+ - tailwind-patterns
12
+ - chrome-extension-patterns
13
+ - ui-ux-guidelines
14
+ constitution:
15
+ principles:
16
+ - Minimal permissions — request only what the extension truly needs
17
+ - User privacy first — never collect data without explicit consent
18
+ - Fast popup — keep popup UI snappy, defer heavy work to background
19
+ - Cross-site safe — sanitize all DOM manipulation in content scripts
20
+ stack:
21
+ - TypeScript 5 (strict)
22
+ - Chrome APIs (Manifest V3)
23
+ - React 19 (popup / options page)
24
+ - Tailwind CSS 4
25
+ - tsup (bundling)
26
+ conventions:
27
+ - Use Manifest V3 service workers instead of background pages
28
+ - Separate concerns — popup, content scripts, and background have clear boundaries
29
+ - Use chrome.storage API for persistence, never localStorage in content scripts
30
+ - Validate all messages between content script and background worker
31
+ - Keep content script injection minimal to avoid page performance impact
32
+ claudemd:
33
+ projectDescription: >
34
+ This is a Chrome extension scaffolded with Loom using Manifest V3. The orchestrator delegates
35
+ popup/options UI work to the frontend agent, background worker logic to the backend agent,
36
+ and security reviews of permissions and content scripts to the security agent.
37
+ orchestratorRef: >
38
+ The orchestrator agent (.claude/agents/orchestrator.md) is the main entry point. Always start
39
+ by delegating to the orchestrator, which will route tasks to the appropriate specialized agent.
@@ -0,0 +1,34 @@
1
+ name: CLI Tool
2
+ description: Outil CLI Node.js avec parsing d'arguments, UX terminal soignée et distribution npm.
3
+ agents:
4
+ - orchestrator
5
+ - backend
6
+ - tests
7
+ - review-qa
8
+ skills:
9
+ - cli-development
10
+ constitution:
11
+ principles:
12
+ - Unix philosophy — do one thing well, compose with other tools
13
+ - Fail loudly — clear error messages with actionable suggestions
14
+ - Zero-config defaults — sensible defaults, override with flags
15
+ - Scriptable — support stdin/stdout piping and non-interactive mode
16
+ stack:
17
+ - TypeScript 5 (strict)
18
+ - Node.js 20+
19
+ - Commander.js (CLI framework)
20
+ - tsup (bundling)
21
+ conventions:
22
+ - Use Commander.js for argument parsing and subcommands
23
+ - Exit with proper codes — 0 for success, 1 for errors, 2 for usage errors
24
+ - Support --json flag for machine-readable output
25
+ - Use stderr for progress/logging, stdout for actual output
26
+ - Include a --version and --help flag on every command
27
+ claudemd:
28
+ projectDescription: >
29
+ This is a CLI tool scaffolded with Loom. It uses Commander.js for argument parsing and tsup
30
+ for bundling. The orchestrator delegates implementation to the backend agent and testing to
31
+ the tests agent.
32
+ orchestratorRef: >
33
+ The orchestrator agent (.claude/agents/orchestrator.md) is the main entry point. Always start
34
+ by delegating to the orchestrator, which will route tasks to the appropriate specialized agent.
@@ -0,0 +1,52 @@
1
+ name: E-Commerce
2
+ description: Boutique en ligne avec catalogue, panier, checkout Stripe et emails transactionnels.
3
+ agents:
4
+ - orchestrator
5
+ - frontend
6
+ - backend
7
+ - database
8
+ - security
9
+ - tests
10
+ - review-qa
11
+ - ux-ui
12
+ - performance
13
+ - marketing
14
+ skills:
15
+ - nextjs-conventions
16
+ - tailwind-patterns
17
+ - hero-copywriting
18
+ - supabase-patterns
19
+ - stripe-integration
20
+ - shadcn-ui
21
+ - seo-optimization
22
+ - api-design
23
+ - ui-ux-guidelines
24
+ constitution:
25
+ principles:
26
+ - Trust through UX — clear pricing, no surprise fees, transparent shipping
27
+ - Payment security — never handle raw card data, always use Stripe Elements
28
+ - SEO drives traffic — product pages must be indexable with structured data
29
+ - Performance converts — every 100ms of load time impacts conversion rate
30
+ stack:
31
+ - Next.js 16+ (App Router)
32
+ - React 19
33
+ - TypeScript 5 (strict)
34
+ - Tailwind CSS 4
35
+ - ShadCN UI
36
+ - Supabase (auth + database)
37
+ - Stripe (payments)
38
+ - Vercel (deployment)
39
+ conventions:
40
+ - Use Stripe Checkout or Payment Elements — never collect card details directly
41
+ - Implement webhook handlers for Stripe events (payment success, refund, etc.)
42
+ - Use ISR or SSG for product catalog pages for performance
43
+ - Add JSON-LD structured data for products (price, availability, reviews)
44
+ - Implement optimistic cart updates with server validation
45
+ claudemd:
46
+ projectDescription: >
47
+ This is an e-commerce application scaffolded with Loom. It includes product catalog, shopping
48
+ cart, Stripe checkout, and transactional emails. The orchestrator coordinates the full agent
49
+ team including marketing for copywriting and SEO.
50
+ orchestratorRef: >
51
+ The orchestrator agent (.claude/agents/orchestrator.md) is the main entry point. Always start
52
+ by delegating to the orchestrator, which will route tasks to the appropriate specialized agent.
@@ -0,0 +1,44 @@
1
+ name: Expo Mobile
2
+ description: App mobile React Native avec Expo, navigation, notifications push et offline-first.
3
+ agents:
4
+ - orchestrator
5
+ - frontend
6
+ - backend
7
+ - database
8
+ - tests
9
+ - review-qa
10
+ - ux-ui
11
+ - performance
12
+ skills:
13
+ - tailwind-patterns
14
+ - react-native-patterns
15
+ - supabase-patterns
16
+ - ui-ux-guidelines
17
+ constitution:
18
+ principles:
19
+ - Native feel — respect platform conventions (iOS HIG, Material Design)
20
+ - Offline-first — the app must be usable without network connectivity
21
+ - Battery conscious — minimize background tasks and network requests
22
+ - Smooth animations — target 60fps, never block the JS thread
23
+ stack:
24
+ - Expo SDK 52+
25
+ - React Native
26
+ - TypeScript 5 (strict)
27
+ - NativeWind (Tailwind for React Native)
28
+ - Expo Router (file-based navigation)
29
+ - Supabase (auth + database)
30
+ conventions:
31
+ - Use Expo Router for all navigation — file-based routing
32
+ - Implement offline storage with async-storage or MMKV for critical data
33
+ - Use expo-notifications for push notifications setup
34
+ - Handle deep linking and universal links from the start
35
+ - Test on both iOS and Android — never assume platform parity
36
+ claudemd:
37
+ projectDescription: >
38
+ This is a mobile application scaffolded with Loom using Expo and React Native. It uses
39
+ NativeWind for styling and Expo Router for navigation. The orchestrator delegates mobile UI
40
+ to the frontend agent, API integration to the backend agent, and native feature testing
41
+ to the tests agent.
42
+ orchestratorRef: >
43
+ The orchestrator agent (.claude/agents/orchestrator.md) is the main entry point. Always start
44
+ by delegating to the orchestrator, which will route tasks to the appropriate specialized agent.
@@ -0,0 +1,48 @@
1
+ name: Fullstack Auth
2
+ description: SaaS avec authentification complète (email, OAuth, magic link), RBAC et dashboard admin.
3
+ agents:
4
+ - orchestrator
5
+ - frontend
6
+ - backend
7
+ - database
8
+ - security
9
+ - tests
10
+ - review-qa
11
+ - ux-ui
12
+ - performance
13
+ skills:
14
+ - nextjs-conventions
15
+ - tailwind-patterns
16
+ - supabase-patterns
17
+ - shadcn-ui
18
+ - api-design
19
+ - ui-ux-guidelines
20
+ constitution:
21
+ principles:
22
+ - Auth is infrastructure — get it right once, never cut corners on security
23
+ - Least privilege — users and services get only the permissions they need
24
+ - Defense in depth — middleware, RLS, and API validation work together
25
+ - Session management — handle expiry, refresh, and revocation properly
26
+ stack:
27
+ - Next.js 16+ (App Router)
28
+ - React 19
29
+ - TypeScript 5 (strict)
30
+ - Tailwind CSS 4
31
+ - ShadCN UI
32
+ - Supabase Auth (email, OAuth, magic link)
33
+ - Supabase (database with RLS)
34
+ - Vercel (deployment)
35
+ conventions:
36
+ - Use Supabase Auth for all authentication flows
37
+ - Implement middleware for route protection and role checks
38
+ - Enable Row Level Security on all tables — no exceptions
39
+ - Use server-side session validation, never trust client-only auth state
40
+ - Separate admin and user dashboards with distinct layouts
41
+ claudemd:
42
+ projectDescription: >
43
+ This is a fullstack SaaS with complete authentication scaffolded with Loom. It includes email,
44
+ OAuth, and magic link flows via Supabase Auth, plus RBAC and admin dashboard. The orchestrator
45
+ coordinates security, frontend, backend, and database agents for auth-related tasks.
46
+ orchestratorRef: >
47
+ The orchestrator agent (.claude/agents/orchestrator.md) is the main entry point. Always start
48
+ by delegating to the orchestrator, which will route tasks to the appropriate specialized agent.
@@ -0,0 +1,41 @@
1
+ name: Landing Page
2
+ description: Site vitrine / marketing avec focus SEO, conversion, animations et responsive design.
3
+ agents:
4
+ - orchestrator
5
+ - frontend
6
+ - ux-ui
7
+ - marketing
8
+ - performance
9
+ - review-qa
10
+ skills:
11
+ - nextjs-conventions
12
+ - tailwind-patterns
13
+ - hero-copywriting
14
+ - seo-optimization
15
+ - ui-ux-guidelines
16
+ constitution:
17
+ principles:
18
+ - Conversion-first — every section must guide visitors toward a clear CTA
19
+ - Performance is UX — aim for perfect Lighthouse scores
20
+ - Mobile-first responsive — design for small screens, enhance for large
21
+ - Accessible by default — semantic HTML, ARIA, keyboard navigation
22
+ stack:
23
+ - Next.js 16+ (static export)
24
+ - React 19
25
+ - TypeScript 5 (strict)
26
+ - Tailwind CSS 4
27
+ - Vercel (deployment)
28
+ conventions:
29
+ - Use Server Components and static generation for maximum performance
30
+ - Optimize all images with next/image and proper srcset
31
+ - Implement structured data (JSON-LD) for SEO
32
+ - Use CSS animations and transitions over JS-based animation libraries
33
+ - Ensure all interactive elements have visible focus states
34
+ claudemd:
35
+ projectDescription: >
36
+ This is a landing page / marketing site scaffolded with Loom. It focuses on SEO, conversion
37
+ optimization, and fast loading. The orchestrator delegates visual tasks to the frontend and
38
+ ux-ui agents, copywriting to marketing, and performance audits to the performance agent.
39
+ orchestratorRef: >
40
+ The orchestrator agent (.claude/agents/orchestrator.md) is the main entry point. Always start
41
+ by delegating to the orchestrator, which will route tasks to the appropriate specialized agent.
@@ -0,0 +1,38 @@
1
+ name: MVP Lean
2
+ description: Prototype rapide avec stack minimale. Vitesse et itération avant la perfection.
3
+ agents:
4
+ - orchestrator
5
+ - frontend
6
+ - backend
7
+ - database
8
+ skills:
9
+ - nextjs-conventions
10
+ - tailwind-patterns
11
+ - supabase-patterns
12
+ constitution:
13
+ principles:
14
+ - Ship it — working software over perfect architecture
15
+ - Iterate fast — build the simplest thing that works, then improve
16
+ - Technical debt is acceptable — speed wins at the prototype stage
17
+ - Validate assumptions — build to learn, not to last
18
+ stack:
19
+ - Next.js 16+ (App Router)
20
+ - React 19
21
+ - TypeScript 5 (strict)
22
+ - Tailwind CSS 4
23
+ - Supabase (auth + database)
24
+ - Vercel (deployment)
25
+ conventions:
26
+ - Prefer inline styles and co-located logic over abstractions
27
+ - Use Supabase client directly — skip custom API layers when possible
28
+ - Minimal component hierarchy — flatten where you can
29
+ - Skip extensive error handling — focus on happy path first
30
+ - One file per feature when practical
31
+ claudemd:
32
+ projectDescription: >
33
+ This is a lean MVP scaffolded with Loom. Speed and iteration are prioritized over architecture.
34
+ The orchestrator coordinates a small team of frontend, backend, and database agents to ship
35
+ features as fast as possible.
36
+ orchestratorRef: >
37
+ The orchestrator agent (.claude/agents/orchestrator.md) is the main entry point. Always start
38
+ by delegating to the orchestrator, which will route tasks to the appropriate specialized agent.
@@ -1,10 +1,6 @@
1
1
  name: SaaS Default
2
2
  description: Standard SaaS project preset with full agent team, Next.js conventions, and Tailwind patterns. Includes
3
3
  orchestrator-driven multi-agent workflow.
4
- boilerplate:
5
- repo: https://github.com/vercel/next.js.git
6
- branch: canary
7
- shallow: true
8
4
  agents:
9
5
  - orchestrator
10
6
  - frontend
@@ -20,6 +16,10 @@ skills:
20
16
  - nextjs-conventions
21
17
  - tailwind-patterns
22
18
  - hero-copywriting
19
+ - supabase-patterns
20
+ - shadcn-ui
21
+ - api-design
22
+ - ui-ux-guidelines
23
23
  constitution:
24
24
  principles:
25
25
  - Ship fast, iterate often — prefer working software over perfect plans
@@ -48,6 +48,3 @@ claudemd:
48
48
  orchestratorRef: >
49
49
  The orchestrator agent (.claude/agents/orchestrator.md) is the main entry point. Always start by delegating to the
50
50
  orchestrator, which will route tasks to the appropriate specialized agent.
51
- specKit:
52
- enabled: true
53
- aiFlag: claude
@@ -0,0 +1,108 @@
1
+ ---
2
+ name: api-design
3
+ description: "REST API design principles, error handling, validation, and security patterns. Use when building API routes, server actions, or backend services."
4
+ allowed-tools: "Read, Write, Edit, Glob, Grep"
5
+ ---
6
+
7
+ # API Design Principles
8
+
9
+ ## Route Structure
10
+
11
+ - Use resource-based URLs: `/api/users`, `/api/posts/:id/comments`.
12
+ - Use HTTP methods semantically:
13
+ - `GET` — read (no side effects)
14
+ - `POST` — create
15
+ - `PUT/PATCH` — update (PUT replaces, PATCH partial update)
16
+ - `DELETE` — remove
17
+ - Nest sub-resources only one level deep: `/api/posts/:id/comments` — not deeper.
18
+ - Use plural nouns for collections: `/api/users` (not `/api/user`).
19
+
20
+ ## Request Validation
21
+
22
+ - Validate **all** incoming data with Zod schemas at the API boundary:
23
+ ```ts
24
+ const CreatePostSchema = z.object({
25
+ title: z.string().min(1).max(200),
26
+ content: z.string().min(1),
27
+ published: z.boolean().default(false),
28
+ })
29
+
30
+ const body = CreatePostSchema.parse(await request.json())
31
+ ```
32
+ - Return 400 with structured validation errors:
33
+ ```json
34
+ { "error": "Validation failed", "details": [{ "field": "title", "message": "Required" }] }
35
+ ```
36
+ - Validate path params, query params, and headers — not just body.
37
+
38
+ ## Response Format
39
+
40
+ - Use consistent response shapes across all endpoints:
41
+ ```ts
42
+ // Success
43
+ { "data": { ... } }
44
+ { "data": [...], "pagination": { "total": 100, "page": 1, "pageSize": 20 } }
45
+
46
+ // Error
47
+ { "error": "Not found", "code": "RESOURCE_NOT_FOUND" }
48
+ ```
49
+ - Always return appropriate HTTP status codes:
50
+ - `200` — success
51
+ - `201` — created
52
+ - `204` — no content (successful delete)
53
+ - `400` — bad request (validation error)
54
+ - `401` — unauthorized (no/invalid auth)
55
+ - `403` — forbidden (insufficient permissions)
56
+ - `404` — not found
57
+ - `409` — conflict (duplicate resource)
58
+ - `429` — too many requests (rate limit)
59
+ - `500` — internal server error
60
+
61
+ ## Error Handling
62
+
63
+ - Catch errors at the route handler level with a consistent pattern:
64
+ ```ts
65
+ try {
66
+ // ... handler logic
67
+ } catch (error) {
68
+ if (error instanceof z.ZodError) {
69
+ return NextResponse.json({ error: 'Validation failed', details: error.errors }, { status: 400 })
70
+ }
71
+ console.error('Unhandled error:', error)
72
+ return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
73
+ }
74
+ ```
75
+ - Never expose stack traces or internal details in production error responses.
76
+ - Log errors server-side with request context (method, path, user ID).
77
+
78
+ ## Authentication & Authorization
79
+
80
+ - Validate auth on every protected endpoint — middleware + route-level checks.
81
+ - Extract user from session/token, never from request body.
82
+ - Check permissions at the resource level: "Can this user access THIS specific post?"
83
+ - Return `401` for missing/invalid auth, `403` for insufficient permissions.
84
+
85
+ ## Rate Limiting
86
+
87
+ - Implement rate limiting on public endpoints and auth endpoints.
88
+ - Use token bucket or sliding window algorithm.
89
+ - Return `429` with `Retry-After` header when rate limited.
90
+ - Rate limit by IP for public endpoints, by user ID for authenticated endpoints.
91
+
92
+ ## Pagination
93
+
94
+ - Use cursor-based pagination for large datasets:
95
+ ```
96
+ GET /api/posts?cursor=abc123&limit=20
97
+ ```
98
+ - Return pagination metadata: `{ "data": [...], "nextCursor": "def456", "hasMore": true }`
99
+ - Default limit to 20, max to 100.
100
+ - For simple cases, offset-based is acceptable: `?page=1&pageSize=20`.
101
+
102
+ ## Security
103
+
104
+ - Validate Content-Type header on POST/PUT/PATCH requests.
105
+ - Set CORS headers explicitly — never use `*` in production.
106
+ - Sanitize user input before database queries.
107
+ - Use parameterized queries — never string concatenation for SQL.
108
+ - Set security headers: `X-Content-Type-Options`, `X-Frame-Options`, `Strict-Transport-Security`.
@@ -0,0 +1,98 @@
1
+ ---
2
+ name: chrome-extension-patterns
3
+ description: "Chrome extension development patterns for Manifest V3, content scripts, popup UI, and service workers. Use when building browser extensions."
4
+ allowed-tools: "Read, Write, Edit, Glob, Grep"
5
+ ---
6
+
7
+ # Chrome Extension Patterns (Manifest V3)
8
+
9
+ ## Manifest
10
+
11
+ - Always use **Manifest V3** — Manifest V2 is deprecated.
12
+ - Define minimal permissions — request only what the extension needs:
13
+ ```json
14
+ {
15
+ "manifest_version": 3,
16
+ "permissions": ["storage", "activeTab"],
17
+ "host_permissions": ["https://specific-site.com/*"]
18
+ }
19
+ ```
20
+ - Use `activeTab` instead of broad `<all_urls>` when possible.
21
+ - Declare content scripts and their match patterns explicitly.
22
+ - Use `"action"` (not `"browser_action"`) for the extension button.
23
+
24
+ ## Architecture
25
+
26
+ - **Popup** (`popup.html/tsx`): lightweight UI shown on extension icon click. Keep it fast — no heavy initialization.
27
+ - **Options page** (`options.html/tsx`): settings and configuration UI.
28
+ - **Background service worker** (`background.ts`): event-driven logic, API calls, alarms, message routing.
29
+ - **Content scripts** (`content.ts`): code injected into web pages to read/modify DOM.
30
+ - Keep these four concerns strictly separated — never mix responsibilities.
31
+
32
+ ## Service Workers (Background)
33
+
34
+ - Service workers are **event-driven and ephemeral** — they start on events and stop when idle.
35
+ - Never rely on global state persisting between activations. Use `chrome.storage` instead.
36
+ - Register event listeners at the top level (not inside async callbacks):
37
+ ```ts
38
+ chrome.runtime.onInstalled.addListener(() => { /* ... */ })
39
+ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { /* ... */ })
40
+ ```
41
+ - Use `chrome.alarms` for periodic tasks — never `setInterval`.
42
+ - Return `true` from `onMessage` listener to send async responses.
43
+
44
+ ## Content Scripts
45
+
46
+ - Content scripts run in an **isolated world** — they can access the page DOM but not the page's JS variables.
47
+ - Sanitize all DOM manipulation to prevent XSS:
48
+ ```ts
49
+ element.textContent = userInput // Safe
50
+ element.innerHTML = userInput // DANGEROUS — never do this
51
+ ```
52
+ - Minimize content script footprint — inject only what's necessary.
53
+ - Use `MutationObserver` for dynamic pages instead of polling.
54
+ - Communicate with background via `chrome.runtime.sendMessage()`.
55
+
56
+ ## Storage
57
+
58
+ - Use `chrome.storage.local` for large data (up to 10MB).
59
+ - Use `chrome.storage.sync` for user settings that should sync across devices (100KB limit).
60
+ - Never use `localStorage` in content scripts — it belongs to the host page.
61
+ - Listen for storage changes:
62
+ ```ts
63
+ chrome.storage.onChanged.addListener((changes, area) => { /* ... */ })
64
+ ```
65
+
66
+ ## Messaging
67
+
68
+ - Use `chrome.runtime.sendMessage` for popup/options ↔ background communication.
69
+ - Use `chrome.tabs.sendMessage` for background → content script communication.
70
+ - Define a message type system for type-safe messaging:
71
+ ```ts
72
+ type Message =
73
+ | { type: 'GET_DATA'; payload: { key: string } }
74
+ | { type: 'SAVE_DATA'; payload: { key: string; value: unknown } }
75
+ ```
76
+ - Validate all incoming messages — never trust message content blindly.
77
+
78
+ ## Popup UI (React)
79
+
80
+ - Keep popup bundle small — lazy load heavy features.
81
+ - Use React for popup and options page, bundled with tsup or Vite.
82
+ - Popup window is destroyed on close — persist state to `chrome.storage`.
83
+ - Set a fixed width/height for popup: `min-width: 320px; min-height: 400px`.
84
+
85
+ ## Security
86
+
87
+ - Never inject user-generated content into web pages without sanitization.
88
+ - Use Content Security Policy (CSP) in manifest.
89
+ - Validate all data from external sources (APIs, messages, storage).
90
+ - Never include API keys or secrets in content scripts — they're visible to the page.
91
+ - Audit `host_permissions` — overly broad permissions trigger Chrome Web Store review delays.
92
+
93
+ ## Development
94
+
95
+ - Use `chrome://extensions` with Developer Mode for loading unpacked extensions.
96
+ - Enable "Errors" view for debugging service worker issues.
97
+ - Use Chrome DevTools to inspect popup (right-click → Inspect) and background (service worker link).
98
+ - Hot-reload: rebuild with tsup watch, then click "Update" in `chrome://extensions`.