Install command
Provided
Monitors and alerts on performance-impacting changes in real-time.
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Provided
Config snippet
Provided
Copy snippet
Provided
Prerequisites
None
Platforms
1 listed
Difficulty
0/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Safety & privacy surface
1 safety and 1 privacy notes across 2 risk areas. Review closely: credentials & tokens, permissions & scopes.
#!/usr/bin/env bash
# Performance Impact Monitor Hook
# Monitors for performance-impacting changes in real-time
echo "⚡ Performance Impact Monitor" >&2
# Initialize performance monitoring
PERF_WARNINGS=0
PERF_ERRORS=0
PERF_INFO=0
FILE_SIZE=0
LINE_COUNT=0
# Performance thresholds (configurable)
LARGE_FILE_THRESHOLD=100000 # 100KB
MASSIVE_FILE_THRESHOLD=500000 # 500KB
LARGE_FUNCTION_LINES=50
COMPLEX_CYCLOMATIC=10
LONG_TIMER_MS=5000
# Function to report performance impacts
report_performance() {
local level="$1"
local message="$2"
local suggestion="$3"
case "$level" in
"ERROR")
echo "🚨 CRITICAL PERFORMANCE IMPACT: $message" >&2
[ -n "$suggestion" ] && echo " 💡 Suggestion: $suggestion" >&2
PERF_ERRORS=$((PERF_ERRORS + 1))
;;
"WARNING")
echo "⚠️ PERFORMANCE WARNING: $message" >&2
[ -n "$suggestion" ] && echo " 💡 Suggestion: $suggestion" >&2
PERF_WARNINGS=$((PERF_WARNINGS + 1))
;;
"INFO")
echo "ℹ️ PERFORMANCE INFO: $message" >&2
[ -n "$suggestion" ] && echo " 💡 Tip: $suggestion" >&2
PERF_INFO=$((PERF_INFO + 1))
;;
esac
}
# Get environment variables (simulated Claude tool context)
TOOL_NAME="${CLAUDE_TOOL_NAME:-unknown}"
FILE_PATH="${CLAUDE_TOOL_FILE_PATH:-}"
# If no file path provided, try to get from stdin input
if [ -z "$FILE_PATH" ]; then
# Try to read tool input from stdin (for newer hook format)
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // "unknown"' 2>/dev/null || echo "unknown")
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""' 2>/dev/null || echo "")
fi
# Skip if no file path available
if [ -z "$FILE_PATH" ]; then
exit 0
fi
# Skip if file doesn't exist or is not readable
if [ ! -f "$FILE_PATH" ] || [ ! -r "$FILE_PATH" ]; then
exit 0
fi
# Only monitor for Edit/Write operations
if [[ "$TOOL_NAME" != "Edit" ]] && [[ "$TOOL_NAME" != "Write" ]] && [[ "$TOOL_NAME" != "MultiEdit" ]]; then
exit 0
fi
FILE_NAME=$(basename "$FILE_PATH")
FILE_EXT="${FILE_NAME##*.}"
echo " 📊 Analyzing performance impact of: $FILE_NAME" >&2
# 1. File Size Impact Analysis
FILE_SIZE=$(stat -f%z "$FILE_PATH" 2>/dev/null || stat -c%s "$FILE_PATH" 2>/dev/null || echo "0")
LINE_COUNT=$(wc -l < "$FILE_PATH" 2>/dev/null || echo "0")
echo " 📏 File size: $(( FILE_SIZE / 1024 ))KB, Lines: $LINE_COUNT" >&2
# File size warnings
if [ "$FILE_SIZE" -gt "$MASSIVE_FILE_THRESHOLD" ]; then
report_performance "ERROR" "Massive file detected ($(( FILE_SIZE / 1024 ))KB)" "Consider code splitting or modularization"
elif [ "$FILE_SIZE" -gt "$LARGE_FILE_THRESHOLD" ]; then
report_performance "WARNING" "Large file detected ($(( FILE_SIZE / 1024 ))KB)" "Monitor bundle size impact and consider optimization"
fi
# 2. Language-Specific Performance Analysis
case "$FILE_EXT" in
"js"|"jsx"|"ts"|"tsx")
echo " 📦 JavaScript/TypeScript performance analysis..." >&2
# Large function detection
LARGE_FUNCTIONS=$(grep -n 'function\\|=>' "$FILE_PATH" | while read line; do
line_num=$(echo "$line" | cut -d: -f1)
# Simple heuristic: look for next function or end of file
next_func=$(tail -n +$((line_num + 1)) "$FILE_PATH" | grep -n 'function\\|=>' | head -1 | cut -d: -f1)
if [ -n "$next_func" ]; then
func_lines=$((next_func - 1))
else
func_lines=$(tail -n +$line_num "$FILE_PATH" | wc -l)
fi
if [ "$func_lines" -gt "$LARGE_FUNCTION_LINES" ]; then
echo "$line_num:$func_lines"
fi
done)
if [ -n "$LARGE_FUNCTIONS" ]; then
func_count=$(echo "$LARGE_FUNCTIONS" | wc -l)
report_performance "WARNING" "$func_count large function(s) detected (>$LARGE_FUNCTION_LINES lines)" "Consider breaking down into smaller functions"
fi
# Performance anti-patterns
if grep -q '\\$(' "$FILE_PATH" 2>/dev/null; then
jquery_count=$(grep -c '\\$(' "$FILE_PATH" 2>/dev/null || echo "0")
if [ "$jquery_count" -gt 5 ]; then
report_performance "INFO" "Heavy jQuery usage detected ($jquery_count instances)" "Consider modern alternatives like vanilla JS or React"
fi
fi
# Long timers
if grep -E '(setTimeout|setInterval).*[0-9]{4,}' "$FILE_PATH" 2>/dev/null; then
report_performance "WARNING" "Long timer intervals detected (>=${LONG_TIMER_MS}ms)" "Verify if long delays are intentional"
fi
# Nested loops
NESTED_LOOPS=$(grep -E 'for.*{[^}]*for.*{[^}]*for' "$FILE_PATH" 2>/dev/null || echo "")
if [ -n "$NESTED_LOOPS" ]; then
report_performance "ERROR" "Triple nested loops detected - O(n³) complexity" "Consider algorithm optimization or data structure changes"
elif grep -E 'for.*{[^}]*for' "$FILE_PATH" 2>/dev/null; then
nested_count=$(grep -c 'for.*{[^}]*for' "$FILE_PATH" 2>/dev/null || echo "0")
if [ "$nested_count" -gt 3 ]; then
report_performance "WARNING" "Multiple nested loops detected" "Review algorithmic complexity"
fi
fi
# Memory leak patterns
if grep -q 'addEventListener.*function' "$FILE_PATH" 2>/dev/null; then
if ! grep -q 'removeEventListener' "$FILE_PATH" 2>/dev/null; then
report_performance "WARNING" "Event listeners without cleanup detected" "Add removeEventListener calls to prevent memory leaks"
fi
fi
# Global variable pollution
GLOBAL_VARS=$(grep -c '^var\\|^let\\|^const' "$FILE_PATH" 2>/dev/null || echo "0")
if [ "$GLOBAL_VARS" -gt 20 ]; then
report_performance "INFO" "Many global variables detected ($GLOBAL_VARS)" "Consider using modules or namespacing"
fi
# Bundle size impact for dependencies
if grep -q 'import.*from' "$FILE_PATH" 2>/dev/null; then
LARGE_IMPORTS=$(grep -E 'import.*(lodash|moment|rxjs)' "$FILE_PATH" 2>/dev/null || echo "")
if [ -n "$LARGE_IMPORTS" ]; then
report_performance "INFO" "Large library imports detected" "Consider tree shaking or lighter alternatives"
fi
fi
;;
"py")
echo " 🐍 Python performance analysis..." >&2
# List comprehensions vs loops
if grep -q 'for.*in.*:' "$FILE_PATH" 2>/dev/null; then
list_comp_count=$(grep -c '\\[.*for.*in.*\\]' "$FILE_PATH" 2>/dev/null || echo "0")
loop_count=$(grep -c 'for.*in.*:' "$FILE_PATH" 2>/dev/null || echo "0")
if [ "$loop_count" -gt 0 ] && [ "$list_comp_count" -eq 0 ]; then
report_performance "INFO" "Consider using list comprehensions for better performance" "List comprehensions are often faster than explicit loops"
fi
fi
# Global imports inside functions
if grep -A 5 'def ' "$FILE_PATH" | grep -q 'import' 2>/dev/null; then
report_performance "WARNING" "Imports inside functions detected" "Move imports to module level for better performance"
fi
# String concatenation
if grep -q '+.*+.*+' "$FILE_PATH" 2>/dev/null; then
report_performance "INFO" "String concatenation chains detected" "Consider using f-strings or join() for better performance"
fi
;;
"sql")
echo " 🗄️ SQL performance analysis..." >&2
# Missing indexes (basic heuristics)
if grep -qi 'where.*=' "$FILE_PATH" 2>/dev/null; then
if ! grep -qi 'index' "$FILE_PATH" 2>/dev/null; then
report_performance "WARNING" "WHERE clauses without visible indexes" "Ensure proper indexing for query performance"
fi
fi
# SELECT * usage
if grep -qi 'select \\*' "$FILE_PATH" 2>/dev/null; then
select_star_count=$(grep -ci 'select \\*' "$FILE_PATH" 2>/dev/null || echo "0")
report_performance "WARNING" "SELECT * queries detected ($select_star_count)" "Specify only needed columns for better performance"
fi
# Cartesian products
if grep -qi 'from.*,.*where' "$FILE_PATH" 2>/dev/null; then
if ! grep -qi 'join' "$FILE_PATH" 2>/dev/null; then
report_performance "ERROR" "Potential cartesian product detected" "Use explicit JOINs instead of comma-separated tables"
fi
fi
;;
"css"|"scss"|"sass")
echo " 🎨 CSS performance analysis..." >&2
# Complex selectors
COMPLEX_SELECTORS=$(grep -c '[[:space:]].*[[:space:]].*[[:space:]].*[[:space:]]' "$FILE_PATH" 2>/dev/null || echo "0")
if [ "$COMPLEX_SELECTORS" -gt 5 ]; then
report_performance "WARNING" "Complex CSS selectors detected ($COMPLEX_SELECTORS)" "Simplify selectors for better rendering performance"
fi
# Expensive properties
if grep -q 'box-shadow.*,.*,' "$FILE_PATH" 2>/dev/null; then
report_performance "INFO" "Complex box-shadow detected" "Consider simpler shadow effects for better performance"
fi
if grep -q '@import' "$FILE_PATH" 2>/dev/null; then
import_count=$(grep -c '@import' "$FILE_PATH" 2>/dev/null || echo "0")
if [ "$import_count" -gt 3 ]; then
report_performance "WARNING" "Multiple CSS @imports detected ($import_count)" "Consider bundling CSS files to reduce HTTP requests"
fi
fi
;;
"html")
echo " 🌐 HTML performance analysis..." >&2
# Inline styles
INLINE_STYLES=$(grep -c 'style=' "$FILE_PATH" 2>/dev/null || echo "0")
if [ "$INLINE_STYLES" -gt 10 ]; then
report_performance "WARNING" "Many inline styles detected ($INLINE_STYLES)" "Move styles to CSS files for better caching"
fi
# Large images without attributes
if grep -q '<img' "$FILE_PATH" 2>/dev/null; then
if ! grep -q 'width=\\|height=' "$FILE_PATH" 2>/dev/null; then
img_count=$(grep -c '<img' "$FILE_PATH" 2>/dev/null || echo "0")
report_performance "INFO" "Images without dimensions detected ($img_count)" "Add width/height attributes to prevent layout shifts"
fi
fi
;;
esac
# 3. Asset Performance Analysis
echo " 🖼️ Asset performance analysis..." >&2
# Check for asset imports/references
if [[ "$FILE_EXT" =~ ^(js|jsx|ts|tsx|css|scss|html)$ ]]; then
# Image references
IMAGE_REFS=$(grep -oE '\\.(jpg|jpeg|png|gif|svg|webp)' "$FILE_PATH" 2>/dev/null | wc -l || echo "0")
if [ "$IMAGE_REFS" -gt 10 ]; then
report_performance "INFO" "Many image references detected ($IMAGE_REFS)" "Consider image optimization and lazy loading"
fi
# Large base64 data
if grep -q 'data:image' "$FILE_PATH" 2>/dev/null; then
BASE64_COUNT=$(grep -c 'data:image' "$FILE_PATH" 2>/dev/null || echo "0")
report_performance "WARNING" "Base64 encoded images detected ($BASE64_COUNT)" "Consider using separate image files for better caching"
fi
fi
# 4. Database Query Analysis
if grep -qi 'select\\|insert\\|update\\|delete' "$FILE_PATH" 2>/dev/null; then
echo " 🗄️ Database query analysis..." >&2
# N+1 query patterns
if grep -q 'for.*in' "$FILE_PATH" 2>/dev/null && grep -q 'select\\|query' "$FILE_PATH" 2>/dev/null; then
report_performance "WARNING" "Potential N+1 query pattern detected" "Consider using joins or batch queries"
fi
# Missing LIMIT clauses
if grep -qi 'select.*from' "$FILE_PATH" 2>/dev/null; then
if ! grep -qi 'limit\\|top\\|rownum' "$FILE_PATH" 2>/dev/null; then
unlimited_queries=$(grep -ci 'select.*from' "$FILE_PATH" 2>/dev/null || echo "0")
if [ "$unlimited_queries" -gt 2 ]; then
report_performance "WARNING" "Queries without LIMIT detected ($unlimited_queries)" "Add LIMIT clauses to prevent large result sets"
fi
fi
fi
fi
# 5. Framework-Specific Analysis
if [[ "$FILE_EXT" =~ ^(jsx|tsx)$ ]]; then
echo " ⚛️ React performance analysis..." >&2
# Component re-render patterns
if grep -q 'useState\\|useEffect' "$FILE_PATH" 2>/dev/null; then
if ! grep -q 'useMemo\\|useCallback\\|React.memo' "$FILE_PATH" 2>/dev/null; then
hooks_count=$(grep -c 'useState\\|useEffect' "$FILE_PATH" 2>/dev/null || echo "0")
if [ "$hooks_count" -gt 5 ]; then
report_performance "INFO" "Many React hooks without memoization" "Consider useMemo/useCallback for expensive operations"
fi
fi
fi
# Inline object/function creation in props
if grep -q '={{' "$FILE_PATH" 2>/dev/null; then
inline_objects=$(grep -c '={{' "$FILE_PATH" 2>/dev/null || echo "0")
if [ "$inline_objects" -gt 5 ]; then
report_performance "WARNING" "Many inline objects in JSX props ($inline_objects)" "Extract to variables to prevent unnecessary re-renders"
fi
fi
fi
# 6. Generate Performance Impact Summary
echo "" >&2
echo "⚡ Performance Impact Summary" >&2
echo "============================" >&2
echo " 📄 File: $FILE_NAME ($(( FILE_SIZE / 1024 ))KB)" >&2
echo " 🚨 Critical Issues: $PERF_ERRORS" >&2
echo " ⚠️ Warnings: $PERF_WARNINGS" >&2
echo " ℹ️ Optimization Tips: $PERF_INFO" >&2
# Performance impact assessment
TOTAL_ISSUES=$((PERF_ERRORS + PERF_WARNINGS))
if [ "$PERF_ERRORS" -gt 0 ]; then
echo " 🚨 Impact Level: HIGH - Critical performance issues detected" >&2
elif [ "$PERF_WARNINGS" -gt 3 ]; then
echo " ⚠️ Impact Level: MODERATE - Multiple performance concerns" >&2
elif [ "$PERF_WARNINGS" -gt 0 ]; then
echo " ⚠️ Impact Level: LOW - Minor performance considerations" >&2
elif [ "$PERF_INFO" -gt 0 ]; then
echo " ✅ Impact Level: MINIMAL - Good practices recommended" >&2
else
echo " 🎉 Impact Level: OPTIMAL - No performance issues detected" >&2
fi
if [ "$TOTAL_ISSUES" -gt 0 ]; then
echo "" >&2
echo "💡 Performance Optimization Resources:" >&2
echo " • Web: Core Web Vitals and Lighthouse audits" >&2
echo " • JavaScript: Profiler tools and performance monitoring" >&2
echo " • Database: Query optimization and indexing strategies" >&2
echo " • Bundle: Code splitting and tree shaking" >&2
fi
echo "⚡ Performance impact monitoring complete" >&2
exit 0{
"hooks": {
"notification": {
"script": "./.claude/hooks/performance-impact-monitor.sh"
}
}
}Show that Performance Impact Monitor - Hooks is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/hooks/performance-impact-monitor)Performance Impact Monitor - Hooks side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
| Field | Monitors and alerts on performance-impacting changes in real-time. Open dossier | Alerts when files exceed size thresholds that could impact performance. This PostToolUse hook provides comprehensive file size monitoring when files are created or modified, automatically detecting files that exceed recommended size thresholds for different file types and providing optimization suggestions. Open dossier | Monitors memory usage and alerts when thresholds are exceeded. Open dossier | A Claude Code hook that flags files exceeding complexity thresholds after you edit them — estimating cyclomatic complexity, line and function counts, and nesting depth (via ESLint's complexity rule and Radon). Open dossier |
|---|---|---|---|---|
| Next steps | ||||
| Trust | ||||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed | Source-backed | Source-backed |
| Submitter | — | — | — | — |
| Install risk | Review first | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — | — | — |
| Category | hooks | hooks | hooks | hooks |
| Source | source-backed | source-backed | source-backed | source-backed |
| Author | JSONbored | JSONbored | JSONbored | JSONbored |
| Added | 2025-09-19 | 2025-09-19 | 2025-09-19 | 2025-09-19 |
| Platforms | Claude Code | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — | — |
| Safety notes | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs after edits to JS/TS/Python files and prints advisory warnings only; the line/function/brace counts are heuristics, not a substitute for ESLint or Radon run on the full project. |
| Privacy notes | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Reads the contents of files you edit to compute complexity locally; it prints warnings to hook output and does not transmit code, but those messages can reveal file structure. |
| Prerequisites | — none listed | — none listed | — none listed | — none listed |
| Install | | | | |
| Config | | | | |
| Citations | ||||
| Claim | Unclaimed | Unclaimed | Unclaimed | Unclaimed |
Source-backed guides for putting this to work.
Control MCP tool output size with env limits, annotations, and tool search to protect Claude Code context.
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.