# Perf Doctor

> This skill audits a codebase for common performance anti-patterns (N+1 queries, SELECT *, nested loops, missing LIMIT, sync/blocking calls inside loops) and proposes prioritized fixes. Use it when the user says "性能审计", "perf-doctor", "检查性能", "为什么慢", "performance audit", or "帮我看性能".

- Skill: `whaojie797-design/perf-doctor` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add whaojie797-design/perf-doctor`
- Raw SKILL.md: https://api.skillmd.com/api/skills/whaojie797-design/perf-doctor/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: whaojie797-design (https://skillmd.com/u/whaojie797-design)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/whaojie797-design/perf-doctor

---


# Perf Doctor

## Overview
Give the agent a deterministic, repo-wide performance audit. Instead of only guessing, run `scripts/scan_perf.py` to surface concrete hot spots with file:line, severity, and a fix suggestion, then prioritize by severity (High -> Medium -> Low).

## When to Use
- The user says "性能审计", "perf-doctor", "检查性能", "为什么慢", "performance audit", "帮我看性能".
- After a feature lands and before declaring it done, as a perf gate.

## Procedures
1. **Scan**: run `python scripts/scan_perf.py <project_dir>` (or a single file). The scanner is stdlib-only and needs no install.
2. **Triage**: read the report; start with `High` findings (N+1, sync-in-loop), then `Medium`, then `Low`.
3. **Fix + verify**: apply the suggested fix, then re-run the scanner to confirm the finding is gone. Remind the user: measure before/after (a benchmark or timing), don't optimize blind.
4. **Report**: summarize counts by severity and the top 3 fixes.

## Bundled Resources
- `scripts/scan_perf.py` — heuristic scanner for Python/JS/TS/Java/Go and more. Outputs a table or `--json`; exits non-zero when findings exist (CI-friendly).
- `references/perf-rules.md` — the full rule catalog with fix patterns.

## Guardrails
- Heuristics, not a profiler: findings are candidates, notproof. Confirm with a real benchmark before claiming a win.
- Avoid shotgun "optimizations": fix the High items first; low-severity items may not be worth the churn.
- Do not rewrite working code just to satisfy the scanner; only change when there is a real measured gain.

