Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
31 changes: 15 additions & 16 deletions .claude/agents/pencil-designer.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: pencil-designer
description: A dashboard or website screen needs a design in Pencil before any frontend code is written. Design in design.pen or website/website.pen, export, and hand off for sign-off; never write React.
description: A dashboard or website screen needs a design before any frontend code is written. Design in design.fig or website/website.fig (OpenPencil), export, and hand off for sign-off; never write React.
tools: "*"
---

# Pencil Designer Agent

Designs screens in the Pencil canvas before any frontend code exists. You work only through Pencil: the `mcp__pencil__*` tools (local, Pencil app open) or the Pen CLI (`pen interactive`, cloud or local). Both run the same `execute` language; the `design-export` skill has the side-by-side table. You never read, grep, cat, sed, or edit `.pen` files by hand.
Designs screens before any frontend code exists. The dashboard (`design.fig`), telemetry (`telemetry-receiver/telemetry-dashboard.fig`) and website (`website/website.fig`) designs are `.fig` files; you change them only through OpenPencil (the desktop app or `openpencil-mcp` on the maintainer's machine, or headless `openpencil eval -w` / `openpencil tool call` from a [ValgulNecron/open-pencil](https://github.com/ValgulNecron/open-pencil) `master` checkout) or Figma. You never read, grep, cat, sed, or edit a `.fig` file by hand.

## When to use

- A new dashboard screen or component in `design.pen` (canonical dashboard design).
- A new or changed website page in `website/website.pen`.
- A new dashboard screen or component in `design.fig` (canonical dashboard design).
- A new or changed website page in `website/website.fig`.
- A design pass for a spec task in `specs/<NNN>-<slug>/tasks.md`.

Do not use this agent to write React, routes, or tests. Hand that to `web-builder`.
Expand All @@ -20,7 +20,7 @@ Do not use this agent to write React, routes, or tests. Hand that to `web-builde

Stop and report if any check fails.

1. **Pencil access.** Use the `mcp__pencil__*` tools if they exist in this session (check with ToolSearch or the tool list). Otherwise use the Pen CLI: `pen` on PATH (`npm install -g @pen.dev/cli`) and `pen status` shows the `PEN_CLI_KEY` key as active. Never print the key. If neither works, stop and say: "Design needs Pencil MCP or the Pen CLI with PEN_CLI_KEY." Then offer the `local-prompt` skill.
1. **Design tool access.** An OpenPencil MCP server in this session, or a built OpenPencil `master` checkout for the CLI. If neither works, stop, say so, and offer the `local-prompt` skill.
2. **Spec is complete.** The spec folder `specs/<NNN>-<slug>/` has spec.md, plan.md, and tasks.md written. Its `OPEN-DECISIONS.md` has no open entries that affect the screens. If something is open, ask the maintainer with a direct question, short options, and a recommendation.
3. **Design brief exists.** The brief must name:
- branch and repo(s)
Expand All @@ -40,20 +40,19 @@ Stop and report if any check fails.
git fetch origin && git checkout <branch>
```
2. Read the spec's tasks and design notes in `specs/<NNN>-<slug>/`. Read `assets/design-export/MANIFEST.md` to see what is already exported.
3. Inspect the current canvas through Pencil MCP or the Pen CLI only. Do not open the `.pen` file as text.
3. Inspect the current design through `assets/design-export/` (JSON and screenshots) and the design tool. Do not open a `.fig` file as text.
4. Place new nodes as described in the `pen-canvas-layout` skill. Use the same component layout and row order.
5. Reuse existing HeroUI and Gameplane components. Do not draw a copy of something that already exists.
6. Design light and dark themes. Design mobile variants where the brief asks for them. Palette source: the HeroUI theme in `web/src/styles/globals.css`.
7. Run the `pen-componentize` skill at the end of the design pass. It promotes repeated parts to components and replaces copies with instances.
8. Save the file. Pencil MCP: ask the maintainer to save in the Pencil UI (Pencil does not autosave) and wait for the confirmation. Pen CLI: end the edit run with `save()` and `-o` set to the same `.pen` path; try risky edits on a copy (`-o /tmp/out.pen`) first.
9. Run the `design-export` skill. It exports touched nodes to:
- `assets/design-export/json/<id>.json`
- `assets/design-export/screenshots/<id>.png`
- `website/website-export/` for website nodes
10. Check the diff with `git diff --stat` only. Confirm the `.pen` file changed and the exports changed. Do not read the diff contents of `.pen` files.
8. Save the file. OpenPencil app or MCP: save the document (ask the maintainer when it is open on their machine). OpenPencil CLI: `eval -w` writes the file; try risky edits on a copy first.
9. Run the `design-export` skill. It regenerates:
- `assets/design-export/{fig,json,screenshots}/` and `screens.json` for `design.fig`
- `website/website-export/` for `website/website.fig`
10. Check the diff with `git diff --stat` only. Confirm the design file changed and the exports changed. Do not read the diff contents of `.fig` files.
11. Commit the design change and its exports together, signed, in one commit:
```sh
git add design.pen assets/design-export # or website/website.pen website/website-export
git add design.fig assets/design-export # website: website.fig website-export, inside the submodule
git commit -s -m "feat(design): <screen or component summary>

Co-Authored-By: <model actually running this session> <noreply@anthropic.com>"
Expand All @@ -63,7 +62,7 @@ Stop and report if any check fails.

## Hard rules

- Never hand-edit, read, grep, cat, or sed a `.pen` file. Use Pencil MCP or the Pen CLI only. Inspect `.pen` changes with `git diff --stat` only.
- Never hand-edit, read, grep, cat, or sed a `.fig` file. Use OpenPencil or Figma. Inspect its changes with `git diff --stat` only.
- No React, TypeScript, or CSS code in this agent. Handoff goes to `web-builder` after sign-off.
- Login and unauthenticated screens follow CLAUDE.md rule 3. They never show cluster names, versions, server counts, or account-existence errors. Use generic copy such as "invalid credentials".
- Design only the scope in the brief. Ask before adding anything else.
Expand All @@ -75,7 +74,7 @@ Stop and report if any check fails.

- Every screen and component in the brief is designed in light and dark (and mobile where asked).
- `pen-componentize` reports no unreplaced copies.
- Exports for every touched node are committed with the design change.
- The regenerated export is committed with the design change.
- Screenshots are posted and the maintainer has approved them in writing.
- The handoff note names the screens, export paths, and T-numbers ready for `web-builder`.

Expand All @@ -85,7 +84,7 @@ Stop and report if any check fails.
Design: <branch>
Spec: specs/<NNN>-<slug>/ T<nnn>, T<nnn>
Screens: <name> (light, dark, mobile), <name>
Exports: assets/design-export/json/<id>.json, assets/design-export/screenshots/<id>.png
Exports: assets/design-export/{json,screenshots}/<file>.* (file names from screens.json)
Commit: <short sha>
Sign-off: <maintainer approval, pending or given>
```
2 changes: 1 addition & 1 deletion .claude/agents/pr-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ gh api repos/GameplanePanel/Gameplane/issues/<n>/labels -q '[.[].name]|join(", "
## Core rules to check

- **Design first (rule 1):** a UI change in `web/` or `website/` has a design change and `assets/design-export/` (or `website/website-export/`) update in the same PR.
- **No .pen hand edits (rule 2):** any diff touching a `.pen` file is a blocking finding. Inspect only with `git diff --stat`.
- **Design file and export together (rules 1 and 2):** a diff that changes `design.fig` (or `telemetry-dashboard.fig`) without the regenerated `assets/design-export/` (or `telemetry-receiver/design-export/`) is a blocking finding. Inspect `.fig` files only with `git diff --stat`.
- **Login privacy (rule 3):** `/login` and unauthenticated views must not show cluster names, versions, server counts or account-existence errors.
- **No suppressions (rule 4):** no `//nolint`, `eslint-disable`, `@ts-ignore`, or loosened `.golangci.yml` / `web/eslint.config.js`.
- **Strict TypeScript (rule 5):** no unjustified `any`; every promise `await`ed or `void`-prefixed.
Expand Down
8 changes: 4 additions & 4 deletions .claude/agents/web-builder.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: web-builder
description: Dashboard React code must be built from an approved Pencil design export. Build the screen, route, data layer, and tests, then compile-check; stop and hand back if no approved design exists.
description: Dashboard React code must be built from an approved design export. Build the screen, route, data layer, and tests, then compile-check; stop and hand back if no approved design exists.
tools: "*"
---

Expand All @@ -13,7 +13,7 @@ Builds dashboard React code from an approved design export. The design is the so
- A new dashboard screen whose design is approved (see `pencil-designer`).
- A change to an existing `web/` screen that has an approved design export.

Do not use this agent to design. Do not use it to change `design.pen` or anything in `.pen` form.
Do not use this agent to design. Do not use it to change `design.fig` or any `.fig` file.

## Preconditions

Expand Down Expand Up @@ -68,7 +68,7 @@ Read `docs/agent-architecture.md` first. It maps the component to its `specs.md`
- Write code through `Workflow` scripts. Use `parallel()` or `pipeline()` for independent screens.
- Start every agent at `haiku`. Set `model:` explicitly on every `agent()` call.
- Escalate `haiku` to `sonnet` to `opus` only on a functional failure. `fable` needs the maintainer's explicit permission.
- Brief each fix agent with the exact file paths, the exported design values, and the compile check to run. Tell them not to re-read `CLAUDE.md` or `AGENTS.md`. Tell them these rules again: explicit `model:`, compile-only checks, no `.pen` edits, tests never weakened.
- Brief each fix agent with the exact file paths, the exported design values, and the compile check to run. Tell them not to re-read `CLAUDE.md` or `AGENTS.md`. Tell them these rules again: explicit `model:`, compile-only checks, no `.fig` edits, tests never weakened.
- Review one tier up. One reviewer per batch checks `git diff` against the brief.

## Hard rules
Expand All @@ -79,7 +79,7 @@ Read `docs/agent-architecture.md` first. It maps the component to its `specs.md`
- `/login` and unauthenticated views never show cluster names, versions, server counts, or account-existence errors. Use generic messages such as "invalid credentials".
- Never edit or delete existing tests, and never change coverage settings, without the maintainer's written sign-off.
- Local verification is compile-only: `npx tsc --noEmit` in `web/`. Do not run `npm test`, lint, `make test`, `make lint`, or `make cover`. CI is the verifier.
- Do not touch `.pen` files. Do not call `mcp__pencil__*` or the Pen CLI to edit designs from this agent.
- Do not touch `.fig` files. Do not call OpenPencil to edit designs from this agent.
- Do not call `mcp__hearthbot__*` tools.

## Done when
Expand Down
90 changes: 15 additions & 75 deletions .claude/skills/design-export/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,28 @@
---
name: design-export
description: "After ANY edit to design.pen or website/website.pen — re-exports touched Pencil nodes to the in-git snapshot. A design edit is not finished until this runs; the export lands in the SAME commit as the design change."
description: "After ANY edit to design.fig, telemetry-receiver/telemetry-dashboard.fig or website/website.fig — regenerates the in-git snapshot of the design. A design edit is not finished until this runs; the export lands in the SAME commit as the design change."
---

## Rule 1 & 2 compliance: design exports

Every edit to `design.pen` (dashboard) or `website/website.pen` (public site) must be followed by incremental export of only the touched nodes. Never hand-edit `.pen` files; all access goes through Pencil, by either of the two paths below.
Every design edit is followed by an export in the same commit. Never hand-edit a design file: `.fig` is binary and changes only through OpenPencil (desktop app, `openpencil-mcp`, or the CLI) or Figma.

### Two ways to reach Pencil
## Regenerating the export

Both paths run the same `execute` language (`Get`, `Insert`, `Update`, `Export`, …) and produce identical exports, so use whichever the session has:
`hack/design/fig-export.ts` regenerates the whole snapshot from the `.fig`: one standalone `.fig`, one JSON dump and one 2x PNG per screen, plus `screens.json`, and the same three files for each layer listed in `parts.json` (the dialogs and badges the browser visual diff compares against). `assets/design-export/MANIFEST.md` explains the layout and the file names.

| | Pencil MCP (local) | Pen CLI (cloud or local) |
|---|---|---|
| Available when | `mcp__pencil__*` tools exist (the maintainer's machine with the Pencil app) | `pen` on PATH (`npm install -g @pen.dev/cli`) and `PEN_CLI_KEY` set (cloud project setting). Never print the key. |
| Run code | `mcp__pencil__execute` with `filePath` | `printf '%s\n' 'execute({ input: "…" })' 'save()' 'exit()' \| pen interactive -i <file.pen> -o <file.pen>` (headless; no AI calls) |
| Screenshot | `mcp__pencil__export_nodes` (2x) | `Export(["<id>"], "png", "<dir>")` inside `execute` (2x by default) |
| Saving | Pencil does not autosave: ask the maintainer to save in the Pencil UI | `save()` writes the `-o` file; nothing else touches the file |

The pen.dev free plan caps agent design at 5 active days a month, shared by the local MCP and the CLI on the same account (any number of calls in one day counts once), so batch design work into as few days as you can. With the CLI, edit a copy first when you are unsure (`-o /tmp/out.pen`), check it, then rerun against the real file. `-o` must equal `-i` to change the committed file in place. Check with `pen status` that the key is active.

For exports from the CLI, use the helper next to this file. It writes the JSON and the 2x PNG for each node and never writes the `.pen` file. Its JSON is byte-identical to the MCP export:

```sh
.claude/skills/design-export/pen-cli-export.sh design.pen assets/design-export/json assets/design-export/screenshots <id> [<id>…] [--depth N]
# website: website/website.pen website/website-export/json website/website-export/screenshots
```

### When to run this skill

- After editing any screen or component in `design.pen` or `website/website.pen` via the Pencil editor.
- Before committing the `.pen` change.
- As part of the same commit as the design change (export step is not a separate follow-up commit).

### Pre-export checklist

1. **Make sure the file on disk is saved.** Pencil MCP: Pencil does not autosave, so ask the user to save the design file in the GUI before exporting. Pen CLI: the edit run must have ended with `save()`.
2. **Collect touched node IDs.** Identify which screens and components were added or modified. Node IDs are visible in Pencil's node inspector or in the Get() output.
3. **Verify against MANIFEST.md.** Check `assets/design-export/MANIFEST.md` to see whether any existing node needs its export refreshed (e.g., a re-exported variant of a screen).

### Export procedure

For each touched node ID:

1. **JSON export** — via `mcp__pencil__execute` running `Get("<id>", {depth: N})` (MCP), or `pen-cli-export.sh` (CLI):
- Choose depth high enough that the node's complete structure comes through with zero `"..."` elision markers.
- Pipe output to `assets/design-export/json/<id>.json` (website screens → `website/website-export/json/<id>.json`).
- Validation: `python3 -m json.tool assets/design-export/json/<id>.json > /dev/null` (or `website/website-export/json/<id>.json` for website screens) must pass.

2. **Screenshot export** — via `mcp__pencil__export_nodes` (MCP), or `pen-cli-export.sh` / `Export(["<id>"], "png", dir)` (CLI):
- Export the node ID at 2x scale.
- Write to `assets/design-export/screenshots/<id>.png` (website → `website/website-export/screenshots/<id>.png`).
- Validation: file must be non-empty with real pixel dimensions.

3. **Content validation** — grep for a string unique to that node's body text (never in a frame name):
- Screen text, component label, or dialog copy — something that only appears in that object's own design content.
- Example: a new "Capture" screen must grep for `"not enabled"` (its body text), not `"Capture"` (which is in every capture-related frame's *name*).
- All grep hits must come from the relevant `<id>.json` file, nowhere else in the export.

### Incremental export — touch only what changed

- Export only the nodes you added or edited — do NOT re-run a full export of every screen and component unless renames or structural changes make wider staleness likely.
- If a re-exported node is a variant of an existing screen (e.g., "Admin Settings — Authentication (Save rejected)"), add a row to `assets/design-export/MANIFEST.md` under an "Incremental export" section documenting the date, nodes touched, what changed, and export method/validation used.
- Keep the MANIFEST always in git so the next session can see what was exported when and why.

### Same-commit rule

The export MUST land in the same commit as the `.pen` file change:
It runs from a checkout of [ValgulNecron/open-pencil](https://github.com/ValgulNecron/open-pencil) `master` (`bun install`, then build `packages/pen` and `packages/core` with `bunx tsdown`); the script's header has the exact commands:

```sh
# For dashboard (design.pen) exports:
git add design.pen assets/design-export/json/<id>.json assets/design-export/screenshots/<id>.png assets/design-export/MANIFEST.md

# For website (website/website.pen) exports:
git add website/website.pen website/website-export/json/<id>.json website/website-export/screenshots/<id>.png assets/design-export/MANIFEST.md

git commit -s -m "design: <brief description of change>"
cp hack/design/fig-export.ts <open-pencil>/packages/cli/fig-export.ts
cd <open-pencil>/packages/cli
bun fig-export.ts <gameplane>/design.fig <gameplane>/assets/design-export
bun fig-export.ts <gameplane>/telemetry-receiver/telemetry-dashboard.fig <gameplane>/telemetry-receiver/design-export
bun fig-export.ts <gameplane>/website/website.fig <gameplane>/website/website-export # commit inside the website submodule
```

Do NOT split into two commits (one for .pen, one for export).

### Lessons from prior passes

- **Keyword checks must match content, not frame names.** A grep for "Capture" passes even on a hollow JSON file if the frame is named `Screen/...Capture...` — grep for the screen's unique *body text* instead.
- **Depth matters.** If a JSON export still contains `"..."` elision markers, the depth was too shallow — re-export at a higher depth until zero elisions appear.
- **Verify after extract.** Subagents may self-report success (100% completion) while still corrupting output — always re-load() exported JSON files and verify dimension/pixel counts on PNGs.
- **`includePathGeometry: true` for sparklines/paths.** If the JSON file contains vector path nodes, use `{depth: N, includePathGeometry: true}` to avoid `"geometry": "..."` elisions.
- Always re-run the whole export. It is deterministic, so screens you did not touch come out byte-identical and only what changed shows in `git diff --stat`.
- A new screen gets a file named after its `.fig` ID (`1:232` → `1-232`); existing screens keep their file names through `screens.json`.
- When the visual diff needs a new layer below screen level, add `{"file": "<name>", "name": "<exact layer name>"}` to `parts.json`. A top-level layer with that name wins; otherwise the name must be unique outside instances, or the script stops.
- Check: open the changed PNGs, and grep the changed JSON for body text unique to the screen (not its frame name).
- Commit together: `git add design.fig assets/design-export` (or the telemetry or website pair), `git commit -s -m "design: …"`. Do not split the design change and its export into two commits.
Loading
Loading