@caddis/cli 0.0.0 → 0.1.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.
Files changed (153) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -1
  3. package/bundles/antigravity-plugin/agents/code-reviewer.md +47 -0
  4. package/bundles/antigravity-plugin/agents/preflight.md +53 -0
  5. package/bundles/antigravity-plugin/guard_agy.py +338 -0
  6. package/bundles/antigravity-plugin/hooks.json +36 -0
  7. package/bundles/antigravity-plugin/mcp_config.json +8 -0
  8. package/bundles/antigravity-plugin/mcp_ping_server.py +55 -0
  9. package/bundles/antigravity-plugin/plugin.json +5 -0
  10. package/bundles/antigravity-plugin/session_end_agy.py +57 -0
  11. package/bundles/antigravity-plugin/skills/_registry.md +115 -0
  12. package/bundles/antigravity-plugin/skills/add-rules/SKILL.md +45 -0
  13. package/bundles/antigravity-plugin/skills/api-design/SKILL.md +249 -0
  14. package/bundles/antigravity-plugin/skills/backend-development/SKILL.md +305 -0
  15. package/bundles/antigravity-plugin/skills/best-practices/SKILL.md +500 -0
  16. package/bundles/antigravity-plugin/skills/best-practices/agents/best-practices-referencer.md +263 -0
  17. package/bundles/antigravity-plugin/skills/best-practices/agents/codebase-context-builder.md +326 -0
  18. package/bundles/antigravity-plugin/skills/best-practices/agents/task-intent-analyzer.md +245 -0
  19. package/bundles/antigravity-plugin/skills/best-practices/references/anti-patterns.md +571 -0
  20. package/bundles/antigravity-plugin/skills/best-practices/references/before-after-examples.md +1114 -0
  21. package/bundles/antigravity-plugin/skills/best-practices/references/best-practices-guide.md +513 -0
  22. package/bundles/antigravity-plugin/skills/best-practices/references/common-workflows.md +692 -0
  23. package/bundles/antigravity-plugin/skills/best-practices/references/prompt-patterns.md +547 -0
  24. package/bundles/antigravity-plugin/skills/brainstorming/SKILL.md +57 -0
  25. package/bundles/antigravity-plugin/skills/ci-cd-pipeline/SKILL.md +315 -0
  26. package/bundles/antigravity-plugin/skills/code-documentation/SKILL.md +271 -0
  27. package/bundles/antigravity-plugin/skills/code-review/SKILL.md +122 -0
  28. package/bundles/antigravity-plugin/skills/codebase-audit/SKILL.md +204 -0
  29. package/bundles/antigravity-plugin/skills/context-curator/SKILL.md +157 -0
  30. package/bundles/antigravity-plugin/skills/cross-review/SKILL.md +40 -0
  31. package/bundles/antigravity-plugin/skills/css-architecture/SKILL.md +305 -0
  32. package/bundles/antigravity-plugin/skills/css-architecture/references/RESPONSIVE-DESIGN.md +604 -0
  33. package/bundles/antigravity-plugin/skills/database-design/SKILL.md +177 -0
  34. package/bundles/antigravity-plugin/skills/db-diagram/SKILL.md +148 -0
  35. package/bundles/antigravity-plugin/skills/db-diagram/scripts/sql_to_graph.py +1212 -0
  36. package/bundles/antigravity-plugin/skills/digress/SKILL.md +61 -0
  37. package/bundles/antigravity-plugin/skills/draw-io/SKILL.md +162 -0
  38. package/bundles/antigravity-plugin/skills/draw-io/references/aws-icons.md +677 -0
  39. package/bundles/antigravity-plugin/skills/draw-io/references/layout-guidelines.md +142 -0
  40. package/bundles/antigravity-plugin/skills/draw-io/references/troubleshooting.md +118 -0
  41. package/bundles/antigravity-plugin/skills/draw-io/references/workflows.md +103 -0
  42. package/bundles/antigravity-plugin/skills/draw-io/scripts/convert-drawio-to-png.sh +25 -0
  43. package/bundles/antigravity-plugin/skills/draw-io/scripts/find_aws_icon.py +79 -0
  44. package/bundles/antigravity-plugin/skills/error-handling/SKILL.md +260 -0
  45. package/bundles/antigravity-plugin/skills/excalidraw-db/SKILL.md +38 -0
  46. package/bundles/antigravity-plugin/skills/fastapi-dev/SKILL.md +300 -0
  47. package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +198 -0
  48. package/bundles/antigravity-plugin/skills/frontend-design/SKILL.md +193 -0
  49. package/bundles/antigravity-plugin/skills/frontend-design/references/my-tech-stack.md +127 -0
  50. package/bundles/antigravity-plugin/skills/gh-cli/SKILL.md +195 -0
  51. package/bundles/antigravity-plugin/skills/git-commit/SKILL.md +285 -0
  52. package/bundles/antigravity-plugin/skills/golden-plan/SKILL.md +577 -0
  53. package/bundles/antigravity-plugin/skills/handoff/SKILL.md +100 -0
  54. package/bundles/antigravity-plugin/skills/implement/SKILL.md +114 -0
  55. package/bundles/antigravity-plugin/skills/javascript-typescript/SKILL.md +142 -0
  56. package/bundles/antigravity-plugin/skills/kb/SKILL.md +60 -0
  57. package/bundles/antigravity-plugin/skills/mermaid-db/SKILL.md +33 -0
  58. package/bundles/antigravity-plugin/skills/mermaid-diagrams/SKILL.md +236 -0
  59. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/ENHANCEMENTS.md +264 -0
  60. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/MERMAID-SUMMARY.md +137 -0
  61. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/advanced-features.md +556 -0
  62. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/architecture-diagrams.md +192 -0
  63. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/c4-diagrams.md +410 -0
  64. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/class-diagrams.md +361 -0
  65. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/erd-diagrams.md +510 -0
  66. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/flowcharts.md +450 -0
  67. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/sequence-diagrams.md +394 -0
  68. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/troubleshooting.md +335 -0
  69. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/workflows.md +418 -0
  70. package/bundles/antigravity-plugin/skills/migrate-dir/SKILL.md +68 -0
  71. package/bundles/antigravity-plugin/skills/mockup/SKILL.md +242 -0
  72. package/bundles/antigravity-plugin/skills/particle-art/SKILL.md +243 -0
  73. package/bundles/antigravity-plugin/skills/particle-art/references/canvas-utils.ts +171 -0
  74. package/bundles/antigravity-plugin/skills/particle-art/references/dot-field.template.tsx +203 -0
  75. package/bundles/antigravity-plugin/skills/particle-art/references/flow-field.template.tsx +263 -0
  76. package/bundles/antigravity-plugin/skills/particle-art/references/node-shape.template.tsx +261 -0
  77. package/bundles/antigravity-plugin/skills/particle-art/references/shape-sampler.ts +281 -0
  78. package/bundles/antigravity-plugin/skills/particle-art/references/stipple-morph.template.tsx +167 -0
  79. package/bundles/antigravity-plugin/skills/particle-art/references/stipple.template.tsx +175 -0
  80. package/bundles/antigravity-plugin/skills/particle-art/references/trail-ghost.template.tsx +266 -0
  81. package/bundles/antigravity-plugin/skills/particle-art/references/usage-examples.md +320 -0
  82. package/bundles/antigravity-plugin/skills/playwright/API_REFERENCE.md +653 -0
  83. package/bundles/antigravity-plugin/skills/playwright/SKILL.md +454 -0
  84. package/bundles/antigravity-plugin/skills/playwright/lib/helpers.js +441 -0
  85. package/bundles/antigravity-plugin/skills/playwright/package.json +26 -0
  86. package/bundles/antigravity-plugin/skills/playwright/run.js +228 -0
  87. package/bundles/antigravity-plugin/skills/prd/SKILL.md +107 -0
  88. package/bundles/antigravity-plugin/skills/preflight/SKILL.md +435 -0
  89. package/bundles/antigravity-plugin/skills/python/SKILL.md +388 -0
  90. package/bundles/antigravity-plugin/skills/react-best-practices/SKILL.md +269 -0
  91. package/bundles/antigravity-plugin/skills/react-dev/README.md +404 -0
  92. package/bundles/antigravity-plugin/skills/react-dev/SKILL.md +459 -0
  93. package/bundles/antigravity-plugin/skills/react-dev/examples/generic-components.md +579 -0
  94. package/bundles/antigravity-plugin/skills/react-dev/examples/server-components.md +579 -0
  95. package/bundles/antigravity-plugin/skills/react-dev/references/event-handlers.md +574 -0
  96. package/bundles/antigravity-plugin/skills/react-dev/references/hooks.md +456 -0
  97. package/bundles/antigravity-plugin/skills/react-dev/references/react-19-patterns.md +638 -0
  98. package/bundles/antigravity-plugin/skills/react-dev/references/react-router.md +1002 -0
  99. package/bundles/antigravity-plugin/skills/react-dev/references/tanstack-router.md +587 -0
  100. package/bundles/antigravity-plugin/skills/refactoring/SKILL.md +486 -0
  101. package/bundles/antigravity-plugin/skills/resume/SKILL.md +36 -0
  102. package/bundles/antigravity-plugin/skills/security-review/SKILL.md +196 -0
  103. package/bundles/antigravity-plugin/skills/setup-project-ai/SKILL.md +61 -0
  104. package/bundles/antigravity-plugin/skills/ship/SKILL.md +107 -0
  105. package/bundles/antigravity-plugin/skills/ship-merge/SKILL.md +103 -0
  106. package/bundles/antigravity-plugin/skills/ship-pr/SKILL.md +102 -0
  107. package/bundles/antigravity-plugin/skills/skill-creator/LICENSE.txt +202 -0
  108. package/bundles/antigravity-plugin/skills/skill-creator/SKILL.md +491 -0
  109. package/bundles/antigravity-plugin/skills/skill-creator/agents/analyzer.md +274 -0
  110. package/bundles/antigravity-plugin/skills/skill-creator/agents/comparator.md +202 -0
  111. package/bundles/antigravity-plugin/skills/skill-creator/agents/grader.md +223 -0
  112. package/bundles/antigravity-plugin/skills/skill-creator/assets/eval_review.html +146 -0
  113. package/bundles/antigravity-plugin/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  114. package/bundles/antigravity-plugin/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  115. package/bundles/antigravity-plugin/skills/skill-creator/references/schemas.md +430 -0
  116. package/bundles/antigravity-plugin/skills/skill-creator/scripts/__init__.py +0 -0
  117. package/bundles/antigravity-plugin/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  118. package/bundles/antigravity-plugin/skills/skill-creator/scripts/generate_report.py +326 -0
  119. package/bundles/antigravity-plugin/skills/skill-creator/scripts/improve_description.py +247 -0
  120. package/bundles/antigravity-plugin/skills/skill-creator/scripts/package_skill.py +136 -0
  121. package/bundles/antigravity-plugin/skills/skill-creator/scripts/quick_validate.py +103 -0
  122. package/bundles/antigravity-plugin/skills/skill-creator/scripts/run_eval.py +310 -0
  123. package/bundles/antigravity-plugin/skills/skill-creator/scripts/run_loop.py +328 -0
  124. package/bundles/antigravity-plugin/skills/skill-creator/scripts/utils.py +47 -0
  125. package/bundles/antigravity-plugin/skills/sql/SKILL.md +321 -0
  126. package/bundles/antigravity-plugin/skills/tdd/SKILL.md +37 -0
  127. package/bundles/antigravity-plugin/skills/tdd-workflow/SKILL.md +188 -0
  128. package/bundles/antigravity-plugin/skills/technical-writing/SKILL.md +286 -0
  129. package/bundles/antigravity-plugin/skills/test-strategy/SKILL.md +155 -0
  130. package/bundles/antigravity-plugin/skills/ui-brief/SKILL.md +84 -0
  131. package/bundles/antigravity-plugin/skills/ui-review/SKILL.md +176 -0
  132. package/bundles/antigravity-plugin/skills/ui-review/references/framework-fixes.md +471 -0
  133. package/bundles/antigravity-plugin/skills/ui-review/references/visual-checklist.md +236 -0
  134. package/bundles/antigravity-plugin/skills/usage-review/SKILL.md +77 -0
  135. package/bundles/antigravity-plugin/skills/use-model/SKILL.md +64 -0
  136. package/bundles/antigravity-plugin/skills/using-git-worktrees/SKILL.md +217 -0
  137. package/bundles/antigravity-plugin/skills/version/SKILL.md +18 -0
  138. package/bundles/antigravity-plugin/skills/warm-editorial-ui/DESIGN_TOKENS.md +487 -0
  139. package/bundles/antigravity-plugin/skills/warm-editorial-ui/IMPLEMENTATION_GUIDE.md +177 -0
  140. package/bundles/antigravity-plugin/skills/warm-editorial-ui/SKILL.md +732 -0
  141. package/bundles/antigravity-plugin/skills/webapp-testing/LICENSE.txt +202 -0
  142. package/bundles/antigravity-plugin/skills/webapp-testing/SKILL.md +97 -0
  143. package/bundles/antigravity-plugin/skills/webapp-testing/examples/console_logging.py +35 -0
  144. package/bundles/antigravity-plugin/skills/webapp-testing/examples/element_discovery.py +40 -0
  145. package/bundles/antigravity-plugin/skills/webapp-testing/examples/static_html_automation.py +33 -0
  146. package/bundles/antigravity-plugin/skills/webapp-testing/scripts/with_server.py +106 -0
  147. package/bundles/antigravity-plugin/skills/windows-deployment/SKILL.md +880 -0
  148. package/bundles/antigravity-plugin/skills/writing-plans/SKILL.md +384 -0
  149. package/bundles/antigravity-plugin/statusline-command-agy.sh +91 -0
  150. package/bundles/antigravity-plugin/warm_start_agy.py +149 -0
  151. package/bundles/manifest.json +6 -0
  152. package/dist/cli.js +5363 -0
  153. package/package.json +61 -4
