Skip to content

Commit df014e4

Browse files
[CRAFTING] chore(skills): add audit-widget skill (#2461)
2 parents dc58ecc + 0c3a664 commit df014e4

4 files changed

Lines changed: 461 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 into a report (tests, perf, deps, security, smells, behaviours, docs)
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 and write the report to its `AUDIT.md`
2931
- `/code-review` — Review current PR
3032
- `/debug-widget` — Debug widget runtime issues
3133
- `/openspec-*` or `/opsx:*` — OpenSpec workflow commands
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
name: audit-widget
3+
description: Audit one Mendix pluggable widget and write a point-in-time report (AUDIT.md) on unit tests, e2e, performance, dependencies, security, code smells, missing behaviours and mx-docs drift. Report only — it never changes code.
4+
---
5+
6+
# Audit Widget
7+
8+
Writes a health report for **one** widget package. The skill reads code and runs read-only commands. The report is its only output.
9+
10+
## Invocation
11+
12+
```
13+
/audit-widget [<widget>]
14+
```
15+
16+
`<widget>` is a folder name under `packages/pluggableWidgets/` (e.g. `combobox-web`). If it is missing or matches no folder, ask which widget. Do not guess.
17+
18+
Every run is a fresh snapshot. If `AUDIT.md` already exists, replace it without reading it first: audit from scratch so old findings do not anchor the new ones.
19+
20+
## Hard rules
21+
22+
- **The report is the only file you write.** Never edit source, tests, config, `package.json`, docs, or the mx-docs repo. Output that commands write on their own (Jest coverage) is fine.
23+
- **Install nothing.** Never run `pnpm install`, `pnpm add`, `pnpm up` or `pnpm audit --fix`, and never run a script that downloads a tool. They change `package.json` or `pnpm-lock.yaml`, and the repo does not allow lockfile changes.
24+
- **No git writes.** Never `git add`, commit, branch or push. The user decides what to do with the report.
25+
- **Stay in the package.** Read files under `packages/pluggableWidgets/<widget>/` only. Follow a finding into a shared `@mendix/widget-plugin-*` package only when the widget's own code cannot explain it, and record it in Notes, not as a widget finding.
26+
- **mx-docs is read-only.** Read it from `$MX_DOCS_PATH`, else `~/Projects/mx-docs`. If neither exists, skip `DOCS` and say why in Notes.
27+
28+
## 1. Orient
29+
30+
```bash
31+
cd packages/pluggableWidgets/<widget>
32+
git rev-parse --short HEAD # record in the report header
33+
```
34+
35+
Read, in this order:
36+
37+
1. `package.json` — deps, scripts, `widgetName`, `marketplace`
38+
2. `AGENTS.md` if present — the widget's own architecture map, the highest-value context you will get
39+
3. `src/<WidgetName>.xml` — the property contract; this is the source of truth for expected behaviour
40+
4. `CHANGELOG.md` — recent behaviour changes
41+
5. `openspec/specs/**` and `openspec/changes/**` — declared requirements and in-flight work
42+
6. Inventory (do not read contents yet):
43+
```bash
44+
find src -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.scss" \) | sort
45+
find src -path "*__tests__*" -name "*.spec.*" | sort
46+
ls e2e/*.spec.js
47+
```
48+
7. The mx-docs page for the widget — locate it with the recipe in the `DOCS` section of [checklists.md](checklists.md) and record its path. Do not read it in full yet.
49+
50+
## 2. Run the eight checks
51+
52+
Detection heuristics for each category are in [checklists.md](checklists.md). Read it now — it is the substance of this skill.
53+
54+
| Category | ID prefix | What it answers |
55+
| ------------------ | --------- | ---------------------------------------------------------------------------- |
56+
| Unit tests | `UT` | Which modules/branches/states have no Jest+RTL coverage? |
57+
| E2E tests | `E2E` | Which user-visible flows have no Playwright spec, or a fragile one? |
58+
| Performance | `PERF` | What causes avoidable renders, work-in-render, or leaks? |
59+
| Dependencies | `DEP` | Which of this widget's own deps are outdated or have known advisories? |
60+
| Security | `SEC` | Where can untrusted data reach HTML, URLs, scripts or other dangerous sinks? |
61+
| Code smells | `SMELL` | Violations of repo conventions, dead code, type escapes |
62+
| Missing behaviours | `BEH` | XML/API/a11y contract the implementation does not honour |
63+
| Public docs | `DOCS` | Where the mx-docs page disagrees with the XML, changelog, or code |
64+
65+
If your agent supports read-only subagents (for example Claude Code's `Explore`), run one per category with the package path and that category's section of `checklists.md`, then merge the results. Run `DEP` yourself — it needs commands, not a search.
66+
67+
## 3. Verify before writing
68+
69+
Every finding must survive this filter, or it does not go in the report:
70+
71+
- **Evidence**: a `file:line` you actually read, or command output you actually ran.
72+
- **Failure scenario**: concrete inputs/config → wrong, slow or unsafe result. "Could be cleaner" is not a finding.
73+
- **Not already handled**: check the code path once more for the guard you are claiming is absent.
74+
- **Not a shared-package concern** misattributed to the widget.
75+
- **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 once made a stale-callback finding a false positive.
76+
- **Critical needs proof**: report a finding as Critical only with proof you produced — a failing existing test, command output, or for a leaked secret the line itself. Otherwise report it as High and add _needs repro_.
77+
78+
Drop speculative findings silently. A short true report beats a long plausible one.
79+
80+
## 4. Write the report
81+
82+
Write `packages/pluggableWidgets/<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.
83+
84+
**Stop there.**

0 commit comments

Comments
 (0)