跳到主要内容
知仓学习社ZHICANG

phx-perf

Analyze Elixir/Phoenix performance — N+1 queries, assign bloat, ecto

不碰外部(只输出文字)无严重或高危命中oliver-kriska/claude-elixir-phoenix

它会碰到什么

扫了多少2 个文本文件,9 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

Performance Analysis

Analyze code for performance issues across Ecto, LiveView,

and OTP layers. Prioritize findings by impact and effort.

Usage

/phx-perf                           # Analyze full project
/phx-perf lib/my_app/accounts.ex    # Analyze specific module
/phx-perf --focus ecto              # Ecto queries only
/phx-perf --focus liveview          # LiveView memory only
/phx-perf --focus otp               # OTP bottlenecks only

Arguments

$ARGUMENTS = Optional module/context path and --focus flag.

Iron Laws

  1. MEASURE BEFORE OPTIMIZING — Never optimize without evidence of a problem
  2. DATABASE FIRST — 90% of Elixir performance issues are query-related
  3. ONE CHANGE AT A TIME — Isolate optimizations to measure impact
  4. NEVER benchmark in dev mode — Always use MIX_ENV=prod for performance measurements; dev mode includes code reloading, debug logging, and unoptimized compilation that invalidate results

Workflow

Step 1: Identify Scope

Check specific file if provided. Otherwise scan full project:

# Find hot paths: contexts, LiveViews, workers
find lib/ -name "*.ex" | head -50

Step 2: Run Analysis Tracks

Spawn analysis agents in parallel based on focus:

Ecto Track (default or --focus ecto):

Spawn phx:elixir-reviewer with prompt:

"Analyze for N+1 queries, missing preloads, unindexed queries,

and inefficient patterns. Check: Repo.all in loops,

Enum.map with Repo calls, missing preload, queries without

indexes on WHERE/JOIN columns."

LiveView Track (default or --focus liveview):

Spawn phx:elixir-reviewer with prompt:

"Analyze LiveViews for memory issues: large assigns, missing

streams for lists, assigns that grow unbounded, heavy

handle_info processing, missing assign_async for slow ops."

OTP Track (only with --focus otp):

Spawn phx:otp-advisor with prompt:

"Analyze for OTP bottlenecks: GenServer mailbox growth,

synchronous calls in hot paths, missing Task.async for

parallel work, ETS opportunities for read-heavy state."

Step 3: Prioritize Findings

Score each finding on a 2x2 matrix:

| | Low Effort | High Effort |

|---|---|---|

| High Impact | DO FIRST | PLAN |

| Low Impact | QUICK WIN | SKIP |

High impact = affects response time, memory per user, or query count.

Low effort = single file change, no migration needed.

Step 4: Present Top 5

Present findings sorted by priority:

## Performance Analysis: {scope}

### 1. {Finding} — DO FIRST
**Impact**: {what improves}
**Location**: {file}:{line}
**Current**: {problematic pattern}
**Fix**: {optimized pattern}
**Estimated gain**: {e.g., "eliminates N+1, reduces queries from O(n) to O(1)"}

### 2. {Finding} — PLAN
...

Step 5: Offer Next Steps

Always end with actionable next steps — findings without follow-up

get lost. Present options based on severity:

How would you like to proceed?

- `/phx-plan` — Create a plan from these findings (recommended for 3+ fixes)
- `/phx-quick` — Apply top priority fix directly (1-2 simple fixes)
- `/phx-investigate` — Deep-dive into a specific finding

Tidewave Integration

If Tidewave MCP is available:

  • Use mcp__tidewave__project_eval to run Repo.query!("EXPLAIN ANALYZE ...") on suspicious queries
  • Use mcp__tidewave__project_eval to check Process.info(pid, :message_queue_len) for GenServer bottlenecks
  • Use mcp__tidewave__execute_sql_query to check missing indexes

References

  • references/benchmarking.md — Benchee patterns, profiling, flame graphs

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。

它属于哪个仓库

星标★ 553
本站分层T2
该仓技能数322
原文件路径targets/dsh/skills/phx-perf/SKILL.md

同一个仓库里的其他技能

看这个仓库的全部 322 个技能

同名技能的其他版本

有 5 个不同仓库或目录里都有叫 phx-perf 的技能。它们内容并不相同,别混用: