@playcraft/cli 0.0.41 → 0.0.42

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/dist/commands/tools-generation.js +2 -4
  2. package/dist/commands/tools-utils.js +19 -0
  3. package/dist/utils/version-checker.js +8 -11
  4. package/package.json +3 -3
  5. package/project-template/.claude/agents/designer.md +12 -8
  6. package/project-template/.claude/agents/developer.md +53 -62
  7. package/project-template/.claude/agents/refs/README.md +21 -15
  8. package/project-template/.claude/agents/refs/designer-deliverable-spec.md +24 -0
  9. package/project-template/.claude/agents/refs/designer-master-composite-recipes.md +20 -28
  10. package/project-template/.claude/agents/refs/developer-phase1-flow.md +81 -156
  11. package/project-template/.claude/agents/refs/pm-workflow-detail.md +6 -0
  12. package/project-template/.claude/agents/refs/reviewer-convergence-eval.md +130 -0
  13. package/project-template/.claude/agents/refs/reviewer-six-dimension-eval.md +4 -284
  14. package/project-template/.claude/agents/refs/ta-atlas-deliverable-standard.md +27 -6
  15. package/project-template/.claude/agents/refs/ta-pipeline-cookbook.md +433 -24
  16. package/project-template/.claude/agents/reviewer.md +62 -38
  17. package/project-template/.claude/agents/technical-artist.md +36 -25
  18. package/project-template/.claude/hooks/README.md +9 -1
  19. package/project-template/.claude/hooks/validate-workflow-stop.mjs +86 -1
  20. package/project-template/.claude/settings.json +4 -0
  21. package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +65 -15
  22. package/project-template/.claude/skills/playcraft-storyboard/SKILL.md +26 -7
  23. package/project-template/.claude/skills/playcraft-workflow/SKILL.md +104 -15
  24. package/project-template/.claude/skills/playwright-cli/SKILL.md +390 -0
  25. package/project-template/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
  26. package/project-template/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
  27. package/project-template/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
  28. package/project-template/.claude/skills/playwright-cli/references/running-code.md +240 -0
  29. package/project-template/.claude/skills/playwright-cli/references/session-management.md +226 -0
  30. package/project-template/.claude/skills/playwright-cli/references/spec-driven-testing.md +312 -0
  31. package/project-template/.claude/skills/playwright-cli/references/storage-state.md +275 -0
  32. package/project-template/.claude/skills/playwright-cli/references/test-generation.md +138 -0
  33. package/project-template/.claude/skills/playwright-cli/references/tracing.md +142 -0
  34. package/project-template/.claude/skills/playwright-cli/references/video-recording.md +157 -0
  35. package/project-template/.cursor/rules/playcraft-orchestrator.mdc +74 -24
  36. package/project-template/.cursor/rules/playcraft-subagent-boundary.mdc +1 -1
  37. package/project-template/CLAUDE.md +99 -59
  38. package/project-template/docs/team/agent-conduct.md +42 -26
  39. package/project-template/docs/team/atom-plan-format.md +33 -2
  40. package/project-template/docs/team/collaboration.md +57 -48
  41. package/project-template/docs/team/workflow-changelog.md +28 -14
  42. package/project-template/docs/team/workflow-consistency-checklist.md +12 -0
  43. package/project-template/templates/atom-plan.template.md +35 -3
  44. package/project-template/templates/designer-log.template.md +16 -0
  45. package/project-template/templates/developer-log.template.md +95 -101
  46. package/project-template/templates/layout-spec.template.md +14 -0
  47. package/project-template/templates/project-state.template.md +51 -33
  48. package/project-template/templates/review-report.template.md +76 -151
  49. package/project-template/templates/ta-log.template.md +138 -0
@@ -22,10 +22,59 @@ triggers: 构建游戏,开始开发,创建项目,选择组件,选择 skill,查
22
22
  - `gate_pending` 非 null 且 `waiting_for: user_gate` 时:**只跑 Gate**,不得 invoke 子 Agent
23
23
  - `subagent_stop: true` 时:只执行 `next_orchestrator_action`
