Skip to content

microsoft/power-platform-skills / plugins/power-pages/skills/analyze-performance

analyze-performance

Verified

Statically scans the entire local Power Pages codebase for performance anti-patterns — unpaginated Power Pages lists, webpages/web templates used as custom data APIs, FetchXML over-fetching / N+1 / advanced query hints / cache bypassing, unbounded Web API queries, disabled header/footer output caching, sign-in and page tracking, main-thread-blocking JS, CSS @import, frequent Web API polling, and oversized assets — then enriches findings with AI-driven suggestions and mitigations grounded in the affected customer-code snippets, reports them, and offers safe auto-fixes with per-fix approval. Use when the user wants to: "check performance", "perf check", "find performance issues", "why is my site slow", "optimize my Power Pages site", "find anti-patterns", "review FetchXML performance", "is my site over-fetching data", or "audit site performance".

scripts/validate-analyze-performance.js

View on GitHub
#!/usr/bin/env node

// Validates one explicitly named analyze-performance HTML report.
//
// The generic Skill PostToolUse hook fires when the skill instructions are loaded,
// before this workflow renders a report. It therefore invokes this script without
// `--reportPath`, which must approve instead of inspecting historical files. Phase
// 6.3 calls this script explicitly with the report it just rendered; only that path
// is validated, so an old malformed/good report cannot affect the current run.

const fs = require('fs');
const path = require('path');
const { approve, block, runValidation } = require('../../../scripts/lib/validation-helpers');

// render-template.js leaves __KEY__ tokens verbatim when a required value was not
// supplied, so their presence in the output is a definitive render failure.
// See scripts/lib/render-template.js (placeholder = `__${key}__`).
const UNREPLACED_PLACEHOLDER = /__[A-Z][A-Z0-9_]+__/;
// Guard against a truncated/empty write masquerading as a real report.
const MIN_REPORT_BYTES = 500;

function getArg(name) {
  const flag = `--${name}`;
  const index = process.argv.indexOf(flag);
  return index >= 0 ? process.argv[index + 1] : null;
}

function validateReport(reportPath) {
  const resolved = path.resolve(reportPath);
  if (!fs.existsSync(resolved)) {
    return `Performance report was not created at ${resolved}. Re-run /power-pages:analyze-performance.`;
  }

  let content = '';
  try {
    content = fs.readFileSync(resolved, 'utf8');
  } catch (error) {
    return `Performance report could not be read at ${resolved}: ${error.message}`;
  }

  const reportBytes = Buffer.byteLength(content, 'utf8');
  if (reportBytes < MIN_REPORT_BYTES) {
    return `Performance report ${path.basename(resolved)} is suspiciously small (${reportBytes} bytes) — the render likely failed. Re-run /power-pages:analyze-performance.`;
  }
  if (UNREPLACED_PLACEHOLDER.test(content)) {
    return `Performance report ${path.basename(resolved)} has unreplaced template placeholders — the report data was not populated. Re-run the render step in /power-pages:analyze-performance.`;
  }

  return null;
}

const reportPath = getArg('reportPath');
if (reportPath) {
  const error = validateReport(reportPath);
  if (error) block(error);
  approve();
} else {
  // Hook mode: no report exists for the current invocation yet. Never inspect an
  // older report because that could block a prerequisite/review-mode run or mask
  // a missing current render.
  runValidation(() => approve());
}

module.exports = { validateReport };
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall