@playcraft/cli 0.0.40 → 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 (130) hide show
  1. package/README.md +66 -3
  2. package/dist/atom-plan/validate-atom-plan.js +298 -0
  3. package/dist/cli-root-help.js +1 -1
  4. package/dist/commands/3d.js +363 -0
  5. package/dist/commands/create.js +337 -0
  6. package/dist/commands/image.js +1337 -43
  7. package/dist/commands/recommend.js +1 -1
  8. package/dist/commands/remix.js +213 -0
  9. package/dist/commands/skills.js +1379 -0
  10. package/dist/commands/tools-3d.js +473 -0
  11. package/dist/commands/tools-generation.js +452 -0
  12. package/dist/commands/tools-project.js +400 -0
  13. package/dist/commands/tools-research.js +37 -0
  14. package/dist/commands/tools-research.test.js +216 -0
  15. package/dist/commands/tools-utils.js +183 -0
  16. package/dist/commands/tools.js +7 -616
  17. package/dist/config.js +2 -0
  18. package/dist/index.js +19 -1
  19. package/dist/utils/version-checker.js +8 -11
  20. package/package.json +9 -3
  21. package/project-template/.claude/agents/designer.md +120 -0
  22. package/project-template/.claude/agents/developer.md +124 -0
  23. package/project-template/.claude/agents/pm.md +164 -0
  24. package/project-template/.claude/agents/refs/README.md +73 -0
  25. package/project-template/.claude/agents/refs/designer-art-style-catalog.md +533 -0
  26. package/project-template/.claude/agents/refs/designer-color-audio-recipes.md +153 -0
  27. package/project-template/.claude/agents/refs/designer-deliverable-spec.md +191 -0
  28. package/project-template/.claude/agents/refs/designer-dimension-axis.md +27 -0
  29. package/project-template/.claude/agents/refs/designer-handoff-v2-checklist.md +68 -0
  30. package/project-template/.claude/agents/refs/designer-master-composite-recipes.md +208 -0
  31. package/project-template/.claude/agents/refs/designer-style-exploration-flow.md +37 -0
  32. package/project-template/.claude/agents/refs/developer-dev-handoff.md +109 -0
  33. package/project-template/.claude/agents/refs/developer-impl-cookbook.md +134 -0
  34. package/project-template/.claude/agents/refs/developer-phase1-flow.md +136 -0
  35. package/project-template/.claude/agents/refs/pm-workflow-detail.md +551 -0
  36. package/project-template/.claude/agents/refs/reviewer-convergence-eval.md +130 -0
  37. package/project-template/.claude/agents/refs/reviewer-six-dimension-eval.md +6 -0
  38. package/project-template/.claude/agents/refs/ta-3d-flip-recipe.md +85 -0
  39. package/project-template/.claude/agents/refs/ta-atlas-deliverable-standard.md +67 -0
  40. package/project-template/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
  41. package/project-template/.claude/agents/refs/ta-image-generation-detail.md +356 -0
  42. package/project-template/.claude/agents/refs/ta-image-ops-reference.md +495 -0
  43. package/project-template/.claude/agents/refs/ta-pipeline-cookbook.md +1108 -0
  44. package/project-template/.claude/agents/refs/ta-tools-reference.md +111 -0
  45. package/project-template/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
  46. package/project-template/.claude/agents/reviewer.md +127 -0
  47. package/project-template/.claude/agents/technical-artist.md +122 -0
  48. package/project-template/.claude/hooks/README.md +44 -0
  49. package/project-template/.claude/hooks/validate-atom-plan.mjs +224 -0
  50. package/project-template/.claude/hooks/validate-workflow-stop.mjs +343 -0
  51. package/project-template/.claude/settings.json +36 -0
  52. package/project-template/.claude/settings.local.json +4 -0
  53. package/project-template/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
  54. package/project-template/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
  55. package/project-template/.claude/skills/playcraft-asset-state-sheet/SKILL.md +141 -0
  56. package/project-template/.claude/skills/playcraft-audio-generation/SKILL.md +280 -0
  57. package/project-template/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
  58. package/project-template/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
  59. package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +279 -0
  60. package/project-template/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
  61. package/project-template/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
  62. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +235 -0
  63. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +97 -0
  64. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
  65. package/project-template/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +137 -0
  66. package/project-template/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
  67. package/project-template/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
  68. package/project-template/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
  69. package/project-template/.claude/skills/playcraft-masking/SKILL.md +373 -0
  70. package/project-template/.claude/skills/playcraft-research/SKILL.md +212 -0
  71. package/project-template/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
  72. package/project-template/.claude/skills/playcraft-storyboard/SKILL.md +167 -0
  73. package/project-template/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
  74. package/project-template/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
  75. package/project-template/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
  76. package/project-template/.claude/skills/playcraft-workflow/SKILL.md +485 -0
  77. package/project-template/.claude/skills/playwright-cli/SKILL.md +390 -0
  78. package/project-template/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
  79. package/project-template/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
  80. package/project-template/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
  81. package/project-template/.claude/skills/playwright-cli/references/running-code.md +240 -0
  82. package/project-template/.claude/skills/playwright-cli/references/session-management.md +226 -0
  83. package/project-template/.claude/skills/playwright-cli/references/spec-driven-testing.md +312 -0
  84. package/project-template/.claude/skills/playwright-cli/references/storage-state.md +275 -0
  85. package/project-template/.claude/skills/playwright-cli/references/test-generation.md +138 -0
  86. package/project-template/.claude/skills/playwright-cli/references/tracing.md +142 -0
  87. package/project-template/.claude/skills/playwright-cli/references/video-recording.md +157 -0
  88. package/project-template/.cursor/hooks.json +17 -0
  89. package/project-template/.cursor/rules/playcraft-orchestrator.mdc +137 -0
  90. package/project-template/.cursor/rules/playcraft-subagent-boundary.mdc +18 -0
  91. package/project-template/CLAUDE.md +280 -0
  92. package/project-template/assets/audio/bgm/.gitkeep +0 -0
  93. package/project-template/assets/audio/sfx/.gitkeep +0 -0
  94. package/project-template/assets/bundles/.gitkeep +0 -0
  95. package/project-template/assets/images/bg/.gitkeep +0 -0
  96. package/project-template/assets/images/reference/.gitkeep +0 -0
  97. package/project-template/assets/images/storyboard/.gitkeep +0 -0
  98. package/project-template/assets/images/tiles/.gitkeep +0 -0
  99. package/project-template/assets/images/ui/.gitkeep +0 -0
  100. package/project-template/assets/images/vfx/.gitkeep +0 -0
  101. package/project-template/assets/models/.gitkeep +0 -0
  102. package/project-template/docs/team/agent-conduct.md +121 -0
  103. package/project-template/docs/team/agent-runtime-matrix.md +62 -0
  104. package/project-template/docs/team/atom-plan-format.md +105 -0
  105. package/project-template/docs/team/collaboration.md +297 -0
  106. package/project-template/docs/team/core-model.md +50 -0
  107. package/project-template/docs/team/platform-capabilities.md +15 -0
  108. package/project-template/docs/team/workflow-changelog.md +65 -0
  109. package/project-template/docs/team/workflow-consistency-checklist.md +140 -0
  110. package/project-template/game/config/.gitkeep +0 -0
  111. package/project-template/game/gameplay/.gitkeep +0 -0
  112. package/project-template/game/scenes/.gitkeep +0 -0
  113. package/project-template/logs/.gitkeep +0 -0
  114. package/project-template/ta-workspace/logs/.gitkeep +0 -0
  115. package/project-template/ta-workspace/scripts/.gitkeep +0 -0
  116. package/project-template/ta-workspace/tmp/.gitkeep +0 -0
  117. package/project-template/templates/atom-plan.template.json +26 -0
  118. package/project-template/templates/atom-plan.template.md +108 -0
  119. package/project-template/templates/design-brief.template.md +195 -0
  120. package/project-template/templates/design-lens-checklist.reference.md +117 -0
  121. package/project-template/templates/design-methodology.md +99 -0
  122. package/project-template/templates/designer-log.template.md +114 -0
  123. package/project-template/templates/developer-log.template.md +134 -0
  124. package/project-template/templates/five-axis-framework.md +186 -0
  125. package/project-template/templates/intent-clarifications.template.md +58 -0
  126. package/project-template/templates/layout-spec.template.md +146 -0
  127. package/project-template/templates/project-state.template.md +237 -0
  128. package/project-template/templates/review-report.template.md +91 -0
  129. package/project-template/templates/style-exploration.template.md +93 -0
  130. package/project-template/templates/ta-log.template.md +343 -0
