skills/perf-audit/SKILL.md
Static analysis + Lighthouse CLI performance audit with Pretext recommendations. Use when assessing frontend performance, scanning for reflow-triggering patterns, running Core Web Vitals checks, or evaluating text measurement tech debt. Combines code analysis with live Lighthouse metrics. Triggered automatically by frontend-touching commands or explicitly via /perf-audit.
npx skillsauth add rdfitted/claude-code-setup perf-auditInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Combines static code analysis for reflow-triggering patterns with Google Lighthouse CLI for real-world performance metrics. Identifies where @chenglou/pretext adoption would improve Core Web Vitals.
--static-only: Skip Lighthouse, only run static analysis--lighthouse-only: Skip static analysis, only run Lighthouse against URLScan for patterns that trigger browser layout reflow, categorized by severity:
Grep patterns across *.{js,ts,jsx,tsx}:
- getBoundingClientRect
- offset(Top|Left|Width|Height)
- scroll(Top|Left|Width|Height)
- client(Top|Left|Width|Height)
- getComputedStyle
- innerText (triggers reflow to compute text)
- window\.getSelection
Search for patterns where DOM reads and writes alternate:
- for/while loops containing both reads (offset*, getBounding*) and writes (style.*, className, innerHTML)
- Array.forEach/map with DOM measurement inside
- requestAnimationFrame with measurement + mutation
- measureText without Pretext
- font-loading callbacks that trigger re-measurement
- ResizeObserver on text containers
- Dynamic font-size calculations
- Text truncation via JS (measuring then cutting)
- Virtualized list height estimation via DOM
For each finding, read 10 lines of context to classify:
prepare()/layout() could handle# Check if Lighthouse is available
npx lighthouse --version 2>/dev/null || npm install -g lighthouse
# Run Lighthouse with performance focus
npx lighthouse "{URL}" \
--output=json \
--output-path=./lighthouse-report.json \
--chrome-flags="--headless --no-sandbox" \
--only-categories=performance \
--throttling-method=simulate \
--preset=desktop
# Also run mobile
npx lighthouse "{URL}" \
--output=json \
--output-path=./lighthouse-report-mobile.json \
--chrome-flags="--headless --no-sandbox" \
--only-categories=performance \
--throttling-method=simulate \
--preset=perf
Extract key metrics from JSON:
Also extract:
Cross-reference static findings with Lighthouse results:
| Finding | Static Analysis | Lighthouse Impact | Pretext Fix |
|---------|----------------|-------------------|-------------|
| Text height measurement in virtualized list | getBoundingClientRect in scroll handler (HOT) | High CLS, High TBT | Replace with prepare() + layout() |
| Font-size responsive calculation | getComputedStyle in resize handler (HOT) | Medium CLS | Use prepare() per breakpoint, layout() on resize |
| Text truncation check | scrollHeight comparison (COLD) | Low impact | Optional — low priority |
Invoke the pretext-check skill to get current dependency status:
Skill(skill="pretext-check")
Merge those findings into the overall report.
## Performance Audit Report
### Lighthouse Scores (if URL provided)
| Metric | Desktop | Mobile | Target |
|--------|---------|--------|--------|
| Performance | XX | XX | >90 |
| LCP | X.Xs | X.Xs | <2.5s |
| CLS | X.XX | X.XX | <0.1 |
| TBT | XXms | XXms | <200ms |
| FCP | X.Xs | X.Xs | <1.8s |
| TTI | X.Xs | X.Xs | <3.8s |
### Static Analysis Summary
- **X** critical reflow triggers found
- **Y** layout thrashing patterns found
- **Z** text-specific patterns (Pretext-replaceable)
- **W** hot-path patterns (highest impact)
### Pretext Integration Opportunities
#### High Impact (Hot Path + Pretext-Replaceable)
1. `file:line` — Description — Est. CLS improvement: X.XX
2. ...
#### Medium Impact (Cold Path or Partial Replacement)
1. `file:line` — Description
2. ...
#### Low Impact (Optional / Future)
1. `file:line` — Description
2. ...
### Pretext Dependency Status
{output from pretext-check skill}
### Action Items
- [ ] Install @chenglou/pretext (if not installed)
- [ ] Replace N hot-path text measurements with Pretext
- [ ] Re-run /perf-audit after changes to measure improvement
- [ ] Target CLS < 0.1, TBT < 200ms
### Estimated Impact
- CLS improvement: ~X.XX (from removing N reflow-triggering text measurements)
- TBT improvement: ~XXms (from eliminating synchronous layout in hot paths)
Save the full report to the project:
Write report to: .ai-docs/perf-audit-{date}.md
If .ai-docs/ doesn't exist, save to project root as perf-audit-{date}.md.
Clean up Lighthouse JSON files after extracting data.
This skill is invoked by:
/build — after implementation, as part of Phase 3 validation (if frontend changes detected)/scope — during Phase 2 scouting, to baseline current performance before planning changes/kickoff — during Phase 2, if an existing frontend project is being extendedWhen called from another command, return a condensed summary for inclusion.
development
Restore from the Kopia backup repo in one of two opinionated modes. **wikis** (frequent, default) syncs per-project `.ai-docs/` directories from backup to local project trees — used to move compound-knowledge wikis between machines via the backup drive as sneakernet. **full** (rare) restores all sources to original paths for greenfield machine rebuild. Use when the user says "restore wikis", "sync wikis from backup", "pull the wikis", "I plugged in the backup drive on this machine", "rebuild this machine", "greenfield restore", or "restore everything". For ad-hoc single-file restores, use `backup-ops restore` instead.
documentation
# /bp-iterate Iterate the Fitted Business Plan(s). Manages the **internal canonical** and the **external partner/investor variant**, snapshot-on-version-bump lineage, redaction enforcement between variants, and cross-document coupling. ## When this runs - User says `/bp-iterate`, "iterate the BP," "bump the BP," "update the business plan," "version up the BP," "create / update / refresh the external variant" - A material trigger fires per the BP's own Iteration Log (first 2 new closes / fundi
tools
Run Kopia-based backups of key Windows files and config to an external drive. Use when the user says "back up", "run a backup", "snapshot", "the backup drive is plugged in", or wants to set up / configure backups for the first time. Handles initial repo setup, drive detection by volume label, source enumeration, and snapshot creation with structured exclusions.
testing
Secondary backup operations against the Kopia repo — verify integrity, run maintenance/prune, mirror to a second destination, restore files/folders, or run a quick top-up snapshot of hot directories. Use when the user says "verify backups", "check backup integrity", "prune old snapshots", "restore from backup", "mirror backups to cloud", "quick backup", "top up the backup", or asks about backup health. For the primary backup run, use the `backup` skill instead.