MCPInstall

performance-profiler

Use when profiling a Node/Go/Python project for performance bottlenecks — bundle size, dependency bloat, large files, unused code — and outputting prioritized optimization recommendations.

Installs
542
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/wu529778790/shenzjd-skills --skill performance-profiler
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads performance-profiler automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Performance Profiler

一键分析项目性能瓶颈,输出优先级排序的优化建议。

Overview

扫描项目代码和配置,检测性能问题:bundle 体积、依赖膨胀、大文件、未优化的资源。输出按影响程度排序的可执行优化建议报告。

When to Use

  • User wants to analyze project performance
  • User mentions bundle size, slow loading, or performance optimization
  • User wants to know which dependencies are slowing down the project
  • User inputs /performance-profiler
  • User wants to reduce bundle size for faster page loads
  • User wants to find and remove unused dependencies
  • User wants to check for barrel file impact on tree-shaking
  • User wants performance optimization recommendations

When NOT to Use:

  • User wants runtime profiling (requires dedicated APM tools like New Relic, Datadog)
  • User wants load testing (use k6, Locust, or Apache Bench)
  • User only wants to view code coverage (use coverage tools like Istanbul, coverage.py)
  • User wants to optimize database queries (use EXPLAIN plans, slow query logs)
  • User wants to check Core Web Vitals (use Lighthouse, PageSpeed Insights)

Core Pattern

Step 1: 检测项目类型

检测文件项目类型分析重点
package.jsonNode.js / 前端bundle size、依赖数量、tree-shaking
go.modGo二进制大小、依赖数量
requirements.txt / pyproject.tomlPython依赖数量、重复依赖

Step 2: 分析依赖

# Node.js
if command -v node >/dev/null 2>&1; then
  # 尝试 cost-of-modules,如果失败则使用替代方案
  if npx --yes cost-of-modules 2>/dev/null; then
    echo "使用 cost-of-modules 分析完成"
  else
    echo "⚠️ cost-of-modules 不可用,使用替代方案"
    cat package.json | python3 -c "
import sys,json
d=json.load(sys.stdin)
deps=d.get('dependencies',{})
dev_deps=d.get('devDependencies',{})
print(f'Direct Dependencies: {len(deps)}')
print(f'Dev Dependencies: {len(dev_deps)}')
print(f'Total: {len(deps) + len(dev_deps)}')
# 列出前 10 个依赖
print('Top dependencies:')
for i, (name, ver) in enumerate(list(deps.items())[:10]):
    print(f'  {name}: {ver}')
"
  fi
else
  echo "⚠️ Node.js 未安装,跳过 Node.js 依赖分析"
fi

# Go
if command -v go >/dev/null 2>&1; then
  echo "Go dependencies:"
  go list -m all 2>/dev/null | tail -n +2 | wc -l || echo "0"
else
  echo "⚠️ go 未安装,跳过 Go 依赖分析"
fi

# Python
if command -v python3 >/dev/null 2>&1; then
  echo "Python dependencies:"
  grep -cvE '^\s*(#|$)' requirements.txt 2>/dev/null || echo "0"
else
  echo "⚠️ python3 未安装,跳过 Python 依赖分析"
fi

统计(对应 templates/report.md 的变量):

  • dep_count:直接依赖数量(Node len(dependencies) / Go go list -m all 计数 / Python requirements 行数)
  • total_dep_count:含间接依赖的总数(解析 package-lock.json / go list -m all / pip list)
  • outdated_count:过时依赖数量(npm outdated --json / go list -m -u all / pip list --outdated)
  • health_score:综合评分(依赖规模、过时比例、冗余情况,0-100)
  • deps[].size:包大小(来自 cost-of-modules 或 bundlephobia;无则留空)
  • 重复依赖(不同包引入同一依赖的不同版本)
  • 可能的冗余依赖

Step 3: 扫描代码模式

前端/Node.js 重点:

  • 检查 import/require 是否有 barrel file(index.ts re-export 所有模块)
  • 检查是否有大型静态文件(>500KB 的图片/字体)
  • 检查是否有未使用的 CSS/JS 文件
  • 检查 next.config.js / vite.config.ts 的优化配置

