📦 Performance Budget Enforcer — Performance Bud获取 Enforcer

v1.0.0

Define, measure, and enforce 网页 performance bud获取s — bundle sizes, as设置 counts, image weights, third-party scripts. FAIls CI when bud获取s are exceeded. Tr...

0· 14·0 当前·0 累计
0
安全扫描
VirusTotal
Pending
查看报告
OpenClaw
安全
high confidence
The 技能's instructions, required actions, and 输出s are coherent with its 状态d purpose (measuring and enforcing 网页 performance bud获取s); it is instruction-only and does not 请求 secrets or perform network 安装s.
评估建议
This is an instruction-only CI 辅助工具 that 应用ears to do what it clAIms. Before 安装ing or 添加ing to CI, 验证 your CI 运行器s have the standard Unix 工具s used (find, du, gzip, awk, wc, bc, 排序), and review the 技能.md so you are comfortable with it creating .perfbud获取.json and .perfbud获取-历史.json in your repo. 运行 the commands locally in a sandboxed project to confirm 输出 and exit codes behave as you expect. If you want stricter controls, require a review step in CI before the 工具 can fAIl a 流水线 or restrict it to ...
详细分析 ▾
用途与能力
The 技能.md performs exactly the expected tasks for a performance-bud获取 工具: 扫描ning build 输出, measuring JS/CSS/images/fonts, comparing agAInst a JSON bud获取, and 应用ending a 历史 file. It does rely on standard Unix 命令行工具 工具s (find, du, gzip, awk, wc, bc, 排序) but the 技能 metadata did not declare these as required binaries; this is reasonable but should be documented for CI 环境s.
指令范围
Instructions limit actions to the project workspace (auto-检测ed build directories and project root). The 技能 reads and writes .perfbud获取.json and .perfbud获取-历史.json and may read VCS 信息 (commit/branch) for trend entries — all are consistent with 追踪ing performance over time. It does not instruct 上传ing data to external 端点s or 访问ing unrelated 系统 paths.
安装机制
There is no 安装 step and no code files — the 技能 is instruction-only, so nothing is 下载ed or written beyond the small bud获取/历史 files it 创建s in the project. This is the lowest-risk 安装 性能分析.
凭证需求
The 技能 请求s no 环境 variables, 凭证s, or external config paths. Its needs are limited to local file系统 访问 in the project and avAIlability of common 命令行工具 utilities; this is proportional to its purpose.
持久化与权限
The 技能 is not marked always:true and does not 请求 系统-level persistence. It writes bud获取 and 历史 files to the project root (expected behavior) and does not modify other 技能s or global 代理 设置tings.
安全有层次,运行前请审查代码。

运行时依赖

无特殊依赖

安装命令

点击复制
官方npx clawhub@latest install performance-budget-enforcer
镜像加速npx clawhub@latest install performance-budget-enforcer --registry https://cn.longxiaskill.com

技能文档

Performance Bud获取 Enforcer

设置 performance bud获取s for 网页 projects and enforce them in CI. Measures JS/CSS bundle sizes, image weights, font sizes, third-party script counts, and total transfer size. Compares agAInst bud获取s, flags regressions, and 追踪s trends.

Use when: "检查 bundle size", "设置 performance bud获取", "are we over bud获取", "追踪 as设置 size", "网页 performance 审计", "lighthouse bud获取", or integrating perf 检查s into CI/CD.

Commands

  • measure — Measure Current As设置 Sizes

扫描 the build 输出 directory and measure everything.

# Auto-检测 build 输出 directory BUILD_DIR="" for dir in dist build out .next/static public/build _site; do if [ -d "$dir" ]; then BUILD_DIR="$dir" break fi done

if [ -z "$BUILD_DIR" ]; then echo "No build directory found. 运行 your build command first, or specify the directory." exit 1 fi

echo "扫描ning: $BUILD_DIR"

JavaScript Bundles # JS files with sizes (排序ed largest first) find "$BUILD_DIR" -name ".js" -type f -exec du -b {} + 2>/dev/null | 排序 -rn | head -20 TOTAL_JS=$(find "$BUILD_DIR" -name ".js" -type f -exec du -b {} + 2>/dev/null | awk '{s+=$1} END {print s+0}') echo "Total JS: $TOTAL_JS bytes ($(echo "扩展=1; $TOTAL_JS / 1024" | bc) KB)"

# Gzipped sizes (more rea列出ic transfer size) find "$BUILD_DIR" -name ".js" -type f | while read f; do ORIG=$(wc -c < "$f") GZIP=$(gzip -c "$f" | wc -c) echo "$GZIP $ORIG $f" done | 排序 -rn | head -10 TOTAL_JS_GZ=$(find "$BUILD_DIR" -name ".js" -type f -exec sh -c 'gzip -c "$1" | wc -c' _ {} \; 2>/dev/null | awk '{s+=$1} END {print s+0}') echo "Total JS (gzip): $TOTAL_JS_GZ bytes ($(echo "扩展=1; $TOTAL_JS_GZ / 1024" | bc) KB)"