24
24
  - Gate #1 / #2a / #2b:`AskUserQuestion`(子 Agent 更新 handoff 后 STOP)
25
- - Gate #3:Reviewer 通过后展示 **devUrl**(用户只点链,不跑 `npm run dev`)
25
+ - **Gate #1 / #2b 前**:先 invoke `@reviewer design_check`(软性 checklist)
26
+ - Gate #3:Reviewer `load_check` 通过后展示 **devUrl**(用户只点链;玩法由用户判断)
26
27
  - Gate / handoff 细则:`docs/team/collaboration.md` § Gate Protocol、§ Agent Handoff
27
- 6. `devStatus: ready` → `@reviewer`;`devStatus: blocked_upstream` → 按 `devBlockers.routeTo` 调度 TA/Designer → 再 `@developer`
28
- 7. 当前交付终点 = 用户在 Dev URL 验收通过(`done`),**不要求** `playcraft build`
28
+ 6. `devStatus: ui_ready` → `@reviewer ui_diff`;`ui_rework` → 按 report 修复 → 再 `@reviewer ui_diff`
29
+ 7. `devStatus: ready` `@reviewer load_check` Gate #3
30
+ 8. `devStatus: blocked_upstream` → 按 `devBlockers.routeTo` 调度 TA/Designer → 再 `@developer`
31
+ 9. 当前交付终点 = 用户在 Dev URL 验收通过(`done`),**不要求** `playcraft build`
32
+
33
+ ### ⚠️ Orchestrator 调度原则:传 WHAT 不传 HOW
34
+
35
+ **Orchestrator 不是全知全能的指挥官。** 不要在调度时给子 Agent 写详细步骤——子 Agent 有完整的 `.claude/agents/<role>.md` + `refs/` + 相关 Skills。
36
+
37
+ **正确的调度方式:**
38
+
39
+ ```
40
+ @technical-artist
41
+ 目标:完成 atom-plan.json 中所有 assignTo: TA 的 atoms。
42
+ 注意:atom-plan.json → skillsMatch.mediaGroups 有 3 个预制图片资产可复用,优先 link。
43
+ ```
44
+
45
+ **错误的调度方式(越俎代庖):**
46
+
47
+ ```
48
+ @technical-artist
49
+ 1. 先生成 tile_01.png,用绿幕...
50
+ 2. 然后 remove-background --tolerance 25...
51
+ 3. 接着 resize 到 128x128...
52
+ ```
53
+
54
+ **原则:**
55
+
56
+ - Orchestrator 只传递 **目标 + 约束 + 关键提醒**(如 mediaGroups 可用)
57
+ - 子 Agent 自己读 `refs/` + Skills 找到正确方法论
58
+ - Orchestrator 在 sub-agent STOP 后 **验证结果**(atom status 是否更新、Context 是否填写)
59
+
60
+ ### Orchestrator STOP 后验证清单
61
+
62
+ Sub-agent STOP 返回后,Orchestrator 必须验证:
63
+
64
+ ```bash
65
+ # 检查 atom status 是否全部更新
66
+ cat docs/atom-plan.json | jq '[.atoms[] | select(.assignTo == "<agent>") | select(.status == "pending")] | length'
67
+ # 应该 = 0(所有该 agent 的 atom 都已 done / skipped)
68
+
69
+ # 检查 Context 是否填写
70
+ grep -c "Pending" docs/atom-plan.md
71
+ # 对应 agent 的 Context 区不应包含 "Pending"
72
+
73
+ # 检查 actualOutput 文件是否存在
74
+ cat docs/atom-plan.json | jq '.atoms[] | select(.assignTo == "<agent>" and .status == "done") | .actualOutput' | xargs -I {} test -f {}
75
+ ```
76
+
77
+ 如果验证失败 → 不转入下一阶段,而是要求该 agent 补全。
29
78
 
30
79
  ### Single-Agent Mode(降级模式,当 sub-agent 不可用时)
31
80
 
@@ -33,7 +82,7 @@ triggers: 构建游戏,开始开发,创建项目,选择组件,选择 skill,查
33
82
 
34
83
  - 每进入一个新阶段时,先完整读取对应 `.claude/agents/<role>.md` 的所有指令