@@ -0,0 +1,454 @@
1
+ ---
2
+ name: playwright
3
+ context: fork
4
+ description: Complete browser automation with Playwright. Auto-detects dev servers, writes clean test scripts to /tmp. Test pages, fill forms, take screenshots, check responsive design, validate UX, test login flows, check links, automate any browser task. Use when user wants to test websites, automate browser interactions, validate web functionality, or perform any browser-based testing.
5
+ ---
6
+
7
+ **IMPORTANT - Path Resolution:**
8
+ This skill can be installed in different locations (plugin system, manual installation, global, or project-specific). Before executing any commands, determine the skill directory based on where you loaded this SKILL.md file, and use that path in all commands below. Replace `$SKILL_DIR` with the actual discovered path.
9
+
10
+ Common installation paths:
11
+
12
+ - Plugin system: `~/.claude/plugins/marketplaces/playwright-skill/skills/playwright-skill`
13
+ - Manual global: `~/.claude/skills/playwright-skill`
14
+ - Project-specific: `<project>/.claude/skills/playwright-skill`
15
+
16
+ # Playwright Browser Automation
17
+
18
+ General-purpose browser automation skill. I'll write custom Playwright code for any automation task you request and execute it via the universal executor.
19
+
20
+ **CRITICAL WORKFLOW - Follow these steps in order:**
21
+
22
+ 1. **Auto-detect dev servers** - For localhost testing, ALWAYS run server detection FIRST:
23
+
24
+ ```bash
25
+ cd $SKILL_DIR && node -e "require('./lib/helpers').detectDevServers().then(servers => console.log(JSON.stringify(servers)))"
26
+ ```
27
+
28
+ - If **1 server found**: Use it automatically, inform user
29
+ - If **multiple servers found**: Ask user which one to test
30
+ - If **no servers found**: Ask for URL or offer to help start dev server
31
+
32
+ 2. **Write scripts to /tmp** - NEVER write test files to skill directory; always use `/tmp/playwright-test-*.js`
33
+
34
+ 3. **Use visible browser by default** - Always use `headless: false` unless user specifically requests headless mode
35
+
36
+ 4. **Parameterize URLs** - Always make URLs configurable via environment variable or constant at top of script
37
+
38
+ ## How It Works
39
+
40
+ 1. You describe what you want to test/automate
41
+ 2. I auto-detect running dev servers (or ask for URL if testing external site)
42
+ 3. I write custom Playwright code in `/tmp/playwright-test-*.js` (won't clutter your project)
43
+ 4. I execute it via: `cd $SKILL_DIR && node run.js /tmp/playwright-test-*.js`
44
+ 5. Results displayed in real-time, browser window visible for debugging
45
+ 6. Test files auto-cleaned from /tmp by your OS
46
+
47
+ ## Setup (First Time)
48
+
49
+ ```bash
50
+ cd $SKILL_DIR
51
+ npm run setup
52
+ ```
53
+
54
+ This installs Playwright and Chromium browser. Only needed once.
55
+
56
+ ## Execution Pattern
57
+
58
+ **Step 1: Detect dev servers (for localhost testing)**
59
+
60
+ ```bash
61
+ cd $SKILL_DIR && node -e "require('./lib/helpers').detectDevServers().then(s => console.log(JSON.stringify(s)))"
62
+ ```
63
+
64
+ **Step 2: Write test script to /tmp with URL parameter**
65
+
66
+ ```javascript
67
+ // /tmp/playwright-test-page.js
68
+ const { chromium } = require('playwright');
69
+
70
+ // Parameterized URL (detected or user-provided)
71
+ const TARGET_URL = 'http://localhost:3001'; // <-- Auto-detected or from user
72
+
73
+ (async () => {
74
+ const browser = await chromium.launch({ headless: false });
75
+ const page = await browser.newPage();
76
+
77
+ await page.goto(TARGET_URL);
78
+ console.log('Page loaded:', await page.title());
79
+
80
+ await page.screenshot({ path: '/tmp/screenshot.png', fullPage: true });
81
+ console.log('📸 Screenshot saved to /tmp/screenshot.png');
82
+
83
+ await browser.close();
84
+ })();
85
+ ```
86
+
87
+ **Step 3: Execute from skill directory**
88
+
89
+ ```bash
90
+ cd $SKILL_DIR && node run.js /tmp/playwright-test-page.js
91
+ ```
92
+
93
+ ## Common Patterns
94
+
95
+ ### Test a Page (Multiple Viewports)
96
+
97
+ ```javascript
98
+ // /tmp/playwright-test-responsive.js
99
+ const { chromium } = require('playwright');
100
+
101
+ const TARGET_URL = 'http://localhost:3001'; // Auto-detected
102
+
103
+ (async () => {
104
+ const browser = await chromium.launch({ headless: false, slowMo: 100 });
105
+ const page = await browser.newPage();
106
+
107
+ // Desktop test
108
+ await page.setViewportSize({ width: 1920, height: 1080 });
109
+ await page.goto(TARGET_URL);
110
+ console.log('Desktop - Title:', await page.title());
111
+ await page.screenshot({ path: '/tmp/desktop.png', fullPage: true });
112
+
113
+ // Mobile test
114
+ await page.setViewportSize({ width: 375, height: 667 });
115
+ await page.screenshot({ path: '/tmp/mobile.png', fullPage: true });
116
+
117
+ await browser.close();
118
+ })();
119
+ ```
120
+
121
+ ### Test Login Flow
122
+
123
+ ```javascript
124
+ // /tmp/playwright-test-login.js
125
+ const { chromium } = require('playwright');
126
+
127
+ const TARGET_URL = 'http://localhost:3001'; // Auto-detected
128
+
129
+ (async () => {
130
+ const browser = await chromium.launch({ headless: false });
131
+ const page = await browser.newPage();
132
+
133
+ await page.goto(`${TARGET_URL}/login`);
134
+
135
+ await page.fill('input[name="email"]', 'test@example.com');
136
+ await page.fill('input[name="password"]', 'password123');
137
+ await page.click('button[type="submit"]');
138
+
139
+ // Wait for redirect
140
+ await page.waitForURL('**/dashboard');
141
+ console.log('✅ Login successful, redirected to dashboard');
142
+
143
+ await browser.close();
144
+ })();
145
+ ```
146
+
147
+ ### Fill and Submit Form
148
+
149
+ ```javascript
150
+ // /tmp/playwright-test-form.js
151
+ const { chromium } = require('playwright');
152
+
153
+ const TARGET_URL = 'http://localhost:3001'; // Auto-detected
154
+
155
+ (async () => {
156
+ const browser = await chromium.launch({ headless: false, slowMo: 50 });
157
+ const page = await browser.newPage();
158
+
159
+ await page.goto(`${TARGET_URL}/contact`);
160
+
161
+ await page.fill('input[name="name"]', 'John Doe');
162
+ await page.fill('input[name="email"]', 'john@example.com');
163
+ await page.fill('textarea[name="message"]', 'Test message');
164
+ await page.click('button[type="submit"]');
165
+
166
+ // Verify submission
167
+ await page.waitForSelector('.success-message');
168
+ console.log('✅ Form submitted successfully');
169
+
170
+ await browser.close();
171
+ })();
172
+ ```
173
+
174
+ ### Check for Broken Links
175
+
176
+ ```javascript
177
+ const { chromium } = require('playwright');
178
+
179
+ (async () => {
180
+ const browser = await chromium.launch({ headless: false });
181
+ const page = await browser.newPage();
182
+
183
+ await page.goto('http://localhost:3000');
184
+
185
+ const links = await page.locator('a[href^="http"]').all();
186
+ const results = { working: 0, broken: [] };
187
+
188
+ for (const link of links) {
189
+ const href = await link.getAttribute('href');
190
+ try {
191
+ const response = await page.request.head(href);
192
+ if (response.ok()) {
193
+ results.working++;
194
+ } else {
195
+ results.broken.push({ url: href, status: response.status() });
196
+ }
197
+ } catch (e) {
198
+ results.broken.push({ url: href, error: e.message });
199
+ }
200
+ }
201
+
202
+ console.log(`✅ Working links: ${results.working}`);
203
+ console.log(`❌ Broken links:`, results.broken);
204
+
205
+ await browser.close();
206
+ })();
207
+ ```
208
+
209
+ ### Take Screenshot with Error Handling
210
+
211
+ ```javascript
212
+ const { chromium } = require('playwright');
213
+
214
+ (async () => {
215
+ const browser = await chromium.launch({ headless: false });
216
+ const page = await browser.newPage();
217
+
218
+ try {
219
+ await page.goto('http://localhost:3000', {
220
+ waitUntil: 'networkidle',
221
+ timeout: 10000,
222
+ });
223
+
224
+ await page.screenshot({
225
+ path: '/tmp/screenshot.png',
226
+ fullPage: true,
227
+ });
228
+
229
+ console.log('📸 Screenshot saved to /tmp/screenshot.png');
230
+ } catch (error) {
231
+ console.error('❌ Error:', error.message);
232
+ } finally {
233
+ await browser.close();
234
+ }
235
+ })();
236
+ ```
237
+
238
+ ### Test Responsive Design
239
+
240
+ ```javascript
241
+ // /tmp/playwright-test-responsive-full.js
242
+ const { chromium } = require('playwright');
243
+
244
+ const TARGET_URL = 'http://localhost:3001'; // Auto-detected
245
+
246
+ (async () => {
247
+ const browser = await chromium.launch({ headless: false });
248
+ const page = await browser.newPage();
249
+
250
+ const viewports = [
251
+ { name: 'Desktop', width: 1920, height: 1080 },
252
+ { name: 'Tablet', width: 768, height: 1024 },
253
+ { name: 'Mobile', width: 375, height: 667 },
254
+ ];
255
+
256
+ for (const viewport of viewports) {
257
+ console.log(
258
+ `Testing ${viewport.name} (${viewport.width}x${viewport.height})`,
259
+ );
260
+
261
+ await page.setViewportSize({
262
+ width: viewport.width,
263
+ height: viewport.height,
264
+ });
265
+
266
+ await page.goto(TARGET_URL);
267
+ await page.waitForTimeout(1000);
268
+
269
+ await page.screenshot({
270
+ path: `/tmp/${viewport.name.toLowerCase()}.png`,
271
+ fullPage: true,
272
+ });
273
+ }
274
+
275
+ console.log('✅ All viewports tested');
276
+ await browser.close();
277
+ })();
278
+ ```
279
+
280
+ ## Inline Execution (Simple Tasks)
281
+
282
+ For quick one-off tasks, you can execute code inline without creating files:
283
+
284
+ ```bash
285
+ # Take a quick screenshot
286
+ cd $SKILL_DIR && node run.js "
287
+ const browser = await chromium.launch({ headless: false });
288
+ const page = await browser.newPage();
289
+ await page.goto('http://localhost:3001');
290
+ await page.screenshot({ path: '/tmp/quick-screenshot.png', fullPage: true });
291
+ console.log('Screenshot saved');
292
+ await browser.close();
293
+ "
294
+ ```
295
+
296
+ **When to use inline vs files:**
297
+
298
+ - **Inline**: Quick one-off tasks (screenshot, check if element exists, get page title)
299
+ - **Files**: Complex tests, responsive design checks, anything user might want to re-run
300
+
301
+ ## Available Helpers
302
+
303
+ Optional utility functions in `lib/helpers.js`:
304
+
305
+ ```javascript
306
+ const helpers = require('./lib/helpers');
307
+
308
+ // Detect running dev servers (CRITICAL - use this first!)
309
+ const servers = await helpers.detectDevServers();
310
+ console.log('Found servers:', servers);
311
+
312
+ // Safe click with retry
313
+ await helpers.safeClick(page, 'button.submit', { retries: 3 });
314
+
315
+ // Safe type with clear
316
+ await helpers.safeType(page, '#username', 'testuser');
317
+
318
+ // Take timestamped screenshot
319
+ await helpers.takeScreenshot(page, 'test-result');
320
+
321
+ // Handle cookie banners
322
+ await helpers.handleCookieBanner(page);
323
+
324
+ // Extract table data
325
+ const data = await helpers.extractTableData(page, 'table.results');
326
+ ```
327
+
328
+ See `lib/helpers.js` for full list.
329
+
330
+ ## Custom HTTP Headers
331
+
332
+ Configure custom headers for all HTTP requests via environment variables. Useful for:
333
+
334
+ - Identifying automated traffic to your backend
335
+ - Getting LLM-optimized responses (e.g., plain text errors instead of styled HTML)
336
+ - Adding authentication tokens globally
337
+
338
+ ### Configuration
339
+
340
+ **Single header (common case):**
341
+
342
+ ```bash
343
+ PW_HEADER_NAME=X-Automated-By PW_HEADER_VALUE=playwright-skill \
344
+ cd $SKILL_DIR && node run.js /tmp/my-script.js
345
+ ```
346
+
347
+ **Multiple headers (JSON format):**
348
+
349
+ ```bash
350
+ PW_EXTRA_HEADERS='{"X-Automated-By":"playwright-skill","X-Debug":"true"}' \
351
+ cd $SKILL_DIR && node run.js /tmp/my-script.js
352
+ ```
353
+
354
+ ### How It Works
355
+
356
+ Headers are automatically applied when using `helpers.createContext()`:
357
+
358
+ ```javascript
359
+ const context = await helpers.createContext(browser);
360
+ const page = await context.newPage();
361
+ // All requests from this page include your custom headers
362
+ ```
363
+
364
+ For scripts using raw Playwright API, use the injected `getContextOptionsWithHeaders()`:
365
+
366
+ ```javascript
367
+ const context = await browser.newContext(
368
+ getContextOptionsWithHeaders({ viewport: { width: 1920, height: 1080 } }),
369
+ );
370
+ ```
371
+
372
+ ## Advanced Usage
373
+
374
+ For comprehensive Playwright API documentation, see [API_REFERENCE.md](API_REFERENCE.md):
375
+
376
+ - Selectors & Locators best practices
377
+ - Network interception & API mocking
378
+ - Authentication & session management
379
+ - Visual regression testing
380
+ - Mobile device emulation
381
+ - Performance testing
382
+ - Debugging techniques
383
+ - CI/CD integration
384
+
385
+ ## Tips
386
+
387
+ - **CRITICAL: Detect servers FIRST** - Always run `detectDevServers()` before writing test code for localhost testing
388
+ - **Custom headers** - Use `PW_HEADER_NAME`/`PW_HEADER_VALUE` env vars to identify automated traffic to your backend
389
+ - **Use /tmp for test files** - Write to `/tmp/playwright-test-*.js`, never to skill directory or user's project
390
+ - **Parameterize URLs** - Put detected/provided URL in a `TARGET_URL` constant at the top of every script
391
+ - **DEFAULT: Visible browser** - Always use `headless: false` unless user explicitly asks for headless mode
392
+ - **Headless mode** - Only use `headless: true` when user specifically requests "headless" or "background" execution
393
+ - **Slow down:** Use `slowMo: 100` to make actions visible and easier to follow
394
+ - **Wait strategies:** Use `waitForURL`, `waitForSelector`, `waitForLoadState` instead of fixed timeouts
395
+ - **Error handling:** Always use try-catch for robust automation
396
+ - **Console output:** Use `console.log()` to track progress and show what's happening
397
+
398
+ ## Troubleshooting
399
+
400
+ **Playwright not installed:**
401
+
402
+ ```bash
403
+ cd $SKILL_DIR && npm run setup
404
+ ```
405
+
406
+ **Module not found:**
407
+ Ensure running from skill directory via `run.js` wrapper
408
+
409
+ **Browser doesn't open:**
410
+ Check `headless: false` and ensure display available
411
+
412
+ **Element not found:**
413
+ Add wait: `await page.waitForSelector('.element', { timeout: 10000 })`
414
+
415
+ ## Example Usage
416
+
417
+ ```
418
+ User: "Test if the marketing page looks good"
419
+
420
+ Claude: I'll test the marketing page across multiple viewports. Let me first detect running servers...
421
+ [Runs: detectDevServers()]
422
+ [Output: Found server on port 3001]
423
+ I found your dev server running on http://localhost:3001
424
+
425
+ [Writes custom automation script to /tmp/playwright-test-marketing.js with URL parameterized]
426
+ [Runs: cd $SKILL_DIR && node run.js /tmp/playwright-test-marketing.js]
427
+ [Shows results with screenshots from /tmp/]
428
+ ```
429
+
430
+ ```
431
+ User: "Check if login redirects correctly"
432
+
433
+ Claude: I'll test the login flow. First, let me check for running servers...
434
+ [Runs: detectDevServers()]
435
+ [Output: Found servers on ports 3000 and 3001]
436
+ I found 2 dev servers. Which one should I test?
437
+ - http://localhost:3000
438
+ - http://localhost:3001
439
+
440
+ User: "Use 3001"
441
+
442
+ [Writes login automation to /tmp/playwright-test-login.js]
443
+ [Runs: cd $SKILL_DIR && node run.js /tmp/playwright-test-login.js]
444
+ [Reports: ✅ Login successful, redirected to /dashboard]
445
+ ```
446
+
447
+ ## Notes
448
+
449
+ - Each automation is custom-written for your specific request
450
+ - Not limited to pre-built scripts - any browser task possible
451
+ - Auto-detects running dev servers to eliminate hardcoded URLs
452
+ - Test scripts written to `/tmp` for automatic cleanup (no clutter)
453
+ - Code executes reliably with proper module resolution via `run.js`
454
+ - Progressive disclosure - API_REFERENCE.md loaded only when advanced features needed