@@ -0,0 +1,312 @@
1
+ # Spec-driven testing (plan → generate → heal)
2
+
3
+ End-to-end workflow for authoring and maintaining Playwright tests using `playwright-cli`. The three sections below can be used independently:
4
+
5
+ - **Planning** — explore the app, produce a spec file describing what to test.
6
+ - **Generate** — turn a spec into Playwright test files. Update the spec if it's vague or stale.
7
+ - **Heal** — diagnose failing tests, fix the code, reconcile the spec with reality.
8
+
9
+ All three lean on the same mechanic: run `npx playwright test --debug=cli` in the background, then `playwright-cli attach tw-XXXX` to drive the paused page interactively. See [playwright-tests.md](playwright-tests.md) for the debug/attach mechanics and [test-generation.md](test-generation.md) for how every `playwright-cli` action emits Playwright TypeScript.
10
+
11
+ ---
12
+
13
+ ## 1. Planning
14
+
15
+ Goal: produce a spec file (e.g. `specs/<feature>.plan.md`) that enumerates the scenarios to test. **Always** write the spec to a file.
16
+
17
+ ### 1.1 Prerequisite: workspace
18
+
19
+ Check the workspace has Playwright installed before anything else:
20
+
21
+ ```bash
22
+ # Either of these confirms a workspace:
23
+ test -f playwright.config.ts || test -f playwright.config.js
24
+ npx --no-install playwright --version
25
+ ```
26
+
27
+ If there is no Playwright install, bootstrap one and let the user pick the defaults:
28
+
29
+ ```bash
30
+ npm init playwright@latest
31
+ ```
32
+
33
+ ### 1.2 Prerequisite: seed test
34
+
35
+ A **seed test** is a minimal test that lands the page in the state every scenario starts from: navigation to the app, any required login, feature flags, etc. Scenarios assume a fresh start _after_ the seed. `--debug=cli` pauses _inside_ this test, so the seed is where every planning and generation session begins.
36
+
37
+ Minimum viable seed:
38
+
39
+ ```ts
40
+ // tests/seed.spec.ts
41
+ import { test } from "@playwright/test";
42
+
43
+ test("seed", async ({ page }) => {
44
+ await page.goto("https://example.com/");
45
+ });
46
+ ```
47
+
48
+ Preferred — push navigation into a fixture so scenario tests reuse it:
49
+
50
+ ```ts
51
+ // tests/fixtures.ts
52
+ import { test as baseTest } from "@playwright/test";
53
+ export { expect } from "@playwright/test";
54
+
55
+ export const test = baseTest.extend({
56
+ page: async ({ page }, use) => {
57
+ await page.goto("https://example.com/");
58
+ await use(page);
59
+ },
60
+ });
61
+ ```
62
+
63
+ ```ts
64
+ // tests/seed.spec.ts
65
+ import { test } from "./fixtures";
66
+
67
+ test("seed", async ({ page }) => {
68
+ // Fixture already navigates. This empty body tells agents where to start.
69
+ });
70
+ ```
71
+
72
+ If no seed exists, create one that at least navigates to the app.
73
+
74
+ ### 1.3 Explore the app
75
+
76
+ Launch the app via the seed in the background and attach:
77
+
78
+ ```bash
79
+ PLAYWRIGHT_HTML_OPEN=never npx playwright test tests/seed.spec.ts --debug=cli
80
+ # wait for "Debugging Instructions" and the session name tw-XXXX
81
+ playwright-cli attach tw-XXXX
82
+ ```
83
+
84
+ Resume so the seed runs, then probe the app:
85
+
86
+ ```bash
87
+ playwright-cli resume # resume so that seed test runs fully
88
+ playwright-cli snapshot # inventory of interactive elements
89
+ playwright-cli click e5 # follow a flow
90
+ playwright-cli eval "location.href" # read URL / state
91
+ playwright-cli show --annotate # ask the user to point at something
92
+ ```
93
+
94
+ Map out:
95
+
96
+ - Interactive surfaces (forms, buttons, lists, filters, modals).
97
+ - Primary user journeys end-to-end.
98
+ - Edge cases: empty states, validation errors, very long input, boundary values.
99
+ - Persistence: reload, local/session storage, URL fragments.
100
+ - Navigation: which controls change the URL, back/forward behaviour.
101
+
102
+ **Important**: Do not just open the app url with playwright-cli, always go through the test to capture any custom setup done there.
103
+ **Important**: Stop the background test when done exploring.
104
+
105
+ ### 1.4 Write the spec file
106
+
107
+ Save under `specs/<feature>.plan.md`. Use this structure:
108
+
109
+ ```markdown
110
+ # <Feature> Test Plan
111
+
112
+ ## Application Overview
113
+
114
+ <One paragraph describing what the feature does and why it matters.>
115
+
116
+ ## Test Scenarios
117
+
118
+ ### 1. <Group Name>
119
+
120
+ **Seed:** `tests/seed.spec.ts`
121
+
122
+ #### 1.1. <kebab-case-scenario-name>
123
+
124
+ **File:** `tests/<group>/<kebab-case-scenario-name>.spec.ts`
125
+
126
+ **Steps:**
127
+
128
+ 1. <Concrete user step>
129
+
130
+
131
+ - expect: <observable outcome>
132
+ - expect: <another observable outcome>
133
+
134
+ 2. <Next step>
135
+
136
+
137
+ - expect: <outcome>
138
+
139
+ #### 1.2. <next-scenario>
140
+
141
+ ...
142
+
143
+ ### 2. <Next Group>
144
+
145
+ **Seed:** `tests/seed.spec.ts`
146
+ ...
147
+ ```
148
+
149
+ Guidelines:
150
+
151
+ - Each scenario is independent and starts from the seed's fresh state — never chain scenarios.
152
+ - Scenario names are kebab-case and match the test file name (`should-add-single-todo` → `should-add-single-todo.spec.ts`).
153
+ - Cover happy path, edge cases, validation, negative flows, persistence.
154
+ - Write steps at the user level ("Type 'Buy milk' into the input"), not the API level ("call `fill`").
155
+ - Put observable outcomes in `- expect:` bullets; each becomes an assertion during generation.
156
+
157
+ ---
158
+
159
+ ## 2. Generate
160
+
161
+ Goal: take a spec file and produce Playwright test files. Optionally update the spec if it has drifted.
162
+
163
+ ### 2.1 Inputs
164
+
165
+ - **Spec file**, e.g. `specs/basic-operations.plan.md`.
166
+ - **Target**: either a single scenario (e.g. `1.2`), a whole group (`1`), or all.
167
+ - **Seed file**, read from the `**Seed:**` line of the scenario's group.
168
+
169
+ ### 2.2 Generate one scenario
170
+
171
+ For each target scenario, in sequence (never in parallel — scenarios share the seed session):
172
+
173
+ ```bash
174
+ PLAYWRIGHT_HTML_OPEN=never npx playwright test <seed-file> --debug=cli # background
175
+ playwright-cli attach tw-XXXX
176
+ # resume
177
+ ```
178
+
179
+ **Do not** just open the app url with playwright-cli, always go through the test to capture any custom setup done there.
180
+
181
+ Walk the scenario's `Steps:` one by one with `playwright-cli`, treating the spec as the plan and the live app as the source of truth. If a step is vague ("click the button" — which button?), references an element that no longer exists, or contradicts the app's actual behaviour, use your judgement: update the spec to match what the app really does, then keep going. Editing the spec mid-generation is expected.
182
+
183
+ Every action prints the equivalent Playwright TypeScript (see [test-generation.md](test-generation.md)):
184
+
185
+ ```bash
186
+ playwright-cli snapshot # find refs
187
+ playwright-cli fill e3 "John Doe" # -> page.getByRole('textbox', {...}).fill(...)
188
+ playwright-cli press Enter
189
+ playwright-cli click e7
190
+ ```
191
+
192
+ For each `- expect:` bullet, add an explicit assertion. See [test-generation.md](test-generation.md) for details.
193
+
194
+ Collect the generated code and write the test file at the path given in the spec:
195
+
196
+ ```ts
197
+ // spec: specs/basic-operations.plan.md
198
+ // seed: tests/seed.spec.ts
199
+ import { test, expect } from "./fixtures"; // or '@playwright/test' if no fixtures file
200
+
201
+ test.describe("Singing in and out", () => {
202
+ test("should sign in", async ({ page }) => {
203
+ // 1. Navigate to the application
204
+ // (handled by the seed fixture)
205
+
206
+ // 2. Type 'John Doe' into the username field
207
+ await page.getByRole("textbox", { name: "username" }).fill("John Doe");
208
+
209
+ // 3. Type password
210
+ await page.getByRole("textbox", { name: "password" }).fill("TestPassword");
211
+
212
+ // 4. Press Enter to submit
213
+ await page.getByRole("textbox", { name: "password" }).press("Enter");
214
+
215
+ await expect(page.getByRole("heading")).toContainText("Welcome, John Doe!");
216
+ });
217
+ });
218
+ ```
219
+
220
+ Rules:
221
+
222
+ - **One test per file.** File path, describe name, and test name come verbatim from the spec (minus the ordinal).
223
+ - Prefix each numbered step with a `// N. <step text>` comment before its actions.
224
+ - Use the describe group name verbatim from the spec (no `1.` ordinal).
225
+ - Import from `./fixtures` if the project has one; otherwise `@playwright/test`.
226
+ - **Important**: close the CLI session and stop the background test before moving to the next scenario.
227
+
228
+ ### 2.3 Generate multiple scenarios
229
+
230
+ Loop 2.2 over the targeted scenarios one at a time, restarting the seed between each so every test starts from a clean page. This is safe to parallelise due to unique generated session names - just make sure each test run is stopped.
231
+
232
+ ### 2.4 Run generated tests
233
+
234
+ After generation, run the new tests once:
235
+
236
+ ```bash
237
+ PLAYWRIGHT_HTML_OPEN=never npx playwright test tests/<group>/<scenario>.spec.ts
238
+ ```
239
+
240
+ Any failure goes to Section 3.
241
+
242
+ ---
243
+
244
+ ## 3. Heal
245
+
246
+ Goal: fix failing tests, and update the spec if the app's intended behaviour changed.
247
+
248
+ ### 3.1 Find failing tests
249
+
250
+ ```bash
251
+ PLAYWRIGHT_HTML_OPEN=never npx playwright test
252
+ ```
253
+
254
+ Record the list of failing `<file>:<line>` entries and process them one at a time. Do not attempt parallel fixes — shared state and the single CLI session make that fragile.
255
+
256
+ ### 3.2 Debug one failure
257
+
258
+ Run the single failing test in debug mode in the background, then attach:
259
+
260
+ ```bash
261
+ PLAYWRIGHT_HTML_OPEN=never npx playwright test tests/<group>/<scenario>.spec.ts:<line> --debug=cli
262
+ # wait for "Debugging Instructions" and the tw-XXXX session name
263
+ playwright-cli attach tw-XXXX
264
+ ```
265
+
266
+ The test is paused at the start. Step forward or run to until just before the failing action or assertion, then diagnose:
267
+
268
+ ```bash
269
+ playwright-cli snapshot # did the element change / move / rename?
270
+ playwright-cli console # app-side errors?
271
+ playwright-cli network # failed request? wrong payload?
272
+ playwright-cli show --annotate # ask the user to point somewhere
273
+ ```
274
+
275
+ Common causes: selector drift, new wrapper element, label/ARIA rename, timing (transition, async load), assertion text updated in the app, test data leaking between runs.
276
+
277
+ Rehearse the corrected interaction with `playwright-cli` — the generated code in the output is what you paste back into the test.
278
+
279
+ ### 3.3 Apply the fix
280
+
281
+ Edit the test file: update the locator, assertion, step order, or inputs to match the corrected behaviour. Stop the background debug run. Rerun the single test to confirm green.
282
+
283
+ Never skip hooks or add sleeps as a fix. Never use `networkidle`.
284
+
285
+ ### 3.4 Reconcile with the spec
286
+
287
+ Open the spec referenced by the `// spec:` header in the test file and locate the scenario that matches the test.
288
+
289
+ - **Fix was purely technical** (locator drift, better assertion shape) and the spec's user-level behaviour still matches the app → leave the spec alone.
290
+ - **Fix changed user-visible steps, inputs, order, or expected outcomes** that the spec describes → update the spec to match reality. Keep the scenario id and file path stable; only the step / expect lines change.
291
+ - **Unclear whether the app change is intentional** (spec is stale) **or a regression** (test was right, app is wrong) → **stop and ask the user**. Provide:
292
+ - the scenario id (e.g. `2.3`),
293
+ - the spec lines that no longer match,
294
+ - the observed app behaviour (quote a snapshot excerpt or a concrete outcome).
295
+
296
+ Only after the user answers, either update the spec (intentional change) or file/flag the test as covering a bug (regression).
297
+
298
+ ### 3.5 Iteration and giving up
299
+
300
+ - Fix failures one at a time; rerun after each.
301
+ - If after thorough investigation you are confident the test is correct but the app is wrong _and_ the user has confirmed it's a bug: mark the test `test.fixme(...)` with a comment pointing at the user's decision or issue link. Never silently skip.
302
+
303
+ ---
304
+
305
+ ## Cross-references
306
+
307
+ | For... | See |
308
+ | ---------------------------------------------- | ---------------------------------------------- |
309
+ | `--debug=cli` / attach mechanics | [playwright-tests.md](playwright-tests.md) |
310
+ | How `playwright-cli` actions become TS | [test-generation.md](test-generation.md) |
311
+ | Mocking requests during exploration/generation | [request-mocking.md](request-mocking.md) |
312
+ | Managing the CLI browser session | [session-management.md](session-management.md) |
@@ -0,0 +1,275 @@
1
+ # Storage Management
2
+
3
+ Manage cookies, localStorage, sessionStorage, and browser storage state.
4
+
5
+ ## Storage State
6
+
7
+ Save and restore complete browser state including cookies and storage.
8
+
9
+ ### Save Storage State
10
+
11
+ ```bash
12
+ # Save to auto-generated filename (storage-state-{timestamp}.json)
13
+ playwright-cli state-save
14
+
15
+ # Save to specific filename
16
+ playwright-cli state-save my-auth-state.json
17
+ ```
18
+
19
+ ### Restore Storage State
20
+
21
+ ```bash
22
+ # Load storage state from file
23
+ playwright-cli state-load my-auth-state.json
24
+
25
+ # Reload page to apply cookies
26
+ playwright-cli open https://example.com
27
+ ```
28
+
29
+ ### Storage State File Format
30
+
31
+ The saved file contains:
32
+
33
+ ```json
34
+ {
35
+ "cookies": [
36
+ {
37
+ "name": "session_id",
38
+ "value": "abc123",
39
+ "domain": "example.com",
40
+ "path": "/",
41
+ "expires": 1735689600,
42
+ "httpOnly": true,
43
+ "secure": true,
44
+ "sameSite": "Lax"
45
+ }
46
+ ],
47
+ "origins": [
48
+ {
49
+ "origin": "https://example.com",
50
+ "localStorage": [
51
+ { "name": "theme", "value": "dark" },
52
+ { "name": "user_id", "value": "12345" }
53
+ ]
54
+ }
55
+ ]
56
+ }
57
+ ```
58
+
59
+ ## Cookies
60
+
61
+ ### List All Cookies
62
+
63
+ ```bash
64
+ playwright-cli cookie-list
65
+ ```
66
+
67
+ ### Filter Cookies by Domain
68
+
69
+ ```bash
70
+ playwright-cli cookie-list --domain=example.com
71
+ ```
72
+
73
+ ### Filter Cookies by Path
74
+
75
+ ```bash
76
+ playwright-cli cookie-list --path=/api
77
+ ```
78
+
79
+ ### Get Specific Cookie
80
+
81
+ ```bash
82
+ playwright-cli cookie-get session_id
83
+ ```
84
+
85
+ ### Set a Cookie
86
+
87
+ ```bash
88
+ # Basic cookie
89
+ playwright-cli cookie-set session abc123
90
+
91
+ # Cookie with options
92
+ playwright-cli cookie-set session abc123 --domain=example.com --path=/ --httpOnly --secure --sameSite=Lax
93
+
94
+ # Cookie with expiration (Unix timestamp)
95
+ playwright-cli cookie-set remember_me token123 --expires=1735689600
96
+ ```
97
+
98
+ ### Delete a Cookie
99
+
100
+ ```bash
101
+ playwright-cli cookie-delete session_id
102
+ ```
103
+
104
+ ### Clear All Cookies
105
+
106
+ ```bash
107
+ playwright-cli cookie-clear
108
+ ```
109
+
110
+ ### Advanced: Multiple Cookies or Custom Options
111
+
112
+ For complex scenarios like adding multiple cookies at once, use `run-code`:
113
+
114
+ ```bash
115
+ playwright-cli run-code "async page => {
116
+ await page.context().addCookies([
117
+ { name: 'session_id', value: 'sess_abc123', domain: 'example.com', path: '/', httpOnly: true },
118
+ { name: 'preferences', value: JSON.stringify({ theme: 'dark' }), domain: 'example.com', path: '/' }
119
+ ]);
120
+ }"
121
+ ```
122
+
123
+ ## Local Storage
124
+
125
+ ### List All localStorage Items
126
+
127
+ ```bash
128
+ playwright-cli localstorage-list
129
+ ```
130
+
131
+ ### Get Single Value
132
+
133
+ ```bash
134
+ playwright-cli localstorage-get token
135
+ ```
136
+
137
+ ### Set Value
138
+
139
+ ```bash
140
+ playwright-cli localstorage-set theme dark
141
+ ```
142
+
143
+ ### Set JSON Value
144
+
145
+ ```bash
146
+ playwright-cli localstorage-set user_settings '{"theme":"dark","language":"en"}'
147
+ ```
148
+
149
+ ### Delete Single Item
150
+
151
+ ```bash
152
+ playwright-cli localstorage-delete token
153
+ ```
154
+
155
+ ### Clear All localStorage
156
+
157
+ ```bash
158
+ playwright-cli localstorage-clear
159
+ ```
160
+
161
+ ### Advanced: Multiple Operations
162
+
163
+ For complex scenarios like setting multiple values at once, use `run-code`:
164
+
165
+ ```bash
166
+ playwright-cli run-code "async page => {
167
+ await page.evaluate(() => {
168
+ localStorage.setItem('token', 'jwt_abc123');
169
+ localStorage.setItem('user_id', '12345');
170
+ localStorage.setItem('expires_at', Date.now() + 3600000);
171
+ });
172
+ }"
173
+ ```
174
+
175
+ ## Session Storage
176
+
177
+ ### List All sessionStorage Items
178
+
179
+ ```bash
180
+ playwright-cli sessionstorage-list
181
+ ```
182
+
183
+ ### Get Single Value
184
+
185
+ ```bash
186
+ playwright-cli sessionstorage-get form_data
187
+ ```
188
+
189
+ ### Set Value
190
+
191
+ ```bash
192
+ playwright-cli sessionstorage-set step 3
193
+ ```
194
+
195
+ ### Delete Single Item
196
+
197
+ ```bash
198
+ playwright-cli sessionstorage-delete step
199
+ ```
200
+
201
+ ### Clear sessionStorage
202
+
203
+ ```bash
204
+ playwright-cli sessionstorage-clear
205
+ ```
206
+
207
+ ## IndexedDB
208
+
209
+ ### List Databases
210
+
211
+ ```bash
212
+ playwright-cli run-code "async page => {
213
+ return await page.evaluate(async () => {
214
+ const databases = await indexedDB.databases();
215
+ return databases;
216
+ });
217
+ }"
218
+ ```
219
+
220
+ ### Delete Database
221
+
222
+ ```bash
223
+ playwright-cli run-code "async page => {
224
+ await page.evaluate(() => {
225
+ indexedDB.deleteDatabase('myDatabase');
226
+ });
227
+ }"
228
+ ```
229
+
230
+ ## Common Patterns
231
+
232
+ ### Authentication State Reuse
233
+
234
+ ```bash
235
+ # Step 1: Login and save state
236
+ playwright-cli open https://app.example.com/login
237
+ playwright-cli snapshot
238
+ playwright-cli fill e1 "user@example.com"
239
+ playwright-cli fill e2 "password123"
240
+ playwright-cli click e3
241
+
242
+ # Save the authenticated state
243
+ playwright-cli state-save auth.json
244
+
245
+ # Step 2: Later, restore state and skip login
246
+ playwright-cli state-load auth.json
247
+ playwright-cli open https://app.example.com/dashboard
248
+ # Already logged in!
249
+ ```
250
+
251
+ ### Save and Restore Roundtrip
252
+
253
+ ```bash
254
+ # Set up authentication state
255
+ playwright-cli open https://example.com
256
+ playwright-cli eval "() => { document.cookie = 'session=abc123'; localStorage.setItem('user', 'john'); }"
257
+
258
+ # Save state to file
259
+ playwright-cli state-save my-session.json
260
+
261
+ # ... later, in a new session ...
262
+
263
+ # Restore state
264
+ playwright-cli state-load my-session.json
265
+ playwright-cli open https://example.com
266
+ # Cookies and localStorage are restored!
267
+ ```
268
+
269
+ ## Security Notes
270
+
271
+ - Never commit storage state files containing auth tokens
272
+ - Add `*.auth-state.json` to `.gitignore`
273
+ - Delete state files after automation completes
274
+ - Use environment variables for sensitive data
275
+ - By default, sessions run in-memory mode which is safer for sensitive operations