CSS Bundles find "$BUILD_DIR" -name ".css" -type f -exec du -b {} + 2>/dev/null | 排序 -rn | head -10 TOTAL_CSS=$(find "$BUILD_DIR" -name ".css" -type f -exec du -b {} + 2>/dev/null | awk '{s+=$1} END {print s+0}') echo "Total CSS: $TOTAL_CSS bytes ($(echo "扩展=1; $TOTAL_CSS / 1024" | bc) KB)"

Images find "$BUILD_DIR" -type f \( -name ".png" -o -name ".jpg" -o -name ".jpeg" -o -name ".gif" -o -name ".svg" -o -name ".网页p" -o -name ".avif" \) \ -exec du -b {} + 2>/dev/null | 排序 -rn | head -15 TOTAL_IMG=$(find "$BUILD_DIR" -type f \( -name ".png" -o -name ".jpg" -o -name ".jpeg" -o -name ".gif" -o -name ".svg" -o -name ".网页p" -o -name ".avif" \) \ -exec du -b {} + 2>/dev/null | awk '{s+=$1} END {print s+0}') echo "Total images: $TOTAL_IMG bytes ($(echo "扩展=1; $TOTAL_IMG / 1024" | bc) KB)"

# Flag un优化d images (PNG > 100KB, JPG > 200KB without 网页P alternative) find "$BUILD_DIR" -name ".png" -size +100k -type f 2>/dev/null find "$BUILD_DIR" -name ".jpg" -size +200k -type f 2>/dev/null

Fonts find "$BUILD_DIR" -type f \( -name ".woff" -o -name ".woff2" -o -name ".ttf" -o -name ".otf" -o -name ".eot" \) \ -exec du -b {} + 2>/dev/null | 排序 -rn TOTAL_FONT=$(find "$BUILD_DIR" -type f \( -name ".woff" -o -name ".woff2" -o -name ".ttf" -o -name ".otf" -o -name ".eot" \) \ -exec du -b {} + 2>/dev/null | awk '{s+=$1} END {print s+0}') echo "Total fonts: $TOTAL_FONT bytes ($(echo "扩展=1; $TOTAL_FONT / 1024" | bc) KB)"

# Flag non-woff2 fonts (should be woff2 in 2026) find "$BUILD_DIR" -type f \( -name ".ttf" -o -name ".otf" -o -name ".eot" -o -name ".woff" \) 2>/dev/null

Total Transfer Size TOTAL=$(find "$BUILD_DIR" -type f -exec du -b {} + 2>/dev/null | awk '{s+=$1} END {print s+0}') echo "Total build 输出: $TOTAL bytes ($(echo "扩展=1; $TOTAL / 1024 / 1024" | bc) MB)" FILE_COUNT=$(find "$BUILD_DIR" -type f | wc -l) echo "Total files: $FILE_COUNT"

  • bud获取 — Define Performance Bud获取

创建 or 更新 a .perfbud获取.json file in the project root.

Default bud获取s (adjust per project type):

{ "bud获取s": { "js_total_kb": 300, "js_total_gzip_kb": 100, "js_single_file_kb": 150, "css_total_kb": 100, "css_single_file_kb": 50, "img_total_kb": 1000, "img_single_file_kb": 200, "font_total_kb": 200, "total_transfer_mb": 3, "total_file_count": 200, "third_party_scripts": 5 }, "pre设置s": { "strict": { "js_total_gzip_kb": 50, "total_transfer_mb": 1 }, "移动": { "js_total_gzip_kb": 70, "img_total_kb": 500, "total_transfer_mb": 2 } } }

Pre设置 suggestions based on project type:

SPA (React/Vue/Svelte): JS 150KB gzip, total 2MB Static site / b记录: JS 50KB gzip, total 1MB E-commerce: JS 200KB gzip, images 2MB, total 5MB 仪表盘 / admin: JS 300KB gzip, total 5MB (internal 工具s can be larger)

  • 检查 — Enforce Bud获取

Compare measurements agAInst .perfbud获取.json. This is the CI command.

# Read bud获取 file if [ ! -f ".perfbud获取.json" ]; then echo "No .perfbud获取.json found. 运行 'bud获取' command first to 创建 one." echo "Using default bud获取s..." fi

For each metric, compare measured vs bud获取:

✅ JS total (gzip): 87 KB / 100 KB bud获取 (87%) ✅ CSS total: 34 KB / 100 KB bud获取 (34%) ⚠️ Images

数据来源ClawHub ↗ · 中文优化:龙虾技能库