agentleFS
buildpad-aibuildpad-ai/skills/performance-optimization/SKILL.md

performance-optimization

Skill1 starsChanged 27 days agoMITView on GitHub

Optimizes application performance. Use when performance requirements exist, when you suspect performance regressions, or when Core Web Vitals or load times need improvement. Use when profiling reveals bottlenecks that need fixing.

125 other projects use a version of this, 60 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use constraint-driven-development, using-agent-skills and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MrCipherSmithSkill

    constraint-driven-development

    Use when a project needs a persistent, measurable quality bar — starting a project without documented standards, 'set up constraints', or when coverage/perf/a11y thresholds get re-debated per-PR. Produces CONSTRAINTS.md with enforceable numbers, ratchets, and a guard against silent weakening. NOT for throwaway prototypes or a one-off CI setup.

    Also in 15 projects that use this

  • LLl0k0laDSkill

    using-agent-skills

    Use when starting a session or when you need to discover which skill applies to the current task. This is the meta-skill that governs how all other skills are discovered and invoked.

    Also in 33 projects that use this

  • LLl0k0laDSkill

    shipping-and-launch

    Use when preparing to deploy to production. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.

    Also in 42 projects that use this

  • HK-hubSkill

    deprecation-and-migration

    Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when deciding whether to maintain or sunset existing code.

    Also in 39 projects that use this

  • ukanwatSkill

    input-systems

    Architect game input — action mapping (abstracting keys into named actions), rebinding with conflict detection and persistence, multi-device support (keyboard, gamepad, touch), analog deadzones, and feel features like input buffering and coyote time, plus accessibility. Engine-neutral. Use when the user mentions input mapping, rebind controls, gamepad support, deadzone, input buffering, coyote time, or accessible controls.

    Also in 4 projects that use this

  • HK-hubSkill

    observability-and-instrumentation

    Instruments code so production behavior is visible and diagnosable. Use when adding logging, metrics, tracing, or alerting. Use when shipping any feature that runs in production and you need evidence it works. Use when production issues are reported but you can't tell what happened from the available data.

    Also in 31 projects that use this

  • +4 more from LLl0k0laD

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 4 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 110 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When NOT to use: Don't optimize before you have evidence of a problem.

    line 20
  2. Distinctive:

    Use Server Components by default (reduces client JS)

    line 126
  3. Very specific:

    Use 'use client' only when needed (event handlers, hooks, browser APIs)

    line 127
  4. Very specific:

    Use next/image for automatic image optimization

    line 128
  5. Very specific:

    Use next/font for font optimization

    line 129
  6. Very specific:

    Use DaaS fields parameter to fetch only needed fields

    line 131
  7. Very specific:

    Use DaaS filter parameter server-side instead of client-side filtering

    line 132
  8. Distinctive:

    No performance monitoring in production

    line 152
  9. Distinctive:

    After any performance-related change:

    line 157

“Common” is measured: kept by at least 6 in 10 of the 110 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Performance Optimization

Overview

Measure before optimizing. Performance work without measurement is guessing — and guessing leads to premature optimization that adds complexity without improving what matters. Profile first, identify the actual bottleneck, fix it, measure again.

When to Use

  • Performance requirements exist in the spec (load time budgets, response time SLAs)
  • Users or monitoring report slow behavior
  • Core Web Vitals scores are below thresholds
  • You suspect a change introduced a regression
  • Building features that handle large datasets or high traffic

When NOT to use: Don't optimize before you have evidence of a problem.

Core Web Vitals Targets

MetricGoodNeeds ImprovementPoor
LCP (Largest Contentful Paint)≤ 2.5s≤ 4.0s> 4.0s
INP (Interaction to Next Paint)≤ 200ms≤ 500ms> 500ms
CLS (Cumulative Layout Shift)≤ 0.1≤ 0.25> 0.25

The Optimization Workflow

1. MEASURE  → Establish baseline with real data
2. IDENTIFY → Find the actual bottleneck (not assumed)
3. FIX      → Address the specific bottleneck
4. VERIFY   → Measure again, confirm improvement
5. GUARD    → Add monitoring or tests to prevent regression

Where to Start

