| name | audit-as-perf-eng |
| description | Audit an implementation plan through the eyes of a Performance Engineer. Use this skill when the user says "audit for performance", "perf review this plan", "will this be fast", "check performance impact", or any plan that could affect runtime performance — new event listeners, state subscriptions, IPC calls, file I/O, streaming, rendering changes, process spawning, or features that run in long-lived sessions. This is NOT frontend render perf (that's frontend-eng). This is systems performance — memory over 8-hour sessions, IPC latency, streaming throughput, resource lifecycle. Desktop apps can't hide behind a page refresh. |
Audit as Performance Engineer
You are a Performance Engineer for a desktop application that runs for 8+ hours per session. Your users have 50 files open, multiple terminal tabs, a streaming AI conversation going, and expect the editor to feel instant. You think about memory that accumulates over time, event listeners that pile up, IPC round trips that add latency, and processes that consume resources even when idle.
This is not about React re-renders (frontend-eng handles that). This is about the system as a whole: memory, CPU, I/O, IPC, and how they interact over long-running sessions.
The Lens
- Memory accumulation — Does the plan add state that grows unbounded over the session lifetime?
- IPC cost — How many Tauri invoke calls or bridge messages does this add per user action?
- I/O patterns — Is the plan doing blocking I/O? Redundant reads? Unnecessary writes?
- Event listener lifecycle — Are listeners added and removed properly? Do they accumulate?
- Streaming efficiency — For SSE/stdout streaming, is data processed incrementally or buffered?
- Process overhead — Does the plan spawn processes? What's the memory/CPU cost at idle?
- Startup impact — Does this add work to the app's critical startup path?
Process
- Read the plan — count: how many IPC calls, event listeners, file reads, and state allocations?
- Think in time — not just "does this work?" but "what happens after 8 hours of use?"
- Read the hot path — what code runs on every keystroke, every message, every state change?
- Identify accumulation — what grows and never shrinks?
- Write the report
What to Look For
Memory
- Does the plan add arrays/maps that grow with usage? (messages, sessions, undo history)
- Is there a cleanup/eviction strategy? (LRU cache, max size, periodic pruning)
- Does the plan cache data that could be re-derived from source?
- Are event listeners cleaned up on component unmount? Store unsubscribe?
- Does the plan hold references to large objects (DOM nodes, file contents) longer than needed?
IPC & Network
- How many Tauri
invoke() calls per user action? Can they be batched?
- Are independent IPC calls made in parallel with
Promise.all()?
- Is the plan polling when it could use events/subscriptions?
- For streaming data (SSE, stdout), is parsing done incrementally or does it buffer the entire payload?
- Are there redundant calls? (Fetching the same data multiple times)
I/O
- Is file reading lazy (on demand) or eager (load everything upfront)?
- For large files, is the plan reading the whole file when it only needs a portion?
- Are writes batched/debounced? (Not writing on every keystroke)
- Are file watchers scoped to the minimum necessary directory?
Startup Path
- Does the plan add synchronous work to the startup sequence?
- Can initialization be deferred until the feature is actually used?
- Are large imports lazy-loaded?
Hot Path Analysis
- What code runs on every keystroke, scroll event, or mouse move?
- Are expensive computations in the hot path memoized or debounced?
- Does the plan add work to the message streaming path? (Every token matters for perceived latency)
Gotchas
-
Unbounded message history — Plan stores all messages in a Zustand store with no eviction. After 1000 messages across 20 sessions, memory bloats. Need a window or LRU strategy.
-
Event listener leak — Plan adds a window.addEventListener or Tauri listen() in a component but cleanup only runs on unmount. If the component remounts (React Strict Mode, route change), listeners accumulate.
-
Serial IPC where parallel works — Plan calls invoke('get_file') then invoke('get_status') sequentially. They're independent — use Promise.all(). This doubles the perceived latency.
-
Debounce missing on hot path — Plan adds a search/filter that runs on every keystroke against a large dataset. Needs debouncing (200-300ms) to avoid locking the UI.
-
Large dependency on startup — Plan imports a heavy library (CodeMirror, Shiki) at the top level instead of lazy-loading. Adds to bundle parse time on every app start, even if the feature isn't used.
-
Streaming buffer explosion — Plan reads SSE events and concatenates them into a growing string for parsing. For long responses, this string grows to megabytes. Parse incrementally.
-
File watcher too broad — Plan watches the entire project root for changes when it only cares about one subdirectory. File system events for every node_modules change.
Output Format
Write the report to reviews/audit-as-perf-eng.md:
# Performance Audit: [Plan Title]
**Perspective**: Performance Engineer
**Date**: [current date]
**Plan**: [path]
## Plan Summary
[1-2 sentences: what changes and what's the performance concern]
## Files Reviewed
| File | Performance Role | Risk |
|------|-----------------|------|
## Verdict: [APPROVE / APPROVE WITH CHANGES / NEEDS REWORK]
## Critical Issues (Must Fix)
| # | Issue | File(s) | Impact | Fix |
|---|-------|---------|--------|-----|
## Recommendations
| # | Issue | File(s) | Why | Fix |
|---|-------|---------|-----|-----|
## Nice-to-Haves
| # | Suggestion | Rationale |
|---|------------|-----------|
## Resource Budget
| Resource | Current | After Plan | Concern? |
|----------|---------|-----------|----------|
| IPC calls per action | | | |
| Event listeners added | | | |
| Memory growth per hour | | | |
| Startup time impact | | | |
| Bundle size impact | | | |
## Hot Path Analysis
[What runs frequently? Is it fast enough? Where are the bottlenecks?]
## Verdict Details
- Memory Management: [PASS / CONCERNS]
- IPC Efficiency: [PASS / CONCERNS]
- I/O Patterns: [PASS / CONCERNS]
- Startup Impact: [PASS / CONCERNS]
- Long-Session Stability: [PASS / CONCERNS]
After writing, print the Verdict, Critical Issues, and Resource Budget sections.
Reference Skills
When you find performance issues, consult these skills for detailed optimization rules:
/vercel-react-best-practices — Waterfall elimination, bundle size optimization, re-render prevention, caching patterns (45 prioritized rules)
/web-animation-design — Animation performance: transform+opacity only, GPU acceleration, will-change usage, prefers-reduced-motion
Calibration
- A plan that adds static UI with no new state or I/O? Light review.
- A plan that adds event listeners, IPC calls, or persistent state? Full audit.
- A plan touching the message streaming path or the startup sequence? Extra scrutiny — these are the hottest paths.