You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Bootstrap a UI dev sandbox — Playwright end-to-end testing scaffolding for the cozystack-ui SPA plus a Vite dev server connected to a chosen Kubernetes cluster. Use whenever the operator wants to fix, debug, screenshot, or write Playwright tests against the Cozystack console — e.g. "prepare cozystack-ui for a fix", "spin up the UI against my dev cluster", "install playwright in cozystack-ui", "give me a UI sandbox pointing at <kubeconfig>". Handles worktree creation, @playwright/test + Chromium install, playwright.config.ts, dev:e2e / test:e2e scripts, kubectl proxy against a kubeconfig, and a Vite server on a free port so the operator can immediately start poking at the running app.
3
+
description: Bootstrap a UI dev sandbox — Playwright end-to-end testing scaffolding for the Cozystack console UI (vendored in the monorepo at `packages/system/dashboard/images/console`) plus a Vite dev server connected to a chosen Kubernetes cluster. Use whenever the operator wants to fix, debug, screenshot, or write Playwright tests against the Cozystack console — e.g. "prepare the console UI for a fix", "spin up cozystack-ui against my dev cluster", "install playwright in the console", "give me a UI sandbox pointing at <kubeconfig>". Handles monorepo worktree creation, @playwright/test + Chromium install, playwright.config.ts, dev:e2e / test:e2e scripts, kubectl proxy against a kubeconfig, and a Vite server on a free port so the operator can immediately start poking at the running app.
This skill puts an operator in front of a running, working copy of `cozystack-ui`with Playwright wired up, pointed at a real Kubernetes cluster of their choosing. It is the standard entry point for "I want to fix something in the UI" tasks — every step is reversible and avoids touching the repo's main worktree.
9
+
This skill puts an operator in front of a runningcopy of the Cozystack console UI with Playwright wired up, pointed at a real Kubernetes cluster of their choosing. The UI is vendored in-tree in the `cozystack/cozystack` monorepo at `packages/system/dashboard/images/console` (the standalone `cozystack-ui` repo is archived). It is the standard entry point for "I want to fix something in the UI" tasks — every step is reversible and avoids touching the monorepo's main worktree.
10
10
11
11
Work in reasoning mode. Walk through the phases in order. State which phase you are in as you go, so the operator can interrupt early if a default is wrong for their machine.
12
12
@@ -19,60 +19,67 @@ Match the operator's natural language detected from prior conversation messages
19
19
`$ARGUMENTS` is the free-form tail after `/cozystack:dev-ui-bootstrap`. Extract:
20
20
21
21
-`--kubeconfig=<path>` — kubeconfig the Vite dev server should hit through `kubectl proxy`. If absent: list `~/.kube/*config*` files via `ls`, then `AskUserQuestion` to pick one, defaulting to `~/.kube/config` (or `$KUBECONFIG` if set). Never assume `~/.kube/config` silently — picking the wrong cluster is a frequent footgun.
22
-
-`--worktree=<name>` — name (relative to `<repo>/.claude/worktrees/`) for the throwaway worktree. Default: `fix-app` (matches the in-tree convention).
23
-
-`--port=<n>` — Vite dev port. Default: pick the first free port starting at `3002` (since `3001` is the repo default and is often already in use by another session).
24
-
-`--proxy-port=<n>` — `kubectl proxy` port. Default: `8001` (matches `apps/console/vite.config.ts`). If already in use by a proxy pointing at a *different* kubeconfig, pick the next free port (see Phase 7 for the Vite-side consequence).
22
+
-`--worktree=<name>` — name (relative to `<repo>/.claude/worktrees/`) for the throwaway monorepo worktree. Default: `fix-app`.
23
+
-`--port=<n>` — Vite dev port. Default: pick the first free port starting at `3002` (since `3001` is the console default and is often already in use by another session).
24
+
-`--proxy-port=<n>` — `kubectl proxy` port. Default: `8001` (matches the console's `apps/console/vite.config.ts`). If already in use by a proxy pointing at a *different* kubeconfig, pick the next free port (see Phase 7 for the Vite-side consequence).
25
25
-`--no-install` — skip `pnpm install` and `@playwright/test` install if they are already present.
## Phase 2 — Locate the console workspace (in-tree in the monorepo)
29
29
30
-
Resolve in priority order:
30
+
The console UI is a pnpm workspace inside the monorepo, not a standalone repo. Resolve two paths:
31
31
32
-
1. If `pwd` is inside a checkout of `cozystack-ui` (contains `apps/console/package.json` with `"name": "@cozystack/console"`) → use the repo root from `git rev-parse --show-toplevel`.
33
-
2.`~/aenix/cozystack-ui` — the canonical clone on contributors' workstations.
34
-
3. Otherwise — `AskUserQuestion` for the path. Do not `git clone`; the skill is for an already-cloned working copy.
-`$CONSOLE` — the workspace root, `$REPO/packages/system/dashboard/images/console` (all `pnpm` / `vite` / `playwright` / file edits happen here; it holds `pnpm-workspace.yaml`, the root `package.json`, `pnpm-lock.yaml`, and `apps/console`).
35
34
36
-
Verify `pnpm` and `kubectl` are on `$PATH`, and that the workspace's `package.json` has `"packageManager": "pnpm@..."`. If either binary is missing, stop and tell the operator to install it — do not auto-install package managers or CLIs. Catching this here avoids failing five phases deeper when `kubectl proxy` is first invoked.
35
+
Resolve `$REPO` in priority order:
36
+
37
+
1. If `pwd` is inside a cozystack monorepo checkout whose `<toplevel>/packages/system/dashboard/images/console/apps/console/package.json` has `"name": "@cozystack/console"` → use the toplevel from `git rev-parse --show-toplevel`.
38
+
2.`~/aenix/cozystack` — the canonical monorepo clone on contributors' workstations.
39
+
3. Otherwise — `AskUserQuestion` for the monorepo path. Do not `git clone`; the skill is for an already-cloned working copy.
40
+
41
+
> The console UI used to live in a standalone `cozystack-ui` repo. It was vendored into the monorepo (cozystack/cozystack#2963) and that repo is archived — there is no `~/aenix/cozystack-ui` to use anymore.
42
+
43
+
Verify `pnpm` and `kubectl` are on `$PATH`, and that `$CONSOLE/package.json` has `"packageManager": "pnpm@..."`. If either binary is missing, stop and tell the operator to install it — do not auto-install package managers or CLIs. Catching this here avoids failing five phases deeper when `kubectl proxy` is first invoked.
37
44
38
45
## Phase 3 — Worktree creation
39
46
40
-
Create a feature worktree off `main` for the upcoming fix work. The repo's CLAUDE.md is emphatic that the primary working directory must stay on its default branch — multiple Claude sessions share it.
47
+
Create a feature worktree of the **monorepo**off `main` for the upcoming fix work. The user's CLAUDE.md is emphatic that the primary working directory must stay on its default branch — multiple Claude sessions share it.
41
48
42
49
```bash
43
-
git -C <repo> worktree add <repo>/.claude/worktrees/<name> -b fix/<name> main
50
+
git -C $REPO worktree add $REPO/.claude/worktrees/<name> -b fix/<name> main
44
51
```
45
52
46
53
If a worktree at that path already exists:
47
54
48
55
- If clean and on the expected branch → reuse it; no `git worktree add`.
49
56
- If dirty or on a different branch → `AskUserQuestion`: reuse / pick a new name / cancel.
50
57
51
-
Set `$WT` to the absolute worktree path. Every subsequent command in this skill runs from `$WT`.
58
+
Set `$WT` to the absolute worktree path, and re-point `$CONSOLE` into it: `$CONSOLE="$WT/packages/system/dashboard/images/console"`. Every subsequent `pnpm` / `vite` / `playwright` / file command in this skill runs from`$CONSOLE`; only `git` and worktree operations use `$REPO` /`$WT`.
52
59
53
60
## Phase 4 — Install dependencies
54
61
55
-
Always run `pnpm install` once in `$WT` (fast no-op if the lockfile is satisfied) — workspace symlinks must exist before Playwright lands.
62
+
Always run `pnpm install` once in `$CONSOLE` (fast no-op if the lockfile is satisfied) — workspace symlinks must exist before Playwright lands. (Run it from `$CONSOLE`, not `$WT`: the monorepo root is not a pnpm workspace; the console subdirectory is.)
Chromium is ~120 MB. Note the size in the running commentary so an operator on a slow link knows what is happening. The download lives in `~/.cache/ms-playwright/` and is shared across worktrees — usually a one-time cost.
70
77
71
78
## Phase 5 — Write Playwright config + scripts
72
79
73
-
Idempotency: if `apps/console/playwright.config.ts` already exists, diff against the template below and ask before overwriting — the operator may have customised it.
80
+
Idempotency: if `$CONSOLE/apps/console/playwright.config.ts` already exists, diff against the template below and ask before overwriting — the operator may have customised it.
Replace `<PORT>` with the resolved Vite dev port. The `E2E_BASE_URL` env-var override lets CI or another session point Playwright at a different running instance.
99
106
100
-
Create `$WT/apps/console/e2e/` (empty — tests land here as the operator writes them).
107
+
Create `$CONSOLE/apps/console/e2e/` (empty — tests land here as the operator writes them).
101
108
102
-
Patch `$WT/apps/console/package.json``"scripts"` with `Edit` — preserve unrelated keys, do not rewrite the whole file:
109
+
Patch `$CONSOLE/apps/console/package.json``"scripts"` with `Edit` — preserve unrelated keys, do not rewrite the whole file:
103
110
104
111
- Add `"dev:e2e": "vite --port <PORT>"` next to `"dev"`.
105
112
- Add `"test:e2e": "playwright test"` next to `"test"`.
106
113
107
-
No semicolons in the config file — the repo's CLAUDE.md is strict: every file in the tree is semicolon-free, and reformatting unrelated files is forbidden.
114
+
No semicolons in the config file — the console's `CLAUDE.md` is strict: every file in the tree is semicolon-free, and reformatting unrelated files is forbidden.
108
115
109
116
## Phase 6 — Bring up `kubectl proxy`
110
117
@@ -119,53 +126,55 @@ Goal: a `kubectl proxy` instance is reachable on `$PROXY_PORT` and is talking to
119
126
```
120
127
4. Smoke-test with `curl -sS -o /dev/null -w "%{http_code}" http://localhost:$PROXY_PORT/api`. Expect `200`. `/api` is the unauthenticated API-group discovery endpoint — it returns `200` from any reachable apiserver and avoids false negatives from RBAC-restricted kubeconfigs that cannot `get namespaces/default`. On `401`/`403` the kubeconfig is wrong or expired — surface the error and stop. On connection refused, wait up to 5 s for the proxy to come up before failing.
121
128
122
-
Capture the proxy process ID and the kubeconfig path in a marker file at `$WT/.cozystack-dev-ui-bootstrap-proxy` so a follow-up session knows what is running. Never write secrets there — kubeconfig path and context name only.
129
+
Capture the proxy process ID and the kubeconfig path in a marker file at `$CONSOLE/.cozystack-dev-ui-bootstrap-proxy` so a follow-up session knows what is running. Never write secrets there — kubeconfig path and context name only.
123
130
124
131
## Phase 7 — Start the Vite dev server
125
132
126
-
If `$PROXY_PORT` is non-default (8001), the dev server still hard-codes `http://localhost:8001` in `vite.config.ts`. Two options:
133
+
If `$PROXY_PORT` is non-default (8001), the dev server still hard-codes `http://localhost:8001` in `apps/console/vite.config.ts`. Two options:
127
134
128
-
- Preferred: keep the default proxy port `8001` and explain why. The repo treats `vite.config.ts` as load-bearing and edits there are best left for a separate PR.
135
+
- Preferred: keep the default proxy port `8001` and explain why. The console treats `vite.config.ts` as load-bearing and edits there are best left for a separate PR.
129
136
- If the operator explicitly said "change the proxy port", `AskUserQuestion` before touching `vite.config.ts`.
130
137
131
-
Start the dev server in the background, redirecting output to a log file under `$WT` so the polling loop has something to grep:
138
+
Start the dev server in the background, redirecting output to a log file under `$CONSOLE` so the polling loop has something to grep:
Wait for the `ready in` / `Local:` line via a polling loop against that log file (`until grep -q "ready in" $WT/.cozystack-dev-ui-bootstrap-vite.log; do sleep 0.5; done`, with a 30 s timeout guard). Then `curl -sS -o /dev/null -w "%{http_code}" http://localhost:$PORT/` and expect `200`.
145
+
Wait for the `ready in` / `Local:` line via a polling loop against that log file (`until grep -q "ready in" $CONSOLE/.cozystack-dev-ui-bootstrap-vite.log; do sleep 0.5; done`, with a 30 s timeout guard). Then `curl -sS -o /dev/null -w "%{http_code}" http://localhost:$PORT/` and expect `200`.
139
146
140
147
If the server fails to bind (port already in use after the free-port scan), the cause is usually a stale `vite` from a prior crashed session. Run `lsof -nP -iTCP:$PORT -sTCP:LISTEN` and show the result — let the operator decide whether to kill it.
141
148
142
149
## Phase 8 — Summary
143
150
144
151
Print a compact handoff:
145
152
146
-
-Worktree: `$WT` (branch `fix/<name>`)
147
-
- Repo state: clean / dirty (one-line `git status -s`)
153
+
-Monorepo worktree: `$WT` (branch `fix/<name>`); console workspace at `$CONSOLE`
-`kubectl proxy`: `pid <n>` on `http://localhost:$PROXY_PORT` (smoke `200`)
150
157
- Vite dev: `pid <n>` on `http://localhost:$PORT` (smoke `200`)
151
-
- Playwright: configured at `apps/console/playwright.config.ts`, run with `pnpm --filter @cozystack/console test:e2e`
158
+
- Playwright: configured at `$CONSOLE/apps/console/playwright.config.ts`, run with `pnpm --filter @cozystack/console test:e2e` from `$CONSOLE`
152
159
- Next steps the operator can take, e.g.: "Tell me what to fix, or paste a Playwright test idea and I will draft it."
153
160
154
161
Do **not** open the browser. Leave that to the operator — the dev server is reachable and the operator may want to attach an authenticated session, devtools, or a screen recorder of their own choice.
155
162
156
163
## Guardrails
157
164
158
-
-**Never** run `git checkout` in the primary `cozystack-ui` working tree. All branch work happens inside the worktree from Phase 3.
159
-
-**Never** edit files in the primary working tree of `cozystack-ui`— only inside `$WT`.
165
+
-**Never** run `git checkout` in the primary cozystack monorepo working tree. All branch work happens inside the worktree from Phase 3.
166
+
-**Never** edit files in the primary monorepo working tree — only inside `$WT` / `$CONSOLE`.
160
167
-**Never** commit, push, or open a PR as part of this skill. The skill *prepares* the environment; the fix itself is a separate, operator-driven step that goes through the normal commit / PR gates.
161
168
-**Never** start a `kubectl proxy` with a kubeconfig the operator did not explicitly pick. If `--kubeconfig` is absent, ask.
162
169
-**Never** kill a process the operator did not authorise. If a port is occupied, show what is on it and stop.
163
-
-**Never** add a new top-level dependency to the cozystack-ui workspace other than `@playwright/test`. The repo's CLAUDE.md is strict about bundle size; Playwright is dev-only and acceptable.
170
+
-**Never** add a new top-level dependency to the console workspace other than `@playwright/test`. The console's `CLAUDE.md` is strict about bundle size; Playwright is dev-only and acceptable.
164
171
- Refuse to run against a kubeconfig whose current-context name contains `prod` unless the operator re-confirms with `AskUserQuestion`. The console is read/write — pointing it at production is a deploy-shaped risk.
165
172
166
173
## References
167
174
175
+
All paths below are relative to `$CONSOLE` (`packages/system/dashboard/images/console` inside the monorepo):
176
+
168
177
-`apps/console/vite.config.ts` — the existing dev server proxy contract (`/api`, `/apis`, `/k8s` → `http://localhost:8001`).
169
178
-`apps/console/package.json` — where the new `dev:e2e` and `test:e2e` scripts land.
170
-
-`CLAUDE.md` (repo root) — code style (no semicolons, `.ts` extensions in imports, no `any`, etc.) and the worktree mandate.
179
+
-`CLAUDE.md` (at `$CONSOLE`) — code style (no semicolons, `.ts` extensions in imports, no `any`, etc.). The monorepo root `AGENTS.md` covers the broader worktree mandate.
171
180
-`~/.kube/` — separate kubeconfigs per cluster (this host uses one-file-per-cluster, not a merged config).
0 commit comments