Go 重点:

  • 检查是否有不必要的 init() 函数
  • 检查大 struct 的值传递(应改指针)

Python 重点:

  • 检查是否有 import *
  • 检查是否有同步 I/O 在异步上下文中

Step 4: 生成报告

使用 templates/report.md 模板,输出:

  1. 总览 — 依赖数量、项目健康度评分
  2. 高优先级 — 影响最大的问题(bundle 膨胀、冗余依赖)
  3. 中优先级 — 代码层面的优化点
  4. 低优先级 — 建议性改进
  5. 具体修复命令 — 每个问题附带可执行的修复命令

Quick Reference

/performance-profiler              # 分析当前项目,输出优化建议报告

Common Mistakes

错误正确做法原因
只看依赖数量不看体积同时分析包体积10 个小包可能比 1 个大包更好
建议删除所有 devDependenciesdevDependencies 不进生产它们不影响线上性能
忽略 lock 文件分析 lock 文件中的实际依赖树package.json 声明 ≠ 实际安装
不区分生产/开发依赖重点分析 dependenciesdevDependencies 不影响 bundle
忽略 barrel file 影响检查 index.ts 重新导出模式barrel file 阻止 tree-shaking,大幅增加 bundle
不考虑代码分割检查动态 import 使用情况单 chunk 加载所有代码影响首屏
建议删除所有重复依赖分析实际使用再决定有些是 peer dependency 必须保留
只分析前端不分析后端全栈项目前后端都分析Go/Python 也有性能问题
跳过 lock 文件分析解析 lock 文件获取完整依赖树直接依赖少不代表间接依赖少

FAQ

What does the performance-profiler skill do?

Use when profiling a Node/Go/Python project for performance bottlenecks — bundle size, dependency bloat, large files, unused code — and outputting prioritized optimization recommendations.

How do I install performance-profiler?

Run npx skills add https://github.com/wu529778790/shenzjd-skills --skill performance-profiler in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/performance-profiler/ (personal) or .claude/skills/performance-profiler/ (project).

Which AI agents can use performance-profiler?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is performance-profiler safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains performance-profiler?

It is published by wu529778790 in wu529778790/shenzjd-skills. It has 542 recorded installs.

More from wu529778790/shenzjd-skills

View all →

docker-build-deploy

wu529778790/shenzjd-skills

Use when containerizing a Node.js app and setting up GitHub Actions CI/CD to build, push to GHCR, and deploy via SSH. Multi-stage build, non-root user, caching.

DevOps & Cloud1K installs

dependency-audit

wu529778790/shenzjd-skills

Use when auditing project dependencies for security vulnerabilities, outdated packages, or license compliance across npm/yarn/pnpm, pip, go, and cargo.

Security989 installs

git-hooks-setup

wu529778790/shenzjd-skills

Use when setting up git hooks (pre-commit, commit-msg, pre-push) with husky or native hooks for linting, formatting, commit conventions, and secret scanning.

db-migration-helper

wu529778790/shenzjd-skills

Use when generating database migration SQL from model or schema changes — compares current vs desired schema, detects diffs, outputs reversible safe migrations.

github-profile-beautifier

wu529778790/shenzjd-skills

Use when creating or improving a GitHub profile README — themed stats cards, project showcase, tech-stack badges, and typing banner. 5 themes, smart project ranking (snake contribution graph needs separate setup).

Docs & Writing570 installs

api-doc-generator

wu529778790/shenzjd-skills

Use when generating OpenAPI/Swagger API docs from existing code — scans routes/annotations, extracts params and responses, outputs a YAML/JSON spec.

Backend & APIs550 installs

Popular code quality & workflow skills

View category →

grill-me

mattpocock/skills

A relentless interview to sharpen a plan or design.

Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.

handoff

mattpocock/skills

Compact the current conversation into a handoff document for another agent to pick up.

domain-modeling

mattpocock/skills

Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.

codebase-design

mattpocock/skills

Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.

diagnosing-bugs

mattpocock/skills

Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.