What is slow?
├── First page load
│   ├── Large bundle? → Measure bundle size, check code splitting
│   ├── Slow server response? → Measure TTFB in Network waterfall
│   └── Render-blocking resources? → Check CSS/JS blocking in waterfall
├── Interaction feels sluggish
│   ├── UI freezes on click? → Profile main thread, look for long tasks (>50ms)
│   ├── Form input lag? → Check re-renders, controlled component overhead
│   └── Animation jank? → Check layout thrashing, forced reflows
├── Page after navigation
│   ├── Data loading? → Measure API response times, check for waterfalls
│   └── Client rendering? → Profile component render time
└── Backend / API
    ├── Single endpoint slow? → Profile DaaS queries, check indexes (on an Engine project, index a field by creating it with `schema.add_index: true` through `POST /api/fields/:collection`)
    ├── All endpoints slow? → Check connection pool, memory, CPU
    └── Intermittent slowness? → Check for lock contention, GC pauses

Fix Common Anti-Patterns

N+1 Queries (DaaS)

// BAD: Separate fetch per related item
for (const task of tasks) {
  task.owner = await fetch(`/api/users/${task.ownerId}`);
}

// GOOD: Use DaaS deep query with fields parameter
const tasks = await fetch('/api/items/tasks?fields=*,owner.*');

On an Engine project the fields parameter expands the relation as shown; the Engine ignores the deep parameter.

Unnecessary Re-renders (React)

// BAD: Creates new object on every render
function TaskList() {
  return <TaskFilters options={{ sortBy: 'date', order: 'desc' }} />;
}

// GOOD: Stable reference
const DEFAULT_OPTIONS = { sortBy: 'date', order: 'desc' } as const;
function TaskList() {
  return <TaskFilters options={DEFAULT_OPTIONS} />;
}

Large Bundle Size (Next.js)

// GOOD: Dynamic import for heavy features
const ChartLibrary = lazy(() => import('./ChartLibrary'));

// GOOD: Route-level code splitting (Next.js does this automatically)
// Each page in app/ is automatically code-split

Unbounded Data Fetching

// BAD: Fetching all records
const all = await fetch('/api/items/tasks');

// GOOD: Paginated with DaaS
const page = await fetch('/api/items/tasks?limit=20&offset=0&sort=-date_created');

On an Engine project limit is capped at 1000: a request for more returns at most 1000 items, so page through larger sets.

Performance Budget

JavaScript bundle: < 200KB gzipped (initial load)
CSS: < 50KB gzipped
Images: < 200KB per image (above the fold)
API response time: < 200ms (p95)
Lighthouse Performance score: ≥ 90

Next.js / DaaS Specific Tips

  • Use Server Components by default (reduces client JS)
  • Use 'use client' only when needed (event handlers, hooks, browser APIs)
  • Use next/image for automatic image optimization
  • Use next/font for font optimization
  • Leverage DaaS aggregate API for counts/sums instead of fetching all records
  • Use DaaS fields parameter to fetch only needed fields
  • Use DaaS filter parameter server-side instead of client-side filtering
  • On an Engine project the Engine serves the same aggregate, fields and filter parameters, and caps limit at 1000

Common Rationalizations

RationalizationReality
"We'll optimize later"Performance debt compounds. Fix obvious anti-patterns now.
"It's fast on my machine"Your machine isn't the user's. Profile on representative hardware.
"This optimization is obvious"If you didn't measure, you don't know. Profile first.
"Users won't notice 100ms"Research shows 100ms delays impact conversion rates.
"The framework handles performance"Frameworks can't fix N+1 queries or oversized bundles.

Red Flags

  • Optimization without profiling data to justify it
  • N+1 query patterns in data fetching
  • List endpoints without pagination
  • Images without dimensions, lazy loading, or responsive sizes
  • Bundle size growing without review
  • No performance monitoring in production
  • React.memo and useMemo everywhere (overusing is as bad as underusing)

Verification

After any performance-related change:

  • Before and after measurements exist (specific numbers)
  • The specific bottleneck is identified and addressed
  • Core Web Vitals are within "Good" thresholds
  • Bundle size hasn't increased significantly
  • No N+1 queries in new data fetching code
  • Existing tests still pass (optimization didn't break behavior)

See Also

For detailed checklists, see references/performance-checklist.md.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.