| name | ui-audit |
| description | Comprehensive UI component audit for Momentum CMS. Use when asked to audit, review, check, or validate a UI component. Checks Storybook stories, interaction tests, variants, kitchen sink integration, admin dashboard usage, accessibility, and responsive design (mobile-first). AUTOMATICALLY FIXES issues found and verifies with visual inspection. Triggers include "audit button", "review the card component", "check accessibility of tabs", or "/ui-audit <component-name>". |
| argument-hint | <component-name> |
| allowed-tools | Bash(agent-browser:*), Bash(nx *), Read, Glob, Grep, Edit, Write |
UI Component Audit
Comprehensive audit combining static code analysis with visual browser inspection via Storybook and kitchen sink. This skill automatically FIXES issues and VERIFIES fixes visually.
⚠️ CRITICAL: DO NOT SKIP VISUAL INSPECTION ⚠️
Static code analysis is NOT sufficient. You MUST perform visual inspection using browser automation (Claude-in-Chrome MCP or agent-browser).
MANDATORY Visual Inspection Steps
-
Storybook Screenshots - Navigate to the component's stories and take screenshots of EVERY story variant in BOTH light and dark mode. If you don't have screenshots, you haven't completed the audit.
-
Admin Portal Verification - Navigate to the admin dashboard and verify how the component is actually used. Take screenshots showing real usage. Many bugs are only visible in real usage context.
-
Responsive Testing - Resize browser to mobile (375px), tablet (768px), and desktop (1280px) and screenshot each.
Why This Matters
Code review alone misses these issues:
- Badge text invisible against card backgrounds (duplicate CSS variables)
- Borders invisible due to matching colors
- Icons not rendering in Storybook (missing icon provider)
- Hover effects not working
- Focus states not visible
- Spacing issues only visible when rendered
Verification Checklist (before completing audit)
If any checkbox is unchecked, the audit is INCOMPLETE.
Requirements Summary
- Browser automation for visual inspection - MUST take screenshots
- Auto-fix - MUST fix issues found, not just report them
- Visual verification - MUST verify fixes with browser screenshots
Quick Start
/ui-audit button
/ui-audit data-table
/ui-audit sidebar
Audit Workflow
Phase 1: Component Discovery
Find all component files:
libs/ui/src/lib/<component>/
├── <component>.component.ts
├── <component>.types.ts
├── <component>.stories.ts
├── <component>.spec.ts
└── index.ts
Verify export in libs/ui/src/index.ts.
Phase 2: Static Code Analysis
Check component follows Angular 21 + Momentum patterns:
Required Patterns:
Phase 3: Variant Coverage
Extract variants from types and verify story coverage:
type ButtonVariant = 'primary' | 'secondary' | 'destructive' | 'outline' | 'ghost' | 'link';
type ButtonSize = 'sm' | 'md' | 'lg' | 'icon';
Required Stories:
Phase 4: Storybook Visual Inspection ⚠️ MANDATORY
DO NOT SKIP THIS PHASE. Static code analysis cannot catch visual bugs.
Start Storybook and capture screenshots of EVERY story:
nx storybook ui --port 4400
agent-browser open "http://localhost:4400/?path=/story/components-button--primary"
agent-browser wait --load networkidle
agent-browser screenshot ./audit/button-primary-light.png
agent-browser snapshot -i
agent-browser click @e<theme-toggle-ref>
agent-browser wait 500
agent-browser screenshot ./audit/button-primary-dark.png
What to look for in screenshots:
If ANY of these are wrong, you have found a visual bug that code review missed!
Phase 5: Interaction Tests
Verify interaction tests pass:
nx test ui --testNamePattern="<Component>"
agent-browser open "http://localhost:4400/?path=/story/components-button--click-interaction"
agent-browser wait --load networkidle
agent-browser screenshot ./audit/button-interaction.png
Phase 6: Kitchen Sink Integration ⚠️ MANDATORY
DO NOT SKIP THIS PHASE. Components must be verified in the kitchen sink context.
Verify component appears in kitchen sink:
grep -l "<Component>" libs/ui/src/lib/kitchen-sink/kitchen-sink.page.ts
nx serve example-angular
agent-browser open "http://localhost:4200/kitchen-sink"
agent-browser wait --load networkidle
agent-browser find text "Buttons" scrollintoview
agent-browser screenshot ./audit/kitchen-sink-buttons.png
Phase 6.5: Admin Portal Usage Verification ⚠️ MANDATORY
DO NOT SKIP THIS PHASE. Components must be verified in their actual usage context in the admin portal.
Navigate to the admin portal and verify how the component is used in real context:
mcp__claude-in-chrome__tabs_context_mcp({ createIfEmpty: true })
mcp__claude-in-chrome__navigate({ url: "http://localhost:4200/admin", tabId })
mcp__claude-in-chrome__computer({ action: "wait", duration: 2, tabId })
mcp__claude-in-chrome__computer({ action: "screenshot", tabId })
What to verify in Admin Portal:
Common issues found in Admin Portal:
- Sidebar icons not rendering (icon provider missing)
- Badge counts invisible (CSS variable conflict)
- Hover effects not firing (event binding issues)
- Focus states not visible (accessibility regression)
- Layout breaking with real data lengths
Phase 7: Responsive Testing
Test at mobile-first breakpoints:
agent-browser set viewport 375 812
agent-browser screenshot ./audit/responsive-mobile.png
agent-browser set viewport 768 1024
agent-browser screenshot ./audit/responsive-tablet.png
agent-browser set viewport 1280 800
agent-browser screenshot ./audit/responsive-desktop.png
agent-browser set viewport 1920 1080
agent-browser screenshot ./audit/responsive-desktop-lg.png
Phase 8: Visual Design Quality ⚠️ CRITICAL - DO NOT SKIP
THIS PHASE IS THE MOST IMPORTANT. Code review and static analysis cannot catch visual bugs.
Use browser automation to ACTUALLY LOOK at the UI. Many bugs are only visible when rendered.
Theme CSS Variable Analysis
Check for duplicate color values in dark mode (common bug):
grep -A 30 ".dark {" libs/admin/src/styles/theme.css | grep "mcms-"
Red Flags - Multiple variables with identical HSL values:
--mcms-card: 217 33% 17%;
--mcms-secondary: 217 33% 17%;
--mcms-border: 217 33% 17%;
Required Color Differentiation:
| Variable | Purpose | Relative Lightness |
|---|
--mcms-card | Base | 15% |
--mcms-secondary | Badges | 25% (+10) |
--mcms-muted | Subtle BG | 20% (+5) |
--mcms-accent | Hover | 22% (+7) |
--mcms-border | Borders | 22% (+7) |
Visual Verification with Browser
mcp__claude-in-chrome__navigate({ url: "http://localhost:4200/admin", tabId })
mcp__claude-in-chrome__computer({ action: "wait", duration: 2, tabId })
mcp__claude-in-chrome__computer({ action: "screenshot", tabId })
mcp__claude-in-chrome__computer({ action: "hover", coordinate: [400, 240], tabId })
mcp__claude-in-chrome__computer({ action: "screenshot", tabId })
What to Look For:
Card/Component Quality Checks
Dashboard/Page Layout Quality
Phase 9: UX Design Quality Review ⚠️ CRITICAL - DO NOT SKIP
Ask yourself: "Would I ship this?" If the answer is no, the audit FAILS.
This phase catches design quality issues that technical audits miss. Compare against industry standards and ask critical UX questions.
Navigation Design Checklist
Visual Hierarchy Checklist
Industry Comparison
Compare against established admin panels. Ask:
If our UI is notably worse than these, the audit FAILS.
The "Ship It" Test
Look at the screenshot and honestly answer:
If ANY answer is negative, document the issues and FIX THEM before completing the audit.
Common Design Quality Failures
| Issue | What It Looks Like | Fix |
|---|
| No icons | Plain text nav items | Add Lucide/Heroicons to each item |
| Weak active state | Subtle background only | Add left border accent + stronger bg |
| Empty space | Big gap between nav and footer | Add more nav items or collapse spacing |
| No brand | App name same size as nav | Make logo/name larger, add icon |
| Invisible borders | Sidebar bleeds into content | Increase border-sidebar-border contrast |
Phase 10: CDK & ARIA Primitives Audit
Verify component uses Angular CDK and @angular/aria primitives correctly.
Responsive Detection (CDK Layout):
Bad:
ngOnInit(): void {
this.isMobile = window.innerWidth < 768;
}
Good:
readonly isMobile = toSignal(
this.breakpointObserver.observe(['(max-width: 767px)'])
.pipe(map(result => result.matches)),
{ initialValue: false }
);
Focus Management (CDK A11y):
Positioned Content (CDK Overlay):
ARIA Directives (@angular/aria):
Flex Child Wrappers:
See references/angular-primitives.md for complete patterns.
Phase 10.5: Debugging Common Layout Issues
⚠️ Dev Server Caching: Angular dev server may cache stale library code. If fixes aren't appearing:
lsof -i :4200 | awk 'NR>1 {print $2}' | xargs kill -9
nx serve example-angular
Sidebar Footer Not at Bottom:
| Symptom | Likely Cause | Fix |
|---|
| Footer in middle, nav stretches | ng-content not wrapped | Add wrapper divs with shrink-0/flex-1 |
| Footer at bottom only when content tall | Using min-h-screen | Change to h-screen on aside |
| Entire sidebar has wrong height | Parent wrapper uses contents | Change to shrink-0 |
| Footer moves when content grows | Content not using overflow-y-auto | Add overflow-y-auto to content div |
Key Pattern for Sidebar Flex Layout:
<aside class="flex flex-col h-screen sticky top-0">
<div class="shrink-0">Header</div>
<div class="flex-1 overflow-y-auto">Content</div>
<div class="shrink-0">Footer</div>
</aside>
Why wrapper divs are required for ng-content:
ng-content alone creates NO DOM element
- Flex classes (
shrink-0, flex-1) need an element to apply to
- Wrap each
ng-content select="..." in a div with appropriate flex classes
Phase 11: Accessibility Audit
Check accessibility requirements:
ARIA Attributes:
Focus Management:
Color Contrast:
Phase 12: Auto-Fix Issues
CRITICAL: This skill MUST automatically fix issues, not just report them.
For each issue found, apply the appropriate fix:
Visual Design Fixes
Fixing invisible badges (duplicate CSS variables):
--mcms-secondary: 217 33% 17%;
--mcms-secondary: 215 28% 25%;
Adding card hover effects:
styles: `
:host {
box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
`,
styles: `
:host {
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
:host(:hover) {
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
`,
Improving dashboard layout:
<header class="mb-8">
<h1 class="text-3xl font-bold">Dashboard</h1>
</header>
<header class="mb-10">
<h1 class="text-4xl font-bold tracking-tight">Dashboard</h1>
<p class="text-muted-foreground mt-3 text-lg">Manage your content</p>
</header>
<section>
<h2 class="text-sm font-semibold uppercase tracking-wider text-muted-foreground mb-4">
Collections
</h2>
...
</section>
Accessibility Fixes
Missing aria-label on icon buttons:
<button mcms-button variant="ghost" size="icon">
<svg>...</svg>
</button>
<button mcms-button variant="ghost" size="icon" aria-label="Actions menu">
<svg aria-hidden="true">...</svg>
</button>
Missing aria-hidden on decorative icons:
<svg xmlns="..." class="text-muted-foreground">
<svg aria-hidden="true" xmlns="..." class="text-muted-foreground">
Missing aria-label on search inputs:
<mcms-input type="text" [placeholder]="searchPlaceholder()" />
<mcms-input type="text" [placeholder]="searchPlaceholder()" aria-label="Search" />
Story Fixes
Missing interaction test with play function:
export const ClickInteraction: Story = {
render: () => ({
template: `<mcms-component data-testid="test-element" />`,
}),
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const element = canvas.getByTestId('test-element');
await expect(element).toBeVisible();
},
};
Kitchen Sink Fixes
Component not in kitchen sink:
- Add import to
kitchen-sink.page.ts
- Add component to imports array
- Add showcase section in template
Phase 13: Visual Verification with agent-browser
REQUIRED: After fixing, verify visually with agent-browser.
nx storybook ui --port 4400 &
sleep 10
agent-browser open "http://localhost:4400/?path=/story/components-<component>--default"
agent-browser wait --load networkidle
agent-browser screenshot ./audit/<component>-fixed-light.png
agent-browser snapshot -i
agent-browser click @e<theme-toggle>
agent-browser wait 500
agent-browser screenshot ./audit/<component>-fixed-dark.png
agent-browser set viewport 375 812
agent-browser screenshot ./audit/<component>-fixed-mobile.png
agent-browser open "http://localhost:4400/?path=/story/components-<component>--click-interaction"
agent-browser wait --load networkidle
agent-browser screenshot ./audit/<component>-interaction.png
Phase 14: Run Unit Tests
nx test ui --testNamePattern="<Component>"
Phase 15: Generate Report
Create markdown audit report with BEFORE/AFTER status:
# UI Audit Report: <Component>
**Date**: YYYY-MM-DD
**Component**: libs/ui/src/lib/<component>/
## Summary
| Category | Before | After | Fixed |
| ----------------- | ------ | ----- | ----- |
| Code Patterns | PASS | PASS | - |
| Variant Coverage | PASS | PASS | - |
| Interaction Tests | FAIL | PASS | ✅ |
| Accessibility | WARN | PASS | ✅ |
| Visual (Light) | PASS | PASS | - |
| Visual (Dark) | PASS | PASS | - |
| Responsive | PASS | PASS | - |
| Kitchen Sink | PASS | PASS | - |
**Overall**: PASS (2 issues fixed)
## Fixes Applied
1. Added `aria-hidden="true"` to decorative SVG icons
2. Added interaction test with `play` function
## Screenshots (Visual Verification)
- Light mode: ./audit/<component>-fixed-light.png
- Dark mode: ./audit/<component>-fixed-dark.png
- Mobile: ./audit/<component>-fixed-mobile.png
## Tests Passed
✅ All unit tests pass after fixes
Deep-Dive Documentation
| Reference | When to Use |
|---|
| references/component-patterns.md | Angular 21 signal patterns, host styling |
| references/variant-coverage.md | Story requirements, interaction tests |
| references/accessibility-checklist.md | ARIA, focus, keyboard navigation |
| references/visual-inspection.md | Storybook URLs, viewport sizes |
| references/visual-design-quality.md | Theme CSS analysis, color contrast, card hover effects, dashboard layout |
| references/angular-primitives.md | CDK BreakpointObserver, FocusTrap, Overlay, @angular/aria hostDirectives |
Ready-to-Use Templates
Prerequisites
Before running audit:
- Storybook running:
nx storybook ui --port 4400
- Dev server running:
nx serve example-angular
- Browser automation: Either agent-browser CLI OR Claude-in-Chrome MCP tools
Browser Automation Options
Option 1: agent-browser CLI
agent-browser open "http://localhost:4400/?path=/story/components-button--primary"
agent-browser wait --load networkidle
agent-browser screenshot ./audit/button.png
Option 2: Claude-in-Chrome MCP (Preferred)
Use the MCP browser tools when available:
mcp__claude-in-chrome__tabs_context_mcp({ createIfEmpty: true })
mcp__claude-in-chrome__navigate({ url: "http://localhost:4400/?path=/story/components-button--primary", tabId })
mcp__claude-in-chrome__computer({ action: "screenshot", tabId })
mcp__claude-in-chrome__resize_window({ width: 375, height: 812, tabId })
mcp__claude-in-chrome__read_page({ tabId, filter: "interactive" })
Example Audit Output (with Auto-Fix)
Auditing: data-table
Phase 1: Discovery
Found: data-table.component.ts
Found: data-table.stories.ts (10 stories)
Found: data-table.spec.ts
Exported: YES
Phase 2: Static Analysis
[PASS] Uses input() signals
[PASS] Uses computed() for hostClasses
[PASS] ChangeDetectionStrategy.OnPush
[PASS] Host styling (no wrapper div)
[PASS] Accepts class input
Phase 3: Variant Coverage
Stories: 10/10 covered
[PASS] All features have stories
Phase 4: Storybook Visual (via browser)
📸 Taking screenshot: data-table-default-light.png
📸 Taking screenshot: data-table-default-dark.png
[PASS] Renders correctly in both themes
Phase 5: Interaction Tests
[WARN] No story with play function found
Phase 6: Kitchen Sink
[PASS] Component imported
[PASS] Renders in showcase
Phase 7: Responsive (via browser)
📸 Screenshot at 375px: data-table-mobile.png
📸 Screenshot at 768px: data-table-tablet.png
📸 Screenshot at 1280px: data-table-desktop.png
[PASS] Responsive layout works
Phase 8: Visual Design Quality (CRITICAL)
Analyzing theme CSS variables...
[FAIL] --mcms-secondary same as --mcms-card (badges invisible!)
[FAIL] --mcms-border same as --mcms-card (borders invisible!)
[WARN] Card missing hover effect
📸 Admin dashboard screenshot captured
[WARN] Dashboard missing section headers
Phase 9: UX Design Quality Review (CRITICAL)
Comparing against industry standards...
[FAIL] Nav items missing icons (Payload/Strapi have icons)
[FAIL] Active state weak (no left border accent)
[WARN] Large empty space between nav and user section
[WARN] Brand/logo not prominent enough
📸 Side-by-side comparison with Payload captured
"Would I ship this?" → NO
Phase 10: Accessibility
[WARN] Search input missing aria-label
[WARN] Sort headers missing aria-label
[WARN] Row actions button missing aria-label
Phase 11: Auto-Fix
🔧 Fixing theme.css: --mcms-secondary 217 33% 17% → 215 28% 25%
🔧 Fixing theme.css: --mcms-border 217 33% 17% → 217 33% 22%
🔧 Adding card hover effects with transitions
🔧 Adding icons to all nav items
🔧 Adding left border accent to active nav state
🔧 Adding aria-label to search input...
🔧 Adding interaction test story with play function...
Phase 12: Visual Verification (via browser)
📸 Verifying fix: badges now visible in dark mode ✅
📸 Verifying fix: card hover effect working ✅
📸 Verifying fix: nav icons now visible ✅
📸 Verifying fix: active state has left border ✅
📸 Verifying fix: data-table-fixed-dark.png
[PASS] All fixes verified visually
Phase 13: Unit Tests
Running: nx test ui --testNamePattern="DataTable"
[PASS] All 428 tests pass
Phase 14: Report Generated
Report: ./audit/data-table-report.md
Summary:
Before: 9 issues (2 CSS, 2 UX design, 3 accessibility, 1 interaction, 1 layout)
After: 0 issues
Status: ✅ ALL FIXED
⛔ MANDATORY: Phase Completion Enforcement
You CANNOT complete the audit until ALL phases are executed.
Before finishing, you MUST confirm each phase was completed:
| Phase | Name | Required Evidence |
|---|
| 1 | Component Discovery | Listed all component files |
| 2 | Static Code Analysis | Checked all code patterns |
| 3 | Variant Coverage | Verified all variants have stories |
| 4 | Storybook Visual | 📸 Took screenshots of stories |
| 5 | Interaction Tests | Ran tests or noted missing play functions |
| 6 | Kitchen Sink | 📸 Verified component in kitchen sink |
| 6.5 | Admin Portal | 📸 Verified component in admin dashboard |
| 7 | Responsive | 📸 Tested at 375px, 768px, 1280px |
| 8 | Visual Design Quality | Checked CSS variables, hover effects |
| 9 | UX Design Quality | Asked "Would I ship this?" - compared to industry |
| 10 | CDK & ARIA Primitives | Checked BreakpointObserver, FocusTrap, Overlay, flex sizing |
| 10.5 | Debugging | Verified dev server cache cleared, layout issues fixed |
| 11 | Accessibility | Checked ARIA, focus, keyboard |
| 12 | Auto-Fix | Fixed all issues found |
| 13 | Visual Verification | 📸 Verified fixes with screenshots |
| 14 | Unit Tests | All tests pass |
| 15 | Report | Generated summary |
Phases marked with 📸 REQUIRE screenshots. If you don't have them, GO BACK.
Completion Checklist
Copy and complete this checklist in your final report:
## Phase Completion Verification
- [ ] Phase 1: Discovery - files found
- [ ] Phase 2: Static Analysis - patterns checked
- [ ] Phase 3: Variant Coverage - stories verified
- [ ] Phase 4: Storybook - SCREENSHOTS TAKEN (light + dark)
- [ ] Phase 5: Interaction - tests run
- [ ] Phase 6: Kitchen Sink - SCREENSHOT TAKEN
- [ ] Phase 6.5: Admin Portal - SCREENSHOT TAKEN
- [ ] Phase 7: Responsive - SCREENSHOTS at 3 breakpoints
- [ ] Phase 8: Visual Design - CSS variables analyzed
- [ ] Phase 9: UX Design - "Would I ship this?" answered
- [ ] Phase 10: CDK & ARIA - BreakpointObserver, FocusTrap, flex sizing checked
- [ ] Phase 10.5: Debugging - dev server cache cleared, layout issues verified
- [ ] Phase 11: Accessibility - ARIA/focus checked
- [ ] Phase 12: Auto-Fix - all issues fixed
- [ ] Phase 13: Visual Verification - SCREENSHOTS of fixes
- [ ] Phase 14: Unit Tests - all pass
- [ ] Phase 15: Report - generated
**If any box is unchecked, the audit is INCOMPLETE. Go back and finish.**
Why This Enforcement Exists
In a previous audit, I:
- ✓ Did static code analysis
- ✓ Took screenshots
- ✗ Did NOT critically analyze the screenshots
- ✗ Did NOT ask "would I ship this?"
- ✗ Missed obvious issues: no icons, weak active state, empty space
Result: A technically-passing audit that missed glaring UX problems.
This enforcement ensures every audit includes genuine design quality review, not just technical compliance.