35
84
  - 不可跳过任何阶段的必选产出(特别是 TA 的完整素材生产——UI 图、VFX、精灵图都必须生产)
36
- - 必须执行 Spec Quick-Check:TA 在 production Wave 2 启动后 30s 内;Developer 在 `integration` 启动后 30s 内
85
+ - 必须执行 Spec Quick-Check:TA 在 production Wave 2 启动后 30s 内;Developer 在 `ui_pass` 启动后 30s 内
37
86
  - PM 定稿后运行 `playcraft skills link --from-atom-plan`;Developer 优先读 `.claude/skills/<atomId>/SKILL.md`,仅断链时用 `playcraft skills read`
38
87
 
39
88
  ---
@@ -238,13 +287,47 @@ Skills 路径真源:`playcraft.config.json` → `agent.skillsDir`(**不要**
238
287
 
239
288
  ### 各 Agent 的读写职责
240
289
 
241
- | Agent | 读取 | 写入 |
242
- | -------------------- | ---------------------------------------- | ----------------------------------------------------- |
243
- | **PM** | design-brief, layout-spec | `atom-plan.json`(skillsMatch + atoms[]) |
244
- | **Designer** | `atoms[]` + design-brief | `atom-plan.md` § Asset Skill Context |
245
- | **Technical Artist** | `atoms[]` + Asset Context + designer-log | `atom-plan.md` § TA Skill Context;`atoms[].status` |
246
- | **Developer** | `atoms[]` + Context 区 + design-brief | `atom-plan.md` § Impl Skill Context;`atoms[].status` |
247
- | **Reviewer** | JSON + MD(只读) | 不写 |
290
+ | Agent | 读取 | 写入 |
291
+ | -------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------- |
292
+ | **PM** | design-brief, layout-spec | `atom-plan.json`(skillsMatch + atoms[]) |
293
+ | **Designer** | `atoms[]` + `mediaGroups` + design-brief | `atom-plan.md` § Asset Skill Context;`atoms[].status` + `atoms[].actualOutput` |
294
+ | **Technical Artist** | `atoms[]` + `mediaGroups` + Asset Context + designer-log | `atom-plan.md` § TA Skill Context;`atoms[].status` + `atoms[].actualOutput` |
295
+ | **Developer** | `atoms[]` + Context 区 + design-brief | `atom-plan.md` § Impl Skill Context;`atoms[].status` + `atoms[].actualOutput` |
296
+ | **Reviewer** | JSON + MD(只读) | 不写 |
297
+
298
+ ### ⚠️ Status Update 纪律(所有 Agent 必须遵守)
299
+
300
+ 每个 Agent 完成 atom 后 **立即** 更新 `atom-plan.json`:
301
+
302
+ ```json
303
+ {
304
+ "atomId": "<id>",
305
+ "status": "done",
306
+ "actualOutput": "<deliverable_path>"
307
+ }
308
+ ```
309
+
310
+ - **Designer**: `actualOutput` = 文件路径 或 `"ASR:<sheet>:<region>"` (when covered by ASR)
311
+ - **TA**: `actualOutput` = `"assets/images/<path>.webp"` (final WebP contract path)
312
+ - **Developer**: `actualOutput` = `"game/<path>.ts"` (implementation file)
313
+
314
+ **atom-plan 不是 PM 的一次性输出文档,而是贯穿全流程的活依赖追踪系统。**
315
+
316
+ ### mediaGroups 使用纪律(Designer + TA 必须遵守)
317
+
318
+ `skillsMatch.mediaGroups` 包含 PM 通过 `playcraft skills match` 找到的可复用预制资产。
319
+
320
+ **流程**:
321
+
322
+ ```
323
+ Designer/TA 读 mediaGroups
324
+ ├─ 匹配当前 atom?
325
+ │ ├─ 是 → `playcraft skills link --atom <atomId>` → 后处理 → status=done
326
+ │ └─ 否 / 质量不够 → 记录跳过原因到 dagRevisions → 正常生产流程
327
+ └─ mediaGroups 为空?→ 正常生产流程
328
+ ```
329
+
330
+ **禁止**:忽略 mediaGroups 中存在匹配的预制资产而从零生成(浪费 token + 引入不一致风险)。
248
331
 
249
332
  ### 为什么这样设计能避免冲突
250
333
 
@@ -297,22 +380,28 @@ Reviewer:
297
380
 
298
381
  `aiimage` / `aiaudio` Skill 没有 `ref/` 代码文件,只有 `manifest.json` 中的 `generation` 字段(prompt、aspectRatio、duration 等)。Designer 和 TA 读取这些参数作为生成基准,通过 `playcraft image *`、`playcraft tools generate-image` 等 CLI 命令执行,不复制任何文件到项目。
299
382
 
300
- ### Production 串行编排(production-serial-v1
383
+ **Reviewer(convergence-v1)**
384
+
385
+ - **`design_check`**:Gate #1 / #2b 前 — 文档完整性 checklist(无需浏览器)
386
+ - **`ui_diff`**:读取 **`playwright-cli`** skill — 截图 vs MC 各面板
387
+ - **`load_check`**:读取 **`playwright-cli`** skill — 页面加载 + console 无 Error
388
+
389
+ ### Production 串行编排(convergence-v1)
301
390
 
302
391
  Gate #2b 通过后 **严格串行**(见 `workflow-changelog.md`):
303
392
 
304
393
  ```
305
- Wave 1 Designer Ph.2 → Wave 2 TA → integration Developer
394
+ Wave 1 Designer Ph.2 → Wave 2 TA → ui_pass Developer → ui_review (Reviewer ui_diff) → gameplay_pass Developer → load_check → Gate #3
306
395
  ```
307
396
 
308
- Developer 仅在 `integration` 写入 `game/**`,此时 TA 已交付合同路径上的真实资产。
397
+ Developer **`ui_pass`** 写入 UI shell(无核心玩法);**`gameplay_pass`** 叠加玩法逻辑。TA 已交付合同路径上的真实资产。
309
398
 
310
399
  ### 避免重复 Scaffold 的规则
311
400
 
312
401
  同一个 Skill 不应被多次 Scaffold 到同一目录:
313
402
 
314
403
  - PM 在 `atom-plan.json` → `atoms[]` 标注 `skillRef`(若有)+ 调度元信息(assignTo/dependsOn/priority/parallelGroup/referenceSource)
315
- - Developer 在 `integration` 开始时,按 `atoms[]` 中 `assignTo: Developer` 批量 scaffold 一次
404
+ - Developer 在 **`ui_pass`** 开始时,按 `atoms[]` 中 `assignTo: Developer` 批量 scaffold 一次
316
405
  - **不要在实现单个 Atom 时反复 scaffold** — 先统一 scaffold 所有依赖,再逐一实现
317
406
 
318
407
  ---
@@ -0,0 +1,390 @@
1
+ ---
2
+ name: playwright-cli
3
+ description: Automate browser interactions, test web pages and work with Playwright tests.
4
+ allowed-tools: Bash(playwright-cli:*) Bash(npx:*) Bash(npm:*)
5
+ ---
6
+
7
+ # Browser Automation with playwright-cli
8
+
9
+ ## Quick start
10
+
11
+ ```bash
12
+ # open new browser
13
+ playwright-cli open
14
+ # navigate to a page
15
+ playwright-cli goto https://playwright.dev
16
+ # interact with the page using refs from the snapshot
17
+ playwright-cli click e15
18
+ playwright-cli type "page.click"
19
+ playwright-cli press Enter
20
+ # take a screenshot (rarely used, as snapshot is more common)
21
+ playwright-cli screenshot
22
+ # close the browser
23
+ playwright-cli close
24
+ ```
25
+
26
+ ## Commands
27
+
28
+ ### Core
29
+
30
+ ```bash
31
+ playwright-cli open
32
+ # open and navigate right away
33
+ playwright-cli open https://example.com/
34
+ playwright-cli goto https://playwright.dev
35
+ playwright-cli type "search query"
36
+ playwright-cli click e3
37
+ playwright-cli dblclick e7
38
+ # --submit presses Enter after filling the element
39
+ playwright-cli fill e5 "user@example.com" --submit
40
+ playwright-cli drag e2 e8
41
+ # drop files or data onto an element (from outside the page)
42
+ playwright-cli drop e4 --path=./image.png
43
+ playwright-cli drop e4 --data="text/plain=hello world"
44
+ playwright-cli hover e4
45
+ playwright-cli select e9 "option-value"
46
+ playwright-cli upload ./document.pdf
47
+ playwright-cli check e12
48
+ playwright-cli uncheck e12
49
+ playwright-cli snapshot
50
+ playwright-cli eval "document.title"
51
+ playwright-cli eval "el => el.textContent" e5
52
+ # get element id, class, or any attribute not visible in the snapshot
53
+ playwright-cli eval "el => el.id" e5
54
+ playwright-cli eval "el => el.getAttribute('data-testid')" e5
55
+ playwright-cli dialog-accept
56
+ playwright-cli dialog-accept "confirmation text"
57
+ playwright-cli dialog-dismiss
58
+ playwright-cli resize 1920 1080
59
+ playwright-cli close
60
+ ```
61
+
62
+ ### Navigation
63
+
64
+ ```bash
65
+ playwright-cli go-back
66
+ playwright-cli go-forward
67
+ playwright-cli reload
68
+ ```
69
+
70
+ ### Keyboard
71
+
72
+ ```bash
73
+ playwright-cli press Enter
74
+ playwright-cli press ArrowDown
75
+ playwright-cli keydown Shift
76
+ playwright-cli keyup Shift
77
+ ```
78
+
79
+ ### Mouse
80
+
81
+ ```bash
82
+ playwright-cli mousemove 150 300
83
+ playwright-cli mousedown
84
+ playwright-cli mousedown right
85
+ playwright-cli mouseup
86
+ playwright-cli mouseup right
87
+ playwright-cli mousewheel 0 100
88
+ ```
89
+
90
+ ### Save as
91
+
92
+ ```bash
93
+ playwright-cli screenshot
94
+ playwright-cli screenshot e5
95
+ playwright-cli screenshot --filename=page.png
96
+ playwright-cli pdf --filename=page.pdf
97
+ ```
98
+
99
+ ### Tabs
100
+
101
+ ```bash
102
+ playwright-cli tab-list
103
+ playwright-cli tab-new
104
+ playwright-cli tab-new https://example.com/page
105
+ playwright-cli tab-close
106
+ playwright-cli tab-close 2
107
+ playwright-cli tab-select 0
108
+ ```
109
+
110
+ ### Storage
111
+
112
+ ```bash
113
+ playwright-cli state-save
114
+ playwright-cli state-save auth.json
115
+ playwright-cli state-load auth.json
116
+
117
+ # Cookies
118
+ playwright-cli cookie-list
119
+ playwright-cli cookie-list --domain=example.com
120
+ playwright-cli cookie-get session_id
121
+ playwright-cli cookie-set session_id abc123
122
+ playwright-cli cookie-set session_id abc123 --domain=example.com --httpOnly --secure
123
+ playwright-cli cookie-delete session_id
124
+ playwright-cli cookie-clear
125
+
126
+ # LocalStorage
127
+ playwright-cli localstorage-list
128
+ playwright-cli localstorage-get theme
129
+ playwright-cli localstorage-set theme dark
130
+ playwright-cli localstorage-delete theme
131
+ playwright-cli localstorage-clear
132
+
133
+ # SessionStorage
134
+ playwright-cli sessionstorage-list
135
+ playwright-cli sessionstorage-get step
136
+ playwright-cli sessionstorage-set step 3
137
+ playwright-cli sessionstorage-delete step
138
+ playwright-cli sessionstorage-clear
139
+ ```
140
+
141
+ ### Network
142
+
143
+ ```bash
144
+ playwright-cli route "**/*.jpg" --status=404
145
+ playwright-cli route "https://api.example.com/**" --body='{"mock": true}'
146
+ playwright-cli route-list
147
+ playwright-cli unroute "**/*.jpg"
148
+ playwright-cli unroute
149
+ ```
150
+
151
+ ### DevTools
152
+
153
+ ```bash
154
+ playwright-cli console
155
+ playwright-cli console warning
156
+ playwright-cli requests
157
+ playwright-cli request 5
158
+ playwright-cli run-code "async page => await page.context().grantPermissions(['geolocation'])"
159
+ playwright-cli run-code --filename=script.js
160
+ playwright-cli tracing-start
161
+ playwright-cli tracing-stop
162
+ playwright-cli video-start video.webm
163
+ playwright-cli video-chapter "Chapter Title" --description="Details" --duration=2000
164
+ playwright-cli video-stop
165
+
166
+ # launch the dashboard for UI review / design feedback — user annotates the page, you receive the annotated screenshot, snapshot, and notes
167
+ playwright-cli show --annotate
168
+
169
+ # generate a Playwright locator for an element from its ref or selector
170
+ playwright-cli generate-locator e5 --raw
171
+
172
+ # show a persistent highlight overlay for an element, optionally with a custom style
173
+ playwright-cli highlight e5
174
+ playwright-cli highlight e5 --style="outline: 3px dashed red"
175
+ # hide a single element highlight, or all page highlights when no target is given
176
+ playwright-cli highlight e5 --hide
177
+ playwright-cli highlight --hide
178
+ ```
179
+
180
+ ## Raw output
181
+
182
+ The global `--raw` option strips page status, generated code, and snapshot sections from the output, returning only the result value. Use it to pipe command output into other tools. Commands that don't produce output return nothing.
183
+
184
+ ```bash
185
+ playwright-cli --raw eval "JSON.stringify(performance.timing)" | jq '.loadEventEnd - .navigationStart'
186
+ playwright-cli --raw eval "JSON.stringify([...document.querySelectorAll('a')].map(a => a.href))" > links.json
187
+ playwright-cli --raw snapshot > before.yml
188
+ playwright-cli click e5
189
+ playwright-cli --raw snapshot > after.yml
190
+ diff before.yml after.yml
191
+ TOKEN=$(playwright-cli --raw cookie-get session_id)
192
+ playwright-cli --raw localstorage-get theme
193
+ ```
194
+
195
+ For structured output wrapping every reply as JSON, pass --json
196
+
197
+ ```bash
198
+ playwright-cli list --json
199
+ ```
200
+
201
+ ## Open parameters
202
+
203
+ ```bash
204
+ # Use specific browser when creating session
205
+ playwright-cli open --browser=chrome
206
+ playwright-cli open --browser=firefox
207
+ playwright-cli open --browser=webkit
208
+ playwright-cli open --browser=msedge
209
+
210
+ # Use persistent profile (by default profile is in-memory)
211
+ playwright-cli open --persistent
212
+ # Use persistent profile with custom directory
213
+ playwright-cli open --profile=/path/to/profile
214
+
215
+ # Connect to browser via Playwright Extension
216
+ playwright-cli attach --extension=chrome
217
+
218
+ # Connect to a running Chrome or Edge by channel name
219
+ playwright-cli attach --cdp=chrome
220
+ playwright-cli attach --cdp=msedge
221
+
222
+ # Connect to a running browser via CDP endpoint
223
+ playwright-cli attach --cdp=http://localhost:9222
224
+
225
+ # Start with config file
226
+ playwright-cli open --config=my-config.json
227
+
228
+ # Close the browser
229
+ playwright-cli close
230
+ # Detach from an attached browser (leaves the external browser running)
231
+ playwright-cli -s=msedge detach
232
+ # Delete user data for the default session
233
+ playwright-cli delete-data
234
+ ```
235
+
236
+ ## Snapshots
237
+
238
+ After each command, playwright-cli provides a snapshot of the current browser state.
239
+
240
+ ```bash
241
+ > playwright-cli goto https://example.com
242
+ ### Page
243
+ - Page URL: https://example.com/
244
+ - Page Title: Example Domain
245
+ ### Snapshot
246
+ [Snapshot](.playwright-cli/page-2026-02-14T19-22-42-679Z.yml)
247
+ ```
248
+
249
+ You can also take a snapshot on demand using `playwright-cli snapshot` command. All the options below can be combined as needed.
250
+
251
+ ```bash
252
+ # default - save to a file with timestamp-based name
253
+ playwright-cli snapshot
254
+
255
+ # save to file, use when snapshot is a part of the workflow result
256
+ playwright-cli snapshot --filename=after-click.yaml
257
+
258
+ # snapshot an element instead of the whole page
259
+ playwright-cli snapshot "#main"
260
+
261
+ # limit snapshot depth for efficiency, take a partial snapshot afterwards
262
+ playwright-cli snapshot --depth=4
263
+ playwright-cli snapshot e34
264
+
265
+ # include each element's bounding box as [box=x,y,width,height]
266
+ playwright-cli snapshot --boxes
267
+ ```
268
+
269
+ ## Targeting elements
270
+
271
+ By default, use refs from the snapshot to interact with page elements.
272
+
273
+ ```bash
274
+ # get snapshot with refs
275
+ playwright-cli snapshot
276
+
277
+ # interact using a ref
278
+ playwright-cli click e15
279
+ ```
280
+
281
+ You can also use css selectors or Playwright locators.
282
+
283
+ ```bash
284
+ # css selector
285
+ playwright-cli click "#main > button.submit"
286
+
287
+ # role locator
288
+ playwright-cli click "getByRole('button', { name: 'Submit' })"
289
+
290
+ # test id
291
+ playwright-cli click "getByTestId('submit-button')"
292
+ ```
293
+
294
+ ## Browser Sessions
295
+
296
+ ```bash
297
+ # create new browser session named "mysession" with persistent profile
298
+ playwright-cli -s=mysession open example.com --persistent
299
+ # same with manually specified profile directory (use when requested explicitly)
300
+ playwright-cli -s=mysession open example.com --profile=/path/to/profile
301
+ playwright-cli -s=mysession click e6
302
+ playwright-cli -s=mysession close # stop a named browser
303
+ playwright-cli -s=mysession delete-data # delete user data for persistent session
304
+
305
+ playwright-cli list
306
+ # Close all browsers
307
+ playwright-cli close-all
308
+ # Forcefully kill all browser processes
309
+ playwright-cli kill-all
310
+ ```
311
+
312
+ ## Installation
313
+
314
+ If global `playwright-cli` command is not available, try a local version via `npx playwright-cli`:
315
+
316
+ ```bash
317
+ npx --no-install playwright-cli --version
318
+ ```
319
+
320
+ When local version is available, use `npx playwright-cli` in all commands. Otherwise, install `playwright-cli` as a global command:
321
+
322
+ ```bash
323
+ npm install -g @playwright/cli@latest
324
+ ```
325
+
326
+ ## Example: Form submission
327
+
328
+ ```bash
329
+ playwright-cli open https://example.com/form
330
+ playwright-cli snapshot
331
+
332
+ playwright-cli fill e1 "user@example.com"
333
+ playwright-cli fill e2 "password123"
334
+ playwright-cli click e3
335
+ playwright-cli snapshot
336
+ playwright-cli close
337
+ ```
338
+
339
+ ## Example: Multi-tab workflow
340
+
341
+ ```bash
342
+ playwright-cli open https://example.com
343
+ playwright-cli tab-new https://example.com/other
344
+ playwright-cli tab-list
345
+ playwright-cli tab-select 0
346
+ playwright-cli snapshot
347
+ playwright-cli close
348
+ ```
349
+
350
+ ## Example: Debugging with DevTools
351
+
352
+ ```bash
353
+ playwright-cli open https://example.com
354
+ playwright-cli click e4
355
+ playwright-cli fill e7 "test"
356
+ playwright-cli console
357
+ playwright-cli requests
358
+ playwright-cli close
359
+ ```
360
+
361
+ ```bash
362
+ playwright-cli open https://example.com
363
+ playwright-cli tracing-start
364
+ playwright-cli click e4
365
+ playwright-cli fill e7 "test"
366
+ playwright-cli tracing-stop
367
+ playwright-cli close
368
+ ```
369
+
370
+ ## Example: Interactive session
371
+
372
+ Ask the user for UI review or design feedback. The user draws boxes on the live page and types comments; you receive the annotated screenshot, the snapshot of the marked region, and the user's notes. Use this whenever the user asks for "UI review", "design feedback", or to "ask the user what they think / want / mean":
373
+
374
+ ```bash
375
+ playwright-cli open https://example.com
376
+ playwright-cli show --annotate
377
+ ```
378
+
379
+ ## Specific tasks
380
+
381
+ - **Running and Debugging Playwright tests** [references/playwright-tests.md](references/playwright-tests.md)
382
+ - **Request mocking** [references/request-mocking.md](references/request-mocking.md)
383
+ - **Running Playwright code** [references/running-code.md](references/running-code.md)
384
+ - **Browser session management** [references/session-management.md](references/session-management.md)
385
+ - **Spec-driven testing (plan / generate / heal)** [references/spec-driven-testing.md](references/spec-driven-testing.md)
386
+ - **Storage state (cookies, localStorage)** [references/storage-state.md](references/storage-state.md)
387
+ - **Test generation** [references/test-generation.md](references/test-generation.md)
388
+ - **Tracing** [references/tracing.md](references/tracing.md)
389
+ - **Video recording** [references/video-recording.md](references/video-recording.md)
390
+ - **Inspecting element attributes** [references/element-attributes.md](references/element-attributes.md)
@@ -0,0 +1,23 @@
1
+ # Inspecting Element Attributes
2
+
3
+ When the snapshot doesn't show an element's `id`, `class`, `data-*` attributes, or other DOM properties, use `eval` to inspect them.
4
+
5
+ ## Examples
6
+
7
+ ```bash
8
+ playwright-cli snapshot
9
+ # snapshot shows a button as e7 but doesn't reveal its id or data attributes
10
+
11
+ # get the element's id
12
+ playwright-cli eval "el => el.id" e7
13
+
14
+ # get all CSS classes
15
+ playwright-cli eval "el => el.className" e7
16
+
17
+ # get a specific attribute
18
+ playwright-cli eval "el => el.getAttribute('data-testid')" e7
19
+ playwright-cli eval "el => el.getAttribute('aria-label')" e7
20
+
21
+ # get a computed style property
22
+ playwright-cli eval "el => getComputedStyle(el).display" e7
23
+ ```
@@ -0,0 +1,39 @@
1
+ # Running Playwright Tests
2
+
3
+ To run Playwright tests, use the `npx playwright test` command, or a package manager script. To avoid opening the interactive html report, use `PLAYWRIGHT_HTML_OPEN=never` environment variable.
4
+
5
+ ```bash
6
+ # Run all tests
7
+ PLAYWRIGHT_HTML_OPEN=never npx playwright test
8
+
9
+ # Run all tests through a custom npm script
10
+ PLAYWRIGHT_HTML_OPEN=never npm run special-test-command
11
+ ```
12
+
13
+ # Debugging Playwright Tests
14
+
15
+ To debug a failing Playwright test, run it with `--debug=cli` option. This command will pause the test at the start and print the debugging instructions.
16
+
17
+ **IMPORTANT**: run the command in the background and check the output until "Debugging Instructions" is printed. Make sure to stop the command after you have finished.
18
+
19
+ Once instructions containing a session name are printed, use `playwright-cli` to attach the session and explore the page.
20
+
21
+ ```bash
22
+ # Run the test
23
+ PLAYWRIGHT_HTML_OPEN=never npx playwright test --debug=cli
24
+ # ...
25
+ # ... debugging instructions for "tw-abcdef" session ...
26
+ # ...
27
+
28
+ # Attach to the test
29
+ playwright-cli attach tw-abcdef
30
+ ```
31
+
32
+ Keep the test running in the background while you explore and look for a fix.
33
+ The test is paused at the start, so you should step over or pause at a particular location
34
+ where the problem is most likely to be.
35
+
36
+ Every action you perform with `playwright-cli` generates corresponding Playwright TypeScript code.
37
+ This code appears in the output and can be copied directly into the test. Most of the time, a specific locator or an expectation should be updated, but it could also be a bug in the app. Use your judgement.
38
+
39
+ After fixing the test, stop the background test run. Rerun to check that test passes.