home / skills / codyswanngt / lisa / ops-performance

This skill analyzes Expo and serverless app performance, running Lighthouse audits, bundle size checks, and k6 load tests to optimize reliability.

npx playbooks add skill codyswanngt/lisa --skill ops-performance

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.7 KB
---
name: ops-performance
description: Performance analysis for Expo + serverless backend projects. Runs Lighthouse audits, bundle size analysis, and k6 load tests.
allowed-tools:
  - Bash
  - Read
---

# Ops: Performance

Analyze application performance.

**Argument**: `$ARGUMENTS` — analysis type (`lighthouse`, `bundle`, `k6`, `all`; default: `all`) and optional target environment

## Path Convention

- **Frontend**: Current project directory (`.`)
- **Backend**: `${BACKEND_DIR:-../backend-v2}` — set `BACKEND_DIR` in `.claude/settings.local.json` if your backend is elsewhere

## Discovery

1. Read frontend `package.json` for `lighthouse:check`, `export:web`, `analyze:bundle` scripts
2. Read backend `package.json` for `k6:*` scripts
3. Read `e2e/constants.ts` or `.env.*` files for environment URLs

## Lighthouse Audit

### Against Local

```bash
npx lighthouse http://localhost:8081 \
  --output=json \
  --output-path=./lighthouse-local.json \
  --chrome-flags='--headless --no-sandbox'
```

### Against Deployed Environment

Discover frontend URLs from `e2e/constants.ts` or `.env.*` files:

```bash
npx lighthouse https://{env_url} \
  --output=json \
  --output-path=./lighthouse-{env}.json \
  --chrome-flags='--headless --no-sandbox'
```

### LHCI (Lighthouse CI — uses project config)

```bash
bun run lighthouse:check
```

### Parse Lighthouse Results

```bash
cat lighthouse-{env}.json | jq '{
  performance: .categories.performance.score,
  accessibility: .categories.accessibility.score,
  bestPractices: .categories["best-practices"].score,
  seo: .categories.seo.score,
  fcp: .audits["first-contentful-paint"].displayValue,
  lcp: .audits["largest-contentful-paint"].displayValue,
  tbt: .audits["total-blocking-time"].displayValue,
  cls: .audits["cumulative-layout-shift"].displayValue,
  si: .audits["speed-index"].displayValue
}'
```

## Bundle Analysis

### Full Analysis (export + source-map-explorer)

```bash
bun run export:web && bun run analyze:bundle
```

### Quick Size Check

```bash
bun run export:web
echo "=== Total Bundle Size ==="
du -sh dist/
echo ""
echo "=== Largest JS Files ==="
find dist -name "*.js" -exec ls -lhS {} + 2>/dev/null | head -20
```

## k6 Load Tests

Discover available k6 scripts from the backend `package.json` (matching `k6:*`).

### Smoke Test (minimal load, verify endpoints work)

```bash
cd "${BACKEND_DIR:-../backend-v2}"
bun run k6:smoke
```

### Load Test (normal traffic simulation)

```bash
cd "${BACKEND_DIR:-../backend-v2}"
bun run k6:load
```

### Stress Test (push beyond normal capacity)

```bash
cd "${BACKEND_DIR:-../backend-v2}"
bun run k6:stress
```

### Spike Test (sudden traffic burst)

```bash
cd "${BACKEND_DIR:-../backend-v2}"
bun run k6:spike
```

### Docker-based k6 (no local k6 install needed)

```bash
cd "${BACKEND_DIR:-../backend-v2}"
bun run k6:docker:smoke
bun run k6:docker:load
```

## Output Format

### Lighthouse Scores

| Metric | Score | Rating |
|--------|-------|--------|
| Performance | 0.85 | GOOD |
| Accessibility | 0.92 | GOOD |
| Best Practices | 0.88 | GOOD |
| SEO | 0.95 | GOOD |

### Core Web Vitals

| Metric | Value | Threshold | Status |
|--------|-------|-----------|--------|
| FCP (First Contentful Paint) | 1.2s | < 1.8s | PASS |
| LCP (Largest Contentful Paint) | 2.1s | < 2.5s | PASS |
| TBT (Total Blocking Time) | 150ms | < 200ms | PASS |
| CLS (Cumulative Layout Shift) | 0.05 | < 0.1 | PASS |

### Bundle Size

| Category | Size | Notes |
|----------|------|-------|
| Total dist/ | 4.2 MB | |
| Largest chunk | 1.1 MB | vendor.js |

### k6 Results

| Metric | Value |
|--------|-------|
| Requests/sec | 450 |
| Avg response time | 120ms |
| p95 response time | 350ms |
| Error rate | 0.1% |

Include recommendations for any metrics that fall below thresholds.

Overview

This skill performs performance analysis for Expo frontend projects paired with serverless backends. It runs Lighthouse audits, bundle-size inspection, and k6 load tests to give actionable metrics and recommendations for web and API performance.

How this skill works

It discovers frontend and backend entry points by reading package.json scripts and environment constants, then runs Lighthouse either locally or against deployed URLs, exports a production build to analyze bundle composition, and executes k6 scenarios defined in the backend. Results are parsed into Lighthouse scores, Core Web Vitals, bundle breakdowns, and k6 throughput/latency/error metrics with tailored recommendations when thresholds are missed.

When to use it

  • Before a release to validate frontend Core Web Vitals and SEO metrics.
  • When bundle size growth needs investigation or tree-shaking verification.
  • During capacity planning or after changes to backend endpoints to verify performance under load.
  • When comparing local dev performance to deployed environments.
  • Regular CI checks to catch regressions in Lighthouse or load test results.

Best practices

  • Ensure BACKEND_DIR is set in .claude/settings.local.json when backend is not at ../backend-v2.
  • Commit or provide environment constants (e2e/constants.ts or .env.*) so deployed URLs are discoverable.
  • Run bun run export:web before bundle analysis to get accurate production artifacts.
  • Use LHCI (lighthouse:check) in CI to standardize Lighthouse runs and baseline comparisons.
  • Start with smoke k6 tests, then progress to load, stress, and spike to understand system behavior incrementally.

Example use cases

  • Run full analysis (all) to produce Lighthouse JSON, a bundle breakdown, and k6 load test summary for a release candidate.
  • Quickly check frontend bundle bloat by running export:web and listing largest JS files in dist/.
  • Verify Core Web Vitals locally with a headless Lighthouse run against http://localhost:8081.
  • Execute backend k6:load to validate average and p95 response times before traffic increases.
  • Use Docker-based k6 commands in CI to avoid local k6 installation requirements.

FAQ

How are frontend and backend locations discovered?

The skill reads frontend package.json in the current directory and looks for BACKEND_DIR (default ../backend-v2) or package.json k6:* scripts in the backend directory.

What thresholds trigger recommendations?

Recommendations are suggested when Lighthouse category scores or Core Web Vitals exceed common thresholds (for example LCP > 2.5s, CLS > 0.1, TBT > 200ms) or when k6 p95 latency and error rates indicate service degradation.