Skip to content
Development
Skill

/lean

Use to make software faster or lighter when speed, memory, CPU or size is the problem. Do NOT use for correctness bugs.

From plugin
gg-framework
30914 skills

Claude Code

$ npx -y skills add KenKaiii/gg-framework --skill lean --agent claude-code

SKILL.md

lean.SKILL.md
name: lean
description: "Use to make software faster or lighter when speed, memory, CPU or size is the problem. Do NOT use for correctness bugs."
# Checklist audits only (Security, Dependencies, Secrets / Performance); hidden from routine coding after the 27 Oct 2026 skill-value bench.
hidden: true
license: Performance engineering guidance, not a benchmark certification. Sources and snapshot date are recorded at the foot of each reference file.
compatibility: Snapshot dated 3 October 2026; Node release schedule, Core Web Vitals browser support and the current Next.js version re-verified 22 October 2026. Thresholds and tool names decay — re-verify before asserting them as current.

Lean

**Pick your mode now:**

| You are… | Mode | Do | |---|---|---| | Writing or editing a feature (any size) | **Inline gate** | Apply *Binding defaults* + *AI-code traps* while you write. One line in the reply on what you did. No benchmarks, no spawning. | | Asked "make it faster / why slow / eating RAM / will it run smoothly", a regression, pre-ship | **Full pass** | Run *Full-pass workflow*. Read `references/playbooks.md` sections for the stacks found; `references/memory-and-processes.md` for any memory or process finding. |

**Process safety:** kill only an exact PID you started (the bash tool's rule); a process using lots of CPU/RAM is a finding to report, not a target. Details: `references/memory-and-processes.md`.

On from the first line of code: never ship the heavy version intending to "optimize later".

Governing rules

1. **Measure, then cut.** In a pass, never optimize from vibes: baseline → find the bottleneck → fix → re-measure. Build-mode defaults apply without benchmarking. 2. **Fix the shared cause once.** The N+1 belongs in the query layer, not a memo at each call site. 3. **Optimize user time, not machine time.** Startup, first paint, navigation, hot interactions, the nightly job. 4. **Memory should be flat.** After N cycles of the core loop, committed memory ≈ after 1. A climbing staircase is a leak; a sawtooth back to baseline is GC. 5. **Nothing outlives its job.** Timers, listeners, subscriptions, watchers, child processes, temp files, locks: each has an owner that ends it on success *and* every failure path. 6. **Bounded by default.** Cache, queue, buffer, retry, log, list render: cap and eviction policy at creation. 7. **Small is fast.** Deleting dead code, unused deps and duplicate styles is the cheapest optimization. 8. **Numbers or silence.** Before/after on the same machine and data, cold and warm. Say what moved, X → Y, and what you could not measure. 9. **No perf theater.** Complexity must pay for itself in measured user time, or revert it. 10. **Label evidence** on every claim: `RUNTIME` (measured), `CODE` (read in source), `DEDUCED` (inferred), `SNAPSHOT` (dated external source).

Binding defaults (build mode)

  • **Teardown ships with the feature.** Whatever you start is torn down in the same module, success and error paths. One cleanup handle per owner (`AbortController`, `dispose()`, `finally`).
  • **Cap every accumulation.** LRU/TTL cache, bounded queue, paginated query, virtualized long list, capped retries with backoff + jitter, rotating logs.
  • **Never block the interactive thread.** Work that can exceed a frame (web long-task threshold: 50 ms) is chunked (`scheduler.yield()` where supported, else `setTimeout` chunking), deferred, or moved to a worker / utility process / background thread.
  • **Lazy by default, eager only for the first screen.** Rare routes, heavy editors, charts, optional SDKs: dynamic `import()`.
  • **Right-size media.** AVIF/WebP with fallback, explicit `width`/`height`, `srcset`/`sizes`, `loading="lazy"` below the fold, `fetchpriority="high"` on the one LCP image only — never lazy-load it.
  • **Stream, don't hoard.** Stream files and large responses; cursor-paginate queries; chunk big jobs.
  • **Timeout everything external.** Network, subprocesses, locks, queues — and tear down on timeout.
  • **Price a dependency before adopting it** in anything user-facing (bundle impact client-side; `node --cpu-prof -e "require('mod')"` server/desktop).
  • **Batch I/O.** One query for N rows; DOM reads before writes; debounce/throttle expensive handlers.
  • **Events over polling.** Prefer push (WebSocket/SSE, watchers, webhooks). If you must poll: slowest tolerable interval, back off when idle, pause when hidden, stop on unmount.

AI-code traps (check every generated diff)

Scan your own diff before replying.

| Trap | Detect | Fix | |---|---|---| | Whole-library imports | `import * as Icons`, `import _ from "lodash"`, root imports of big icon/UI/date kits | Per-icon/per-function imports or the library's documented tree-shakable entry; confirm in the bundle analyzer | | Effect refetch loops | `useEffect` fetching with object/array/function deps created during render, or no deps array | Fetch on the server / in the route loader / via a query library keyed by primitives | | Over-fetching | `SELECT *`, `findMany()` without `take`/`select`, API returning full rows to render two fields | Select needed columns, paginate, shape on the server | | N+1 | `await` on a query inside `for` / `.map` | Join/include/batch (`IN (...)`, DataLoader) | | Unvirtualized lists | `.map` over unbounded data into DOM or `ScrollView` | Paginate or virtualize (`FlatList`/`FlashList`, TanStack Virtual, `LazyColumn`) | | Polling | `setInterval(fetch…)` without cleanup or visibility check | Events; else backoff + pause + cleanup | | Everything client-side | `"use client"` at the top of a page tree; browser fetches data the server already had | Push the client boundary down to the interactive leaf | | Memo sprinkling | `useMemo`/`useCallback`/`React.memo` on everything | React Compiler on → write plain code, keep manual memo only as an escape hatch (e.g. stable effect deps). Compiler off → memo only what the Profiler implicates | | Unbounded module cache | `const cache = new Map()` at

Read more
@kenkaiii
Ships withgg-framework

The coding agent that gets more out of your AI subscription. Fastest and leanest of 20 agents tested, with unlimited local search of real open-source code.

Stars on GitHub

Momentum

stars in total
309
Star history of KenKaiii/gg-framework on GitHub, a chart by star-history.com

Other skills on gg-framework.

app-walkthrough

app-walkthrough

Job skill for showing how an app or product is used, step by step, on rebuilt real screens. Adds walkthrough questions, the…

before-after

before-after

Job skill for a before-and-after video, showing life without the product, then with it. Adds before/after questions, idea…

brand-kit

brand-kit

Resolve and reuse the user's brand identity for a Motion video. Use when fonts, colours, logos or brand copy need mapping or a…

dev-tool-video

dev-tool-video

Job skill for a video about a developer tool: a CLI, API, library, SDK or editor plugin. Adds questions, terminal and code moves,…

launch-video

launch-video

Job skill for a product, feature or brand launch video. Adds launch questions, idea patterns, moves and pitfalls to the motion…

match-reference

match-reference

Job skill for a video like one the user supplies. Measures the reference's rhythm and style rules with reference-study.mjs, then…

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills2w309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc3w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react10d252k
@facebook@facebookInstall Skill

Questions about lean.

Which coding agents can use lean?
lean installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.