Skip to content

Commit 209cd1f

Browse files
chore(skills): add audit-widget skill with rich text example report
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 999f696 commit 209cd1f

5 files changed

Lines changed: 646 additions & 0 deletions

File tree

‎.agents/skills/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This directory contains all Claude Code skills for the web-widgets repository.
66

77
```
88
.agents/skills/
9+
├── audit-widget/ # Audit one widget (tests, perf, deps, smells, behaviours, docs) and fix by category
910
├── code-review/ # PR review skill for Mendix widget conventions
1011
├── debug-widget/ # Debug Mendix pluggable widget runtime issues
1112
├── openspec-apply-change/ # Implement tasks from OpenSpec change
@@ -26,6 +27,7 @@ This directory contains all Claude Code skills for the web-widgets repository.
2627

2728
Skills are automatically loaded by Claude Code. Users can invoke them via slash commands:
2829

30+
- `/audit-widget <widget>` — Audit one widget into `AUDIT.md`, then `/audit-widget <widget> fix` one category at a time
2931
- `/code-review` — Review current PR
3032
- `/debug-widget` — Debug widget runtime issues
3133
- `/openspec-*` or `/opsx:*` — OpenSpec workflow commands
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
name: audit-widget
3+
description: Audit one Mendix pluggable widget across seven categories (unit tests, e2e, performance, dependencies, code smells, missing behaviours, mx-docs drift) into a resumable AUDIT.md, then fix one category at a time, stopping after each for review and commit.
4+
---
5+
6+
# Audit Widget
7+
8+
Two-phase, resumable health check for one widget package. Phase 1 produces a report; Phase 2 fixes it **one category at a time and stops**.
9+
10+
The report file is the state machine. Everything needed to resume lives in it, so a fresh session can continue an audit it did not start.
11+
12+
## Invocation
13+
14+
```
15+
/audit-widget <widget> # Phase 1 — generate/refresh the report
16+
/audit-widget <widget> fix # Phase 2 — fix the next pending category, then STOP
17+
/audit-widget <widget> fix <category> # Phase 2 — fix a specific category, then STOP
18+
/audit-widget <widget> skip <category> # mark a category skipped, change nothing else
19+
/audit-widget <widget> status # print the category table, change nothing
20+
```
21+
22+
`<widget>` is a folder name under `packages/pluggableWidgets/` (e.g. `combobox-web`) or `packages/modules/` (e.g. `data-widgets`). If it is missing or ambiguous, ask — do not guess.
23+
24+
`<category>` is one of: `unit-tests`, `e2e-tests`, `performance`, `dependencies`, `smells`, `behaviours`, `docs`.
25+
26+
**Mode resolution:** no mode word → Phase 1. If `AUDIT.md` already exists and Phase 1 is requested again, ask whether to refresh it (re-audit, preserving `fixed`/`skipped` statuses) or to switch to `fix`.
27+
28+
## Scope discipline
29+
30+
- Audit **one package**. Read files under `packages/<type>/<widget>/` only.
31+
- Follow findings into `@mendix/widget-plugin-*` / shared packages **only** when the widget's own code cannot explain a finding — and say so explicitly in the finding. Never fix shared-package code as part of a widget audit; raise it as a separate note.
32+
- Dependency analysis uses **only that widget's `package.json`**. Never the root, never another package.
33+
- Never touch `dist/`, generated files (`typings/*.d.ts`), or lockfiles.
34+
- **The one exception is `docs`**: it reads — and in Phase 2 edits — the widget's page in the mx-docs repo. Resolve its location as `$MX_DOCS_PATH`, else `~/Projects/mx-docs`. If neither exists, mark `docs` as `skipped` with the reason in Notes; do not guess another path. Never edit any other mx-docs page than the widget's own (and its `_index.md` only if the page is a section).
35+
36+
## Phase 1 — Report
37+
38+
### 1. Orient (cheap, always do this first)
39+
40+
```bash
41+
cd packages/pluggableWidgets/<widget>
42+
```
43+
44+
Read, in this order:
45+
46+
1. `package.json` — deps, scripts, `widgetName`, `marketplace.minimumMXVersion`
47+
2. `AGENTS.md` if present — the widget's own architecture map, the highest-value context you will get
48+
3. `src/<WidgetName>.xml` — the property contract; this is the source of truth for expected behaviour
49+
4. `CHANGELOG.md` — recent behaviour changes, unreleased entries
50+
5. `openspec/specs/**` and `openspec/changes/**` — declared requirements and in-flight work
51+
6. Inventory (do not read contents yet):
52+
```bash
53+
find src -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.scss" \) | sort
54+
find src -path "*__tests__*" -name "*.spec.*" | sort
55+
ls e2e/*.spec.js
56+
```
57+
7. The mx-docs page for the widget — locate it now (lookup recipe in the `DOCS` section of [checklists.md](checklists.md)) and record its path in the report header. Do not read it in full yet.
58+
59+
### 2. Run the seven checks
60+
61+
Detection heuristics for each live in [checklists.md](checklists.md). Read it now — it is the substance of this skill.
62+
63+
| Category | ID prefix | What it answers |
64+
| ------------------ | --------- | ------------------------------------------------------------------- |
65+
| Unit tests | `UT` | Which modules/branches/states have no Jest+RTL coverage? |
66+
| E2E tests | `E2E` | Which user-visible flows have no Playwright spec, or a fragile one? |
67+
| Performance | `PERF` | What causes avoidable renders, work-in-render, or leaks? |
68+
| Dependencies | `DEP` | Patch/minor/major updates available for this widget's own deps |
69+
| Code smells | `SMELL` | Violations of repo conventions, dead code, type escapes |
70+
| Missing behaviours | `BEH` | XML/API/a11y contract the implementation does not honour |
71+
| Public docs | `DOCS` | Where the mx-docs page disagrees with the XML, changelog, or code |
72+
73+
Parallelising is allowed and encouraged here: dispatch one read-only `Explore` agent per category with the package path plus that category's section of `checklists.md`, then merge results. Keep `dependencies` for yourself — it needs a command run, not a search.
74+
75+
### 3. Verify before writing
76+
77+
Every finding must survive this filter, or it does not go in the report:
78+
79+
- **Evidence**: a `file:line` you actually read, or command output you actually ran.
80+
- **Failure scenario**: concrete inputs/config → wrong or slow result. "Could be cleaner" is not a finding.
81+
- **Not already handled**: check the code path once more for the guard you are claiming is absent.
82+
- **Not a shared-package concern** misattributed to the widget.
83+
- **Not handled by a library**: when the finding depends on how a framework or library behaves (for example, a callback captured by `useEditor(..., [])`), read that library's code in `node_modules` before reporting it. `@tiptap/react` forwards callbacks to the latest options, which made BEH-01 in the example report a false positive.
84+
- **Critical needs proof**: report a finding as Critical only after a failing test or a runtime reproduction. Otherwise report it as High and add _needs repro_.
85+
86+
Drop speculative findings silently. A short true report beats a long plausible one.
87+
88+
A real report produced by this skill is in [examples/rich-text-web.AUDIT.md](examples/rich-text-web.AUDIT.md), including findings later marked `fixed`, `stale` and added by tests.
89+
90+
### 4. Write the report
91+
92+
Write to `packages/<type>/<widget>/AUDIT.md` using [report-template.md](report-template.md). Then print to the user: the category table, the finding counts per severity, and the 3 findings you would fix first.
93+
94+
**Stop there.** Phase 1 never edits source, never installs, never commits.
95+
96+
## Phase 2 — Fix, one category, then stop
97+
98+
### Order
99+
100+
`unit-tests` → `e2e-tests` → `performance` → `dependencies` → `smells` → `behaviours` → `docs`
101+
102+
Tests come first on purpose: they are the safety net for the later categories. `docs` comes last because the earlier categories can change behaviour the docs must then describe. If the user asks for a later category first, do it — but say in one line that the test net is not in place yet.
103+
104+
### Per-category loop
105+
106+
1. **Resolve the category.** Explicit arg wins; otherwise the first row in the table whose status is `pending`. If none are pending, report that the audit is complete and stop.
107+
2. **Set status to `in-progress`** in `AUDIT.md`.
108+
3. **Plan.** List the findings you will address, in order, and the ones you are deliberately leaving (with why). If the category has more than ~6 findings, propose a cut line and ask before starting — a 20-file change is not reviewable in one sitting.
109+
4. **Fix.** Work finding by finding. Follow `AGENTS.md`, `docs/requirements/frontend-guidelines.md`, and for e2e work `docs/requirements/e2e-test-guidelines.md`. Prettier and ESLint run automatically on edit — do not invoke them manually.
110+
5. **Verify.** From the package root:
111+
- always: `pnpm run test`. To run a single spec, use `pnpm run test --testPathPatterns <name> --coverage=false`; a bare path argument does not filter, because the script is `jest --projects jest.config.js`.
112+
- `unit-tests`: if a correct assertion fails because the widget is wrong, do not assert the broken behaviour and do not leave an `it.todo`. Add the bug to the report as a new finding (next free ID in the right category, marked _found by tests_) and leave the test out until the fix PR.
113+
- `e2e-tests`: `pnpm run release` then `pnpm run e2e --no-setup-project`. If Docker or the test project is unavailable, say so plainly and leave the specs as written-but-unverified — do not claim a pass you did not see.
114+
- `dependencies`: `pnpm run test` **and** `pnpm turbo build`
115+
- `performance`, `behaviours`: `pnpm run test`; add or update a test that would have caught the issue
116+
- `docs`: no widget command. Instead, before editing, confirm the mx-docs working tree is clean and not on its default branch (`development`); if it is, create a local branch `docs/<widget>-sync` — never edit on the default branch, never push. Edit following mx-docs `CLAUDE.md` and its style guide (it takes precedence over this repo's conventions inside mx-docs). Afterwards run `npx markdownlint-cli2 <page>` from the mx-docs root if available, and re-read every changed `{#anchor}` / URL with a grep for inbound references.
117+
6. **Changelog.** If widget behaviour changed, add an entry under `## [Unreleased]` in the package `CHANGELOG.md`. User-facing wording only — no implementation detail. Do **not** bump the version. Pure test-only or dependency-only changes with no user-visible effect get no entry. `docs` never adds a widget changelog entry.
118+
7. **Update `AUDIT.md`**: set each addressed finding's status to `fixed` (or `skipped` with a reason), set the category status to `done`, and append a line to the Log section: `<date> — <category> — N fixed, M skipped`.
119+
8. **HALT.**
120+
121+
### The halt is the point
122+
123+
After one category, you are finished for this invocation. That means:
124+
125+
- Do **not** start the next category, even if it looks trivial or related.
126+
- Do **not** `git add`, `git commit`, `git push`, or open a PR. The user commits.
127+
- Do **not** ask "shall I continue?" — the user will invoke the skill again when ready.
128+
129+
Print exactly this shape and then end the turn:
130+
131+
```
132+
✅ <category> — N fixed, M skipped
133+
<one line per fixed finding: ID — what changed, file>
134+
135+
Verification: <command run> → <result>
136+
Next pending: <category> (K findings)
137+
138+
Suggested commit:
139+
<type>(<widget>): <subject>
140+
```
141+
142+
Commit `type` by category: `unit-tests`/`e2e-tests` → `test`, `performance` → `perf`, `dependencies` → `chore`, `smells` → `refactor`, `behaviours` → `fix` or `feat`. Scope is the folder name (`combobox-web`).
143+
144+
For `docs` the commit lives in the **mx-docs** repo, not this one: print the mx-docs branch name and a plain subject line (mx-docs does not use conventional commits), e.g. `Combo box: document <prop>, sync Properties Pane with v2.4.0`.
145+
146+
## Resuming cold
147+
148+
If `AUDIT.md` exists and you have no memory of writing it: trust it. Read it, read the widget's `AGENTS.md`, then act on the requested mode. Re-verify a finding's `file:line` before fixing it — the file may have moved since the report was written. If a finding no longer reproduces, mark it `stale` with a one-line note rather than inventing a fix.

0 commit comments

Comments
 (0)