Performance Optimization Workflow
Strong dependencies (frontmatter): clarifying-question-discipline (one question per turn), known-issue-research (known performance-pattern quick search at the locate stage). If any is missing, abort and print: npx skills add FuDesign2008/open-skills -g --skill '*' --yes.
Runtime strong dependency (environment, not frontmatter): a loop-runner capability for the Stages 5-6 iteration loop — probed at Stage 5 entry; missing means optimization execution stops (see "Iteration loop").
Scope
This workflow owns the full performance optimization paradigm: build a reproducible benchmark, gate every conclusion through evidence-validity checks, attribute the bottleneck along the full chain, optimize one target per iteration, verify by A/B cross-run statistics, and sediment results in a benchmark log — the optimize↔verify cycle running on an environment-provided iteration loop (honest stop when absent). Its per-project deliverables: the benchmark log + harness, and two evolving project-level skills (code-insight for attribution, code-optimizer for optimization) that carry the stack/project knowledge and improve with every campaign.
It answers: who triggers what expensive operation, under which conditions, on which devices — and then eliminates it measurably. Shipping/rollout decisions belong to the project, not this workflow.
Paradigm provenance: distilled from two complete campaigns on different stacks (a native C++ toolchain: 29.4s → 6.7s workload, -77%, byte-identical outputs; a large web rich-text editor: -27% commit time / -31% render volume / -34% memory, plus a multi-year user-jank attribution closed in four paths). The stages below are the stack-agnostic skeleton both campaigns followed.
Layered architecture
| Layer |
Lives in |
Changes when |
| Paradigm + evidence disciplines (this file) |
SKILL.md |
Rarely — behavioral contract, versioned deliberately |
| Project attribution/optimization skills |
The project's agent-skill directory (code-insight, code-optimizer) |
Every campaign — seeded from the corpus, evolved from campaign lessons |
| Stack corpus (seed templates + evidence case archive) |
reference.md |
Occasionally — stack chapters and cases refresh |
The paradigm is durable; the project skills compound with every campaign (that is where stack and project knowledge lives); the corpus is only the seed and needs occasional refresh. Keep perishable content out of this file.
Trigger Recognition
Trigger words (each enters the workflow; with 「trigger + colon + space + description」 form, enters the named stage directly — colon/space punctuation is language-agnostic):
- 「性能分析」/「性能问题」/「卡顿」/「很慢」 or English equivalents ("performance issue", "it's slow", "jank") → enter at Stage 1
- 「性能证据」 → Stage 1: Benchmark & Evidence
- 「性能定位」/「性能深入」 → Stage 2: Locate the Bottleneck (「性能深入」 continues/deepens Stage 2)
- 「性能假设」 → Stage 3: Hypothesize the Root Cause
- 「性能监控」 → Stage 4: Build Toggleable Monitoring
- 「性能优化」 → Stage 5: Optimize
- 「性能验证」 → Stage 6: A/B Verify
- 「前端性能」/「前端性能优化」/「Electron 性能」 → Stage 1, with the frontend corpus in reference.md as working knowledge until the project's
code-insight/code-optimizer skills are seeded and mature
- 「伪影排查」/「口径校准」/「设备画像」 → evidence-gate mode: audit the suspect metric against the disciplines below before it drives any decision
Performance-related logs or a profile handed over for analysis also enter at Stage 1 or 2.
General Principles
先建基准再动刀,证据过闸才定罪,链路归因一锤定音,一轮一个目标,A/B 交叉说了算,负结果也留痕。 (Build the benchmark before cutting; convict only through the evidence gate; attribute along the full chain; one target per iteration; the A/B cross-run verdict rules; negative results leave traces too.)
- Data-driven: no conclusion precedes its measurement. No reproduction path or analyzable data yet → the first task is building one (Stage 1), not hypothesizing.
- Evidence-gated: every metric that feeds a decision must first pass the Evidence Validity Disciplines (in-file section below). Non-decision-grade numbers may inform, never convict.
- Single variable, reproducible: each hypothesis resolvable to yes/no with existing data or minimal targeted instrumentation; each optimization touches exactly one root-cause point so its benefit is attributable; results reproducible and falsifiable — correlation is not causation.
- Full-chain, top-down: from the user-perceived chain (macro) to the hotspot (micro); identify where it is slow (time/resource share), then who triggers it and under what conditions. Avoid blind-men-and-elephant local analysis.
- Production caliber & device profile: acceptance numbers come from production-caliber builds; conviction-grade conclusions come from device-profile-calibrated runs (CPU-throttle matrix), not from high-end developer machines alone.
- No premature optimization: optimize only problems that are measured, user-affecting, and over threshold. Preventive optimization without data adds complexity for nothing.
- ⚠️ Ask proactively: follow
clarifying-question-discipline — one question per turn, multi-round until clear, clarify before answering.
Stage Flow
Forward: evidence → locate → hypothesize → (monitor) → optimize → verify, iterating optimize↔verify until the target is met or cost-effectiveness runs out.
Common jumps:
- Stage 1 lacks data and monitoring must be built first → Stage 4, then back to Stage 1.
- Stage 2's data already pins the bottleneck → skip Stage 3, go to Stage 4/5.
- Stage 6 refutes the hypothesis → back to Stage 2/3; optimization fell short → back to Stage 5.
- Intermittent issue hard to capture → prioritize Stage 4 long-term monitoring, return when it reproduces.
Evidence Validity Disciplines
Hard gate: a performance conclusion may drive an optimization decision only after passing these checks. The traps fall into four classes — measurement artifacts (the environment or tool distorts the number), caliber pollution (the number is real but measures something else), device-profile mismatch (true, but only on machines nobody complains about), and comparison environment-state invalidity (the A/B verdict itself was produced in a polluted environment). Full anonymized case archive with real numbers: reference.md Part 4.
| # |
Discipline |
One-line rule |
| 1 |
Environment-throttling artifacts |
Frame/scheduling-class metrics from a controlled runtime (headless / occluded / backgrounded) are invalid until proven otherwise — background throttling can clamp frame callbacks by orders of magnitude and focus emulation does not lift it; detect by sampling the executor during the suspect window (idle-dominant ⇒ artifact); measure same-task instead (stimulus and measurement in one scheduling unit, so the runtime cannot defer work in between) |
| 2 |
Monitor self-pollution |
Instrumented builds can differ several-fold from production (monitor overhead + unoptimized code); dev caliber is for relative A/B trends only — optimization decisions use production caliber; on conflict with runtime-native metrics, the runtime wins |
| 3 |
Framework counter ambiguity |
Audit any framework-internal statistic on a small scale before trusting it (cross-reconcile independent counts against a native metric); magnitude contradiction means the counter is the artifact — counters are trend signals, never conviction evidence |
| 4 |
Device-profile calibration |
Conviction-grade conclusions need a CPU-throttle matrix (e.g. 1x/8x/20x) × path × scale; an unthrottled "innocent" verdict is invalid for low-end users — one workload can yield three verdicts across cells |
| 5 |
Input-event authenticity |
Every synthetic input load must verify the observable state delta (produced change == intended change); synthetic key/scroll events that bypass the product's real input pipeline are void regardless of driver-reported success |
| 6 |
Instrumentation toggle lifecycle |
Toggles read at load time must be injected before product scripts load (via the debugging protocol's pre-load injection capability); measurement spans ended by a deferred callback inherit environment throttling (discipline 1) — phase conclusions use synchronous spans plus native long-work counters |
| 7 |
Single-sample extrapolation ban |
Developer-machine data is not a user profile; negative-ROI conclusions need user-profile evidence (aggregated telemetry / support feedback / field data) — one account cannot extrapolate |
| 8 |
Ultimate control experiment |
When profilers show no code hotspot (runtime internals dominant), clone the live scene into a pure static copy (same environment, zero product logic) and run the same load under the same conditions: copy ≈ original ⇒ bulk is the physical cost of content scale × environment, and the optimization direction shifts to cutting that base cost; the difference is the product-code margin — the ceiling of code-level optimization; ablation rider: "mechanism exists ≠ mechanism works" |
| 9 |
Negative results leave traces |
Mark contaminated benchmark-log rows with invalidation warnings (what/why/correct caliber); exclusion records keep later readers from re-walking dead ends or citing bad numbers |
| 10 |
Comparison environment-state validity |
Interleaved A/B assumes both arms see the same environment — after code switching, hot-reload state (mixed old/new modules, duplicated singletons, stale registrations) systematically pollutes one arm; changes touching structural units (modules/singleton topology) require an environment reset (restart / hard refresh) between arms before the judge's verdict counts |
Gate rule: for any metric, if the discipline covering its trap class is unresolved, the metric is not decision-grade — it may appear as trend-only context but must not drive optimization choices, priorities, or pass/fail verdicts.
Stage 1: Benchmark & Evidence (性能证据)
Goal
Turn a vague "it's laggy" into a reproducible, standardized, logged workload with a quantified baseline and a target/red-line — not a one-off manual repro. If a benchmark harness already exists, run it; if not, building a minimal one is part of this stage, because every later stage depends on repeatable numbers.
Information to clarify
- Symptom: which action (click/scroll/type/open/IME…), what "slow" looks like (jank/blank/spinner/unresponsive), quantified where possible; pin the analysis boundary (start and end of the problem).
- Data available: existing logs/profiles/instrumentation? If none, determine in what environment, with what method, data can be captured.
- Reproduction: always vs intermittent; requirements on data volume / device class / duration.
Benchmark harness contract (when building one)
- Standardized workloads, planned from a scenario inventory: first build or read the project's user-scenario inventory (the full set of real usage scenarios and their coverage state — file it next to the harness, e.g.
SCENARIOS.md), then plan scripted loads to close its gaps (open × scale, input × chars, scroll × rounds, switch, session-long editing, IME, paste, …). Each load is driven through real input paths (discipline 5) and verifiable by content delta.
- Long-session degradation is its own problem class: short sessions expose single-operation cost; continuous editing / note-switching / history growth expose accumulated degradation (memory creep, latency-trend rise, undo-history bloat). Cover it with dedicated loads (session / switch / history class) and analyze by trend slope and inflection point, not single-run numbers.
- Probe-script pattern: every recurring attribution question is sedimented as a reusable probe script under the harness (naming convention
probe-* — profiler sampling, phase-split timing, counter audits, throttle-matrix drivers, …). Pipeline steps in the project's code-insight invoke probes instead of ad-hoc scripting; the first campaign seeds the initial probe set, later campaigns extend it.
- Automated capture: metric collection wired once, reused every run — not manual copy-paste. Console/log parsing and structured JSON archives preferred.
- Baseline first: record the pre-optimization baseline before any change; every later claim is a comparison against it.
- Benchmark log: an append-only file (e.g.
BENCHMARK.md) at repo root recording every run: date, commit, workload, scale, key metrics, note. This log is the campaign's memory — verdicts, retractions, and invalidations all land here (Stage 6).
- A/B judge: build or reuse a cross-run statistical judge (see Stage 6) so "did it improve" is never answered by eyeballing two numbers.
Evidence gate (before any number leaves this stage)
Clear the in-file disciplines 1 (throttling artifacts), 2 (monitor self-pollution), 5 (input authenticity), 6 (toggle lifecycle) for every metric you plan to carry forward. Numbers failing the gate are marked trend-only.
Output
- What data is available / missing; if missing, the exact capture action (who runs what, what gets captured).
- Recommended output: a structured problem definition — symptom (quantified), reproduction conditions, analysis boundary, baseline, target threshold/red line.
- Benchmark harness status: existing / built-this-stage / deferred-with-reason.
Stage 2: Locate the Bottleneck (性能定位)
Goal
Find the anomalies in the data (who spent how much time/resources, when), trace the full trigger chain, and narrow to 1-2 core segments — with every load-bearing number already evidence-gated.
Project attribution skill (code-insight)
The stack/project-specific attribution pipeline lives as a project-level skill, created and continuously improved by this workflow — the paradigm file stays generic.
- Probe at stage entry: look for the project's
code-insight skill (in the project's conventional agent-skill directory). Found → run its pipeline for this stage's localization work, and note any gap it fails to cover (that gap is this campaign's improvement candidate). Not found (first campaign) → seed it as a step-by-step pipeline: attribution-pipeline template from reference.md Part 5 (JS stack today), adapted with this run's project discoveries (tool paths, workload specifics, known pitfalls, initial probe-* scripts under the harness); Parts 1-2 serve as knowledge attachments per pipeline step; run the specialist-perspective pass over the seeded content before landing. Manual mode confirms the seed location; auto mode uses the project's convention.
- The seeded skill is a standing project asset: later sessions and other agents on the project can invoke it directly, independent of this workflow.
Analysis approach
- Full-chain topology: segment the path from user action to problem end (code execution, system calls, network/storage), no gaps, no overlap; each segment independently timeable.
- Two-dimensional capture: time (per-segment duration/share) + resources (CPU/memory/IO/network). Neither skipped. Resource utilization >70% is a common alert line — beyond it, response time rises non-linearly.
- Initial screen: rank segments by time-share (e.g. >20% = high-cost); flag resource anomalies (saturation, sustained growth, error rate); rule out low-cost + resource-normal segments.
Attribution techniques (pick by what the data shows)
- Text logs: filter by keyword/duration/error code, read snippets + stacks.
- Profiles: read the wide bars / high-share regions first, drill to function/component. Editor/web-app four-bucket split when Rendering dominates: framework commit / style insertion / layout / paint — their fixes differ entirely; do not read "Rendering" as one blob.
- Forced-reflow reading (write→read patterns; rich-text editors: DOM mutation followed immediately by selection-boundary reads is the classic #1 source).
- No JS hotspot (
(program)/(idle) dominant)? → discipline 8's static-copy control experiment decides: product-code cost vs DOM-scale physical cost. This single experiment can end a multi-year argument.
- Known-pattern quick search: when
known-issue-research's triggers fire, load it and run its performance-pattern variant before deeper custom analysis.
Evidence gate
Disciplines 3 (counter audits — audit any framework-internal statistic before use) and 8 (control experiment) apply here.
Output
- Anomaly summary (slow/high-volume/high-frequency + location); causal chain "action → … → bottleneck" in a sentence or diagram.
- 1-3 preliminary hypotheses with confirming/refuting evidence stated; core bottleneck segment list (1-2) with shares.
Stage 3: Hypothesize the Root Cause (性能假设)
Goal
Distill anomalies into verifiable, falsifiable root-cause hypotheses, classified against common patterns; ranked by user impact × verification cost.
Reasoning references
- USE method (resource bottlenecks): utilization / saturation / errors.
- RED method (execution/request bottlenecks): rate / errors / duration.
- Common patterns table (response-scope-too-broad, unbatched updates, high-frequency triggers, backlog-fires-at-once, resource leak, synchronous blocking, redundant computation): generic forms in this file's paradigm; concrete frontend manifestations in reference.md.
Evidence gate
Discipline 7 (single-sample extrapolation ban — "users don't hit this" needs user-profile evidence) and discipline 4 (throttle matrix — hypotheses about user-perceived jank are validated on calibrated cells) apply here.
Output
- The 1-2 most likely hypotheses, each resolvable to yes/no ("is it a full re-render?" is answerable; "the code is badly written" is not); ranked; with verification method (existing data, or which monitoring points from Stage 4).
Stage 4: Build Toggleable Monitoring (性能监控)
Goal
When existing data cannot verify the hypothesis, add toggleable, production-grade observability on the critical path — permanent code, gated at runtime.
Design principles
- Toggle-controlled (env var / config / feature flag / debug switch): off in production = zero output, zero sampling, negligible overhead; on = structured output aligned with existing logs.
- Permanent, not temporary: a standing capability, not instrumentation to rip out later.
- Alignable: stable timestamps + location identifiers, joinable with existing logs/profiles on one timeline.
- Just enough: location + timestamp + the few key variables that confirm/refute the hypothesis; reuse the project's log format.
- Toggle lifecycle: toggles read at module load must be injected before page scripts (discipline 6).
Point selection
Direct trigger point first (the state update / request fire / recompute entry), then intermediate chain nodes (call order/frequency), then the expensive computation's entry/exit (per-call duration/count).
Output
Monitoring-point list (file:line or function, purpose, toggle name) + the user action to enable/reproduce/capture. Root cause already confirmable → skip to Stage 5.
Stage 5: Optimize (性能优化)
This stage and Stage 6 execute as the iteration loop (see "Iteration loop"); the environment gate is probed at this stage's entry.
Goal
Implement the change that eliminates/mitigates the confirmed bottleneck — one root-cause target per iteration, sized by impact.
Project optimization skill (code-optimizer)
Same lifecycle as code-insight: probe the project's code-optimizer skill at stage entry; found → follow its optimization pipeline for this target and note gaps; not found → seed it as a step-by-step pipeline from the Part 5 template (JS stack) plus this run's discoveries. The seed MUST include a deep-attribution step that delegates to the project's code-insight (the two are cooperating pipelines, not isolated tools). It accumulates this project's validated optimization patterns and rejected attempts, so every campaign starts smarter.
Principles
- Fix the root cause, not the symptom: the change maps to the Stage 3 pattern (narrow the scope, batch, throttle, cache, move off-thread…), not a generic "make it faster".
- Technology-selection decisions escalate to the user: introducing a new dependency, replacing a data structure, or changing an allocation/memory strategy → present the candidate options with trade-offs (performance / portability / maintenance) and let the user pick — the agent does not decide unilaterally.
- One target per iteration: every commit optimizes exactly one thing, keeps the change reviewable and revertible, and makes Stage 6's benefit attribution unambiguous. Multiple good ideas queue as separate iterations.
- Layer priority (high → low): business logic → application code → framework/dependency → system/hardware; prefer upper layers and "low change cost, high payoff" moves.
- Time-share priority: optimize the highest-share segments first; a <10% segment improved 100x barely moves the total (Amdahl).
- Stability: no semantic change, no functional bugs, no new performance side effects.
- No gain → revert: Stage 6 rejects the change → revert it (the benchmark log keeps the negative row), do not stack a second speculative change on top.
Output
Change list (file, location, summary) + suggested verification scenario/metrics aligned with Stage 4 monitoring, for Stage 6.
Stage 6: A/B Verify (性能验证)
This stage normally runs inside the iteration loop (see "Iteration loop"); a single pass is only the explicit user-requested exception.
Goal
- Render a yes/no verdict on the hypothesis.
- If Stage 5 changed code: prove the optimization worked statistically, at production caliber, without side effects — or revert.
Evidence gate
Disciplines 2 (production-caliber acceptance), 4 (user-jank verdicts from throttle-matrix cells), 9 (rejections and invalidations logged), and 10 (environment reset between arms when structural units changed) apply to every verdict this stage produces — including single-pass runs.
A/B cross-run statistical judge
- Keep the previous commit's build as Baseline (snapshot keyed by commit hash).
- Alternate runs B₁ A₁ B₂ A₂ B₃ A₃ (Baseline, New, interleaved) so system-load noise hits both sides roughly equally.
- Accept an improvement only if
avg_B − avg_A > max(stdev_B, stdev_A) (the acceptance rule; referenced elsewhere, stated only here). Single runs and minimum-of-N are not verdicts (min-of-N chases idle moments; single runs chase noise).
- Before judging, honor discipline 10: structural changes ⇒ reset the environment between arms.
- Intentional divergence from the source paradigm (recorded): the source accepts "certainly correct" micro-optimizations even within noise; this workflow keeps the hard statistical gate for agent execution — agents systematically overestimate "certainly correct". Restoring the exception would require static equivalence proof plus user confirmation.
- Why it works: alternating runs experience the same machine states, so the difference is far more stable than absolute numbers — no machine lockdown, core pinning, or service-killing required.
Verification checklist
- Hypothesis verdict: confirmed / refuted / uncertain (+ what's missing, next monitoring or re-analysis).
- Effectiveness: same repro path, before/after key metrics, pass criteria stated up front.
- Regression: functional correctness (normal/edge/peak) intact — for optimization of transformation pipelines, output-equivalence checks (e.g. byte-identical) are the strongest form.
- Side effects: no secondary performance issues (e.g. latency fixed but memory climbing).
- Caliber: acceptance numbers from production-caliber builds (discipline 2); user-jank verdicts from device-profile-calibrated cells (discipline 4).
- Sediment: append the run to the benchmark log — including rejections (discipline 9: no-gain and artifact rows are recorded with reason, keeping others from re-walking dead ends or citing bad numbers).
Stop condition
Every hypothesis verified, targets met — or remaining bottlenecks' cost-effectiveness too low (change cost ≫ payoff). This is the campaign-level stop; the loop section's stop conditions govern round-level termination. Then optionally fold key metrics into standing monitoring/CI gates.
Iteration loop (environment-gated, mandatory for Stages 5-6)
Optimize (Stage 5) and A/B verify (Stage 6) execute as a repeating loop mounted on a real environment loop runner — never as one-off passes, and never as a self-invented prose loop. The compounding gains come from sustained rounds; a manual one-pass run stops at the first visible hotspot and silently loses the paradigm's core value.
Environment gate (at Stage 5 entry)
Probe the environment for a loop capability — an installed loop runner (ralph-loop-style runner, /loop, goal-driven long-run, or any mechanism that auto-continues the agent across rounds with per-round context management):
- Found → mount the loop body below on it and enter the loop. The runner drives round cadence and continuation; this workflow supplies what each round contains and when to stop.
- Not found → stop optimization execution. Report the analysis stages' findings (they remain valid and deliverable), and state the exact blocker: install a loop runner, then re-enter at Stage 5. Do not degrade to a single manual pass — an honest abort beats a fake loop.
This gate is a runtime strong dependency on the environment (not a frontmatter dependency — loop runners are environment plugins, not installable skills).
Loop body (each round, in order)
- Profile — re-acquire hotspots fresh this round; last round's list is stale input.
- Pick exactly one target — top hotspot by user impact × time-share; queue the rest.
- Optimize that target — per the Optimize stage (root-cause-mapped, revertible).
- A/B judge — Stage 6's acceptance rule decides accept/revert; honor discipline 10 before judging (environment reset between arms when structural units changed); rejected → revert this round.
- Correctness gate — full test suite / output-equivalence before commit; never commit red.
- Commit + snapshot + log — one commit per round; snapshot the accepted build as next round's baseline (keyed by commit hash); append the round to the benchmark log, accepted or rejected, with reason.
Stop conditions (any one)
- 5 consecutive no-gain rounds — the optimization set has converged.
- Target met — stage-1 threshold/red line reached and verified.
- ROI exhausted — remaining bottlenecks' gain no longer justifies change cost.
On stop: summarize rounds accepted/rejected, total measured gain vs baseline, remaining bottlenecks with ROI assessment.
Context discipline (long loops die of context bloat)
Each round persists its outcome to the benchmark log and carries forward only: the round summary, the baseline-snapshot pointer, and the stop-condition counters. Raw profiles and intermediate data stay in the archive files — they are retrieved on demand, never carried in full across rounds.
Skill evolution (at every stop; or every ~5 rounds in long loops)
Skills are code too — the project's code-insight / code-optimizer are themselves artifacts of the paradigm, improved by use. At each stop condition:
- Fold this campaign's validated lessons into the two skills: attribution patterns that worked, optimizations that failed (with the rejection data), stack/project-specific pitfalls discovered.
- The benchmark log's invalidation rows and negative results are the primary feed — they encode exactly what the skills got wrong or missed.
- Review the update from the stack's specialist perspectives (e.g. language semantics / runtime & framework / hardware & platform) before landing: lessons gathered mid-campaign can contradict each other or the skill's existing content — correct the inconsistencies, then write.
- Update the skills in place; the next campaign starts smarter. This is where the paradigm compounds across campaigns, not just within one.
Output detail level (adaptive)
- Simple problem, ample data: condense to "anomaly + causal chain + verdict".
- Complex/multi-module: brief per-stage outputs, key snippets attached.
- Stack-specific knowledge (framework versions, thresholds, patterns, tool tables): fold in from reference.md conversationally — never hardcode stack specifics into this file's paradigm.
1---2name: perf-optimize-workflow3description: Performance optimization paradigm workflow, proven across stacks: benchmark harness → evidence-validity gate (ten in-file disciplines: measurement artifacts, caliber pollution, device/profile mismatch, comparison environment state) → attribution → one-target-per-iteration optimization → A/B cross-run statistical verification → benchmark-log sediment, on an environment-gated iteration loop (no loop runner ⇒ honest stop). Seeds per-project code-insight/code-optimizer skills with probe scripts and evolves them every campaign (stack corpus in reference.md). Triggers — 「性能分析」「性能证据」「性能定位」「性能假设」「性能监控」「性能优化」「性能验证」「性能深入」「性能问题」「卡顿」「很慢」「前端性能」「Electron 性能」「伪影排查」「口径校准」「设备画像」 / performance analysis, perf evidence, locate bottleneck, perf optimization, perf verification, measurement artifact check. Do NOT use for non-performance bugs (solve-workflow) or trivial single-line edits.4---56# Performance Optimization Workflow78> Strong dependencies (frontmatter): `clarifying-question-discipline` (one question per turn), `known-issue-research` (known performance-pattern quick search at the locate stage). If any is missing, abort and print: `npx skills add FuDesign2008/open-skills -g --skill '*' --yes`.9>10> Runtime strong dependency (environment, not frontmatter): a loop-runner capability for the Stages 5-6 iteration loop — probed at Stage 5 entry; missing means optimization execution stops (see "Iteration loop").1112## Scope1314This workflow owns the full performance optimization paradigm: **build a reproducible benchmark, gate every conclusion through evidence-validity checks, attribute the bottleneck along the full chain, optimize one target per iteration, verify by A/B cross-run statistics, and sediment results in a benchmark log** — the optimize↔verify cycle running on an environment-provided iteration loop (honest stop when absent). Its per-project deliverables: the benchmark log + harness, and two **evolving project-level skills** (`code-insight` for attribution, `code-optimizer` for optimization) that carry the stack/project knowledge and improve with every campaign.1516It answers: who triggers what expensive operation, under which conditions, on which devices — and then eliminates it measurably. Shipping/rollout decisions belong to the project, not this workflow.1718**Paradigm provenance**: distilled from two complete campaigns on different stacks (a native C++ toolchain: 29.4s → 6.7s workload, -77%, byte-identical outputs; a large web rich-text editor: -27% commit time / -31% render volume / -34% memory, plus a multi-year user-jank attribution closed in four paths). The stages below are the stack-agnostic skeleton both campaigns followed.1920## Layered architecture2122| Layer | Lives in | Changes when |23|-------|----------|--------------|24| Paradigm + evidence disciplines (this file) | `SKILL.md` | Rarely — behavioral contract, versioned deliberately |25| Project attribution/optimization skills | The project's agent-skill directory (`code-insight`, `code-optimizer`) | Every campaign — seeded from the corpus, evolved from campaign lessons |26| Stack corpus (seed templates + evidence case archive) | [reference.md](reference.md) | Occasionally — stack chapters and cases refresh |2728The paradigm is durable; the **project skills compound with every campaign** (that is where stack and project knowledge lives); the corpus is only the seed and needs occasional refresh. Keep perishable content out of this file.2930## Trigger Recognition3132Trigger words (each enters the workflow; with 「trigger + colon + space + description」 form, enters the named stage directly — colon/space punctuation is language-agnostic):3334- **「性能分析」/「性能问题」/「卡顿」/「很慢」** or English equivalents ("performance issue", "it's slow", "jank") → enter at Stage 135- **「性能证据」** → Stage 1: Benchmark & Evidence36- **「性能定位」/「性能深入」** → Stage 2: Locate the Bottleneck (「性能深入」 continues/deepens Stage 2)37- **「性能假设」** → Stage 3: Hypothesize the Root Cause38- **「性能监控」** → Stage 4: Build Toggleable Monitoring39- **「性能优化」** → Stage 5: Optimize40- **「性能验证」** → Stage 6: A/B Verify41- **「前端性能」/「前端性能优化」/「Electron 性能」** → Stage 1, with the frontend corpus in [reference.md](reference.md) as working knowledge until the project's `code-insight`/`code-optimizer` skills are seeded and mature42- **「伪影排查」/「口径校准」/「设备画像」** → evidence-gate mode: audit the suspect metric against the disciplines below before it drives any decision4344Performance-related logs or a profile handed over for analysis also enter at Stage 1 or 2.4546## General Principles4748**先建基准再动刀,证据过闸才定罪,链路归因一锤定音,一轮一个目标,A/B 交叉说了算,负结果也留痕。** (Build the benchmark before cutting; convict only through the evidence gate; attribute along the full chain; one target per iteration; the A/B cross-run verdict rules; negative results leave traces too.)49501. **Data-driven**: no conclusion precedes its measurement. No reproduction path or analyzable data yet → the first task is building one (Stage 1), not hypothesizing.512. **Evidence-gated**: every metric that feeds a decision must first pass the Evidence Validity Disciplines (in-file section below). Non-decision-grade numbers may inform, never convict.523. **Single variable, reproducible**: each hypothesis resolvable to yes/no with existing data or minimal targeted instrumentation; each optimization touches exactly one root-cause point so its benefit is attributable; results reproducible and falsifiable — correlation is not causation.534. **Full-chain, top-down**: from the user-perceived chain (macro) to the hotspot (micro); identify *where* it is slow (time/resource share), then *who* triggers it and *under what conditions*. Avoid blind-men-and-elephant local analysis.545. **Production caliber & device profile**: acceptance numbers come from production-caliber builds; conviction-grade conclusions come from device-profile-calibrated runs (CPU-throttle matrix), not from high-end developer machines alone.556. **No premature optimization**: optimize only problems that are measured, user-affecting, and over threshold. Preventive optimization without data adds complexity for nothing.5657- **⚠️ Ask proactively**: follow `clarifying-question-discipline` — one question per turn, multi-round until clear, clarify before answering.5859## Stage Flow6061Forward: **evidence → locate → hypothesize → (monitor) → optimize → verify**, iterating optimize↔verify until the target is met or cost-effectiveness runs out.6263Common jumps:6465- Stage 1 lacks data and monitoring must be built first → Stage 4, then back to Stage 1.66- Stage 2's data already pins the bottleneck → skip Stage 3, go to Stage 4/5.67- Stage 6 refutes the hypothesis → back to Stage 2/3; optimization fell short → back to Stage 5.68- Intermittent issue hard to capture → prioritize Stage 4 long-term monitoring, return when it reproduces.6970---7172## Evidence Validity Disciplines7374> Hard gate: a performance conclusion may drive an optimization decision only after passing these checks. The traps fall into four classes — **measurement artifacts** (the environment or tool distorts the number), **caliber pollution** (the number is real but measures something else), **device-profile mismatch** (true, but only on machines nobody complains about), and **comparison environment-state invalidity** (the A/B verdict itself was produced in a polluted environment). Full anonymized case archive with real numbers: [reference.md](reference.md) Part 4.7576| # | Discipline | One-line rule |77|---|-----------|---------------|78| 1 | Environment-throttling artifacts | Frame/scheduling-class metrics from a controlled runtime (headless / occluded / backgrounded) are invalid until proven otherwise — background throttling can clamp frame callbacks by orders of magnitude and focus emulation does not lift it; detect by sampling the executor during the suspect window (idle-dominant ⇒ artifact); measure same-task instead (stimulus and measurement in one scheduling unit, so the runtime cannot defer work in between) |79| 2 | Monitor self-pollution | Instrumented builds can differ several-fold from production (monitor overhead + unoptimized code); dev caliber is for relative A/B trends only — optimization decisions use production caliber; on conflict with runtime-native metrics, the runtime wins |80| 3 | Framework counter ambiguity | Audit any framework-internal statistic on a small scale before trusting it (cross-reconcile independent counts against a native metric); magnitude contradiction means the counter is the artifact — counters are trend signals, never conviction evidence |81| 4 | Device-profile calibration | Conviction-grade conclusions need a CPU-throttle matrix (e.g. 1x/8x/20x) × path × scale; an unthrottled "innocent" verdict is invalid for low-end users — one workload can yield three verdicts across cells |82| 5 | Input-event authenticity | Every synthetic input load must verify the observable state delta (produced change == intended change); synthetic key/scroll events that bypass the product's real input pipeline are void regardless of driver-reported success |83| 6 | Instrumentation toggle lifecycle | Toggles read at load time must be injected before product scripts load (via the debugging protocol's pre-load injection capability); measurement spans ended by a deferred callback inherit environment throttling (discipline 1) — phase conclusions use synchronous spans plus native long-work counters |84| 7 | Single-sample extrapolation ban | Developer-machine data is not a user profile; negative-ROI conclusions need user-profile evidence (aggregated telemetry / support feedback / field data) — one account cannot extrapolate |85| 8 | Ultimate control experiment | When profilers show no code hotspot (runtime internals dominant), clone the live scene into a pure static copy (same environment, zero product logic) and run the same load under the same conditions: copy ≈ original ⇒ bulk is the physical cost of content scale × environment, and the optimization direction shifts to cutting that base cost; the difference is the product-code margin — the ceiling of code-level optimization; ablation rider: "mechanism exists ≠ mechanism works" |86| 9 | Negative results leave traces | Mark contaminated benchmark-log rows with invalidation warnings (what/why/correct caliber); exclusion records keep later readers from re-walking dead ends or citing bad numbers |87| 10 | Comparison environment-state validity | Interleaved A/B assumes both arms see the same environment — after code switching, hot-reload state (mixed old/new modules, duplicated singletons, stale registrations) systematically pollutes one arm; changes touching structural units (modules/singleton topology) require an environment reset (restart / hard refresh) between arms before the judge's verdict counts |8889**Gate rule**: for any metric, if the discipline covering its trap class is unresolved, the metric is **not decision-grade** — it may appear as trend-only context but must not drive optimization choices, priorities, or pass/fail verdicts.9091---9293## Stage 1: Benchmark & Evidence (性能证据)9495### Goal9697Turn a vague "it's laggy" into a **reproducible, standardized, logged workload** with a quantified baseline and a target/red-line — not a one-off manual repro. If a benchmark harness already exists, run it; if not, building a minimal one is part of this stage, because every later stage depends on repeatable numbers.9899### Information to clarify100101- **Symptom**: which action (click/scroll/type/open/IME…), what "slow" looks like (jank/blank/spinner/unresponsive), **quantified** where possible; pin the analysis boundary (start and end of the problem).102- **Data available**: existing logs/profiles/instrumentation? If none, determine in what environment, with what method, data can be captured.103- **Reproduction**: always vs intermittent; requirements on data volume / device class / duration.104105### Benchmark harness contract (when building one)106107- **Standardized workloads, planned from a scenario inventory**: first build or read the project's **user-scenario inventory** (the full set of real usage scenarios and their coverage state — file it next to the harness, e.g. `SCENARIOS.md`), then plan scripted loads to close its gaps (open × scale, input × chars, scroll × rounds, switch, session-long editing, IME, paste, …). Each load is driven through **real input paths** (discipline 5) and verifiable by content delta.108- **Long-session degradation is its own problem class**: short sessions expose single-operation cost; continuous editing / note-switching / history growth expose accumulated degradation (memory creep, latency-trend rise, undo-history bloat). Cover it with dedicated loads (session / switch / history class) and analyze by **trend slope and inflection point**, not single-run numbers.109- **Probe-script pattern**: every recurring attribution question is sedimented as a reusable probe script under the harness (naming convention `probe-*` — profiler sampling, phase-split timing, counter audits, throttle-matrix drivers, …). Pipeline steps in the project's `code-insight` invoke probes instead of ad-hoc scripting; the first campaign seeds the initial probe set, later campaigns extend it.110- **Automated capture**: metric collection wired once, reused every run — not manual copy-paste. Console/log parsing and structured JSON archives preferred.111- **Baseline first**: record the pre-optimization baseline before any change; every later claim is a comparison against it.112- **Benchmark log**: an append-only file (e.g. `BENCHMARK.md`) at repo root recording every run: date, commit, workload, scale, key metrics, note. This log is the campaign's memory — verdicts, retractions, and invalidations all land here (Stage 6).113- **A/B judge**: build or reuse a cross-run statistical judge (see Stage 6) so "did it improve" is never answered by eyeballing two numbers.114115### Evidence gate (before any number leaves this stage)116117Clear the in-file disciplines **1 (throttling artifacts), 2 (monitor self-pollution), 5 (input authenticity), 6 (toggle lifecycle)** for every metric you plan to carry forward. Numbers failing the gate are marked trend-only.118119### Output120121- What data is available / missing; if missing, the exact capture action (who runs what, what gets captured).122- Recommended output: a structured problem definition — symptom (quantified), reproduction conditions, analysis boundary, baseline, target threshold/red line.123- Benchmark harness status: existing / built-this-stage / deferred-with-reason.124125---126127## Stage 2: Locate the Bottleneck (性能定位)128129### Goal130131Find the anomalies in the data (who spent how much time/resources, when), trace the full trigger chain, and narrow to 1-2 core segments — with every load-bearing number already evidence-gated.132133### Project attribution skill (`code-insight`)134135The stack/project-specific attribution pipeline lives as a **project-level skill**, created and continuously improved by this workflow — the paradigm file stays generic.136137- **Probe at stage entry**: look for the project's `code-insight` skill (in the project's conventional agent-skill directory). Found → run its pipeline for this stage's localization work, and note any gap it fails to cover (that gap is this campaign's improvement candidate). Not found (first campaign) → **seed it as a step-by-step pipeline**: attribution-pipeline template from [reference.md](reference.md) Part 5 (JS stack today), adapted with this run's project discoveries (tool paths, workload specifics, known pitfalls, initial `probe-*` scripts under the harness); Parts 1-2 serve as knowledge attachments per pipeline step; run the specialist-perspective pass over the seeded content before landing. Manual mode confirms the seed location; auto mode uses the project's convention.138- The seeded skill is a standing project asset: later sessions and other agents on the project can invoke it directly, independent of this workflow.139140### Analysis approach1411421. **Full-chain topology**: segment the path from user action to problem end (code execution, system calls, network/storage), no gaps, no overlap; each segment independently timeable.1432. **Two-dimensional capture**: time (per-segment duration/share) + resources (CPU/memory/IO/network). Neither skipped. Resource utilization >70% is a common alert line — beyond it, response time rises non-linearly.1443. **Initial screen**: rank segments by time-share (e.g. >20% = high-cost); flag resource anomalies (saturation, sustained growth, error rate); rule out low-cost + resource-normal segments.145146### Attribution techniques (pick by what the data shows)147148- **Text logs**: filter by keyword/duration/error code, read snippets + stacks.149- **Profiles**: read the wide bars / high-share regions first, drill to function/component. **Editor/web-app four-bucket split** when Rendering dominates: framework commit / style insertion / layout / paint — their fixes differ entirely; do not read "Rendering" as one blob.150- **Forced-reflow reading** (write→read patterns; rich-text editors: DOM mutation followed immediately by selection-boundary reads is the classic #1 source).151- **No JS hotspot** (`(program)`/`(idle)` dominant)? → discipline 8's static-copy control experiment decides: product-code cost vs DOM-scale physical cost. This single experiment can end a multi-year argument.152- **Known-pattern quick search**: when `known-issue-research`'s triggers fire, load it and run its performance-pattern variant before deeper custom analysis.153154### Evidence gate155156Disciplines **3 (counter audits — audit any framework-internal statistic before use)** and **8 (control experiment)** apply here.157158### Output159160- Anomaly summary (slow/high-volume/high-frequency + location); causal chain "action → … → bottleneck" in a sentence or diagram.161- 1-3 preliminary hypotheses with confirming/refuting evidence stated; core bottleneck segment list (1-2) with shares.162163---164165## Stage 3: Hypothesize the Root Cause (性能假设)166167### Goal168169Distill anomalies into **verifiable, falsifiable** root-cause hypotheses, classified against common patterns; ranked by user impact × verification cost.170171### Reasoning references172173- **USE method** (resource bottlenecks): utilization / saturation / errors.174- **RED method** (execution/request bottlenecks): rate / errors / duration.175- **Common patterns table** (response-scope-too-broad, unbatched updates, high-frequency triggers, backlog-fires-at-once, resource leak, synchronous blocking, redundant computation): generic forms in this file's paradigm; concrete frontend manifestations in [reference.md](reference.md).176177### Evidence gate178179Discipline **7 (single-sample extrapolation ban — "users don't hit this" needs user-profile evidence)** and discipline **4 (throttle matrix — hypotheses about user-perceived jank are validated on calibrated cells)** apply here.180181### Output182183- The 1-2 most likely hypotheses, each resolvable to yes/no ("is it a full re-render?" is answerable; "the code is badly written" is not); ranked; with verification method (existing data, or which monitoring points from Stage 4).184185---186187## Stage 4: Build Toggleable Monitoring (性能监控)188189### Goal190191When existing data cannot verify the hypothesis, add **toggleable, production-grade observability** on the critical path — permanent code, gated at runtime.192193### Design principles1941951. **Toggle-controlled** (env var / config / feature flag / debug switch): off in production = zero output, zero sampling, negligible overhead; on = structured output aligned with existing logs.1962. **Permanent, not temporary**: a standing capability, not instrumentation to rip out later.1973. **Alignable**: stable timestamps + location identifiers, joinable with existing logs/profiles on one timeline.1984. **Just enough**: location + timestamp + the few key variables that confirm/refute the hypothesis; reuse the project's log format.1995. **Toggle lifecycle**: toggles read at module load must be injected before page scripts (discipline 6).200201### Point selection202203Direct trigger point first (the state update / request fire / recompute entry), then intermediate chain nodes (call order/frequency), then the expensive computation's entry/exit (per-call duration/count).204205### Output206207Monitoring-point list (file:line or function, purpose, toggle name) + the user action to enable/reproduce/capture. Root cause already confirmable → skip to Stage 5.208209---210211## Stage 5: Optimize (性能优化)212213> This stage and Stage 6 execute as the iteration loop (see "Iteration loop"); the environment gate is probed at this stage's entry.214215### Goal216217Implement the change that eliminates/mitigates the confirmed bottleneck — **one root-cause target per iteration**, sized by impact.218219### Project optimization skill (`code-optimizer`)220221Same lifecycle as `code-insight`: probe the project's `code-optimizer` skill at stage entry; found → follow its optimization pipeline for this target and note gaps; not found → **seed it as a step-by-step pipeline** from the Part 5 template (JS stack) plus this run's discoveries. The seed MUST include a **deep-attribution step that delegates to the project's `code-insight`** (the two are cooperating pipelines, not isolated tools). It accumulates this project's validated optimization patterns and rejected attempts, so every campaign starts smarter.222223### Principles224225- **Fix the root cause, not the symptom**: the change maps to the Stage 3 pattern (narrow the scope, batch, throttle, cache, move off-thread…), not a generic "make it faster".226- **Technology-selection decisions escalate to the user**: introducing a new dependency, replacing a data structure, or changing an allocation/memory strategy → present the candidate options with trade-offs (performance / portability / maintenance) and let the user pick — the agent does not decide unilaterally.227- **One target per iteration**: every commit optimizes exactly one thing, keeps the change reviewable and revertible, and makes Stage 6's benefit attribution unambiguous. Multiple good ideas queue as separate iterations.228- **Layer priority** (high → low): business logic → application code → framework/dependency → system/hardware; prefer upper layers and "low change cost, high payoff" moves.229- **Time-share priority**: optimize the highest-share segments first; a <10% segment improved 100x barely moves the total (Amdahl).230- **Stability**: no semantic change, no functional bugs, no new performance side effects.231- **No gain → revert**: Stage 6 rejects the change → revert it (the benchmark log keeps the negative row), do not stack a second speculative change on top.232233### Output234235Change list (file, location, summary) + suggested verification scenario/metrics aligned with Stage 4 monitoring, for Stage 6.236237---238239## Stage 6: A/B Verify (性能验证)240241> This stage normally runs inside the iteration loop (see "Iteration loop"); a single pass is only the explicit user-requested exception.242243### Goal2442451. Render a yes/no verdict on the hypothesis.2462. If Stage 5 changed code: prove the optimization worked **statistically**, at production caliber, without side effects — or revert.247248### Evidence gate249250Disciplines **2 (production-caliber acceptance)**, **4 (user-jank verdicts from throttle-matrix cells)**, **9 (rejections and invalidations logged)**, and **10 (environment reset between arms when structural units changed)** apply to every verdict this stage produces — including single-pass runs.251252### A/B cross-run statistical judge253254- Keep the previous commit's build as Baseline (snapshot keyed by commit hash).255- Alternate runs **B₁ A₁ B₂ A₂ B₃ A₃** (Baseline, New, interleaved) so system-load noise hits both sides roughly equally.256- Accept an improvement **only if `avg_B − avg_A > max(stdev_B, stdev_A)`** (the acceptance rule; referenced elsewhere, stated only here). Single runs and minimum-of-N are not verdicts (min-of-N chases idle moments; single runs chase noise).257- Before judging, honor discipline 10: structural changes ⇒ reset the environment between arms.258- Intentional divergence from the source paradigm (recorded): the source accepts "certainly correct" micro-optimizations even within noise; this workflow keeps the hard statistical gate for agent execution — agents systematically overestimate "certainly correct". Restoring the exception would require static equivalence proof plus user confirmation.259- Why it works: alternating runs experience the same machine states, so the difference is far more stable than absolute numbers — no machine lockdown, core pinning, or service-killing required.260261### Verification checklist262263- **Hypothesis verdict**: confirmed / refuted / uncertain (+ what's missing, next monitoring or re-analysis).264- **Effectiveness**: same repro path, before/after key metrics, pass criteria stated up front.265- **Regression**: functional correctness (normal/edge/peak) intact — for optimization of transformation pipelines, output-equivalence checks (e.g. byte-identical) are the strongest form.266- **Side effects**: no secondary performance issues (e.g. latency fixed but memory climbing).267- **Caliber**: acceptance numbers from production-caliber builds (discipline 2); user-jank verdicts from device-profile-calibrated cells (discipline 4).268- **Sediment**: append the run to the benchmark log — including **rejections** (discipline 9: no-gain and artifact rows are recorded with reason, keeping others from re-walking dead ends or citing bad numbers).269270### Stop condition271272Every hypothesis verified, targets met — or remaining bottlenecks' cost-effectiveness too low (change cost ≫ payoff). This is the campaign-level stop; the loop section's stop conditions govern round-level termination. Then optionally fold key metrics into standing monitoring/CI gates.273274---275276## Iteration loop (environment-gated, mandatory for Stages 5-6)277278Optimize (Stage 5) and A/B verify (Stage 6) execute as a repeating loop **mounted on a real environment loop runner** — never as one-off passes, and never as a self-invented prose loop. The compounding gains come from sustained rounds; a manual one-pass run stops at the first visible hotspot and silently loses the paradigm's core value.279280### Environment gate (at Stage 5 entry)281282Probe the environment for a loop capability — an installed loop runner (ralph-loop-style runner, `/loop`, goal-driven long-run, or any mechanism that auto-continues the agent across rounds with per-round context management):283284- **Found** → mount the loop body below on it and enter the loop. The runner drives round cadence and continuation; this workflow supplies what each round contains and when to stop.285- **Not found** → **stop optimization execution**. Report the analysis stages' findings (they remain valid and deliverable), and state the exact blocker: install a loop runner, then re-enter at Stage 5. Do not degrade to a single manual pass — an honest abort beats a fake loop.286287This gate is a runtime strong dependency on the environment (not a frontmatter dependency — loop runners are environment plugins, not installable skills).288289### Loop body (each round, in order)2902911. **Profile** — re-acquire hotspots fresh this round; last round's list is stale input.2922. **Pick exactly one target** — top hotspot by user impact × time-share; queue the rest.2933. **Optimize that target** — per the Optimize stage (root-cause-mapped, revertible).2944. **A/B judge** — Stage 6's acceptance rule decides accept/revert; honor discipline 10 before judging (environment reset between arms when structural units changed); rejected → revert this round.2955. **Correctness gate** — full test suite / output-equivalence before commit; never commit red.2966. **Commit + snapshot + log** — one commit per round; snapshot the accepted build as next round's baseline (keyed by commit hash); append the round to the benchmark log, accepted or rejected, with reason.297298### Stop conditions (any one)299300- **5 consecutive no-gain rounds** — the optimization set has converged.301- **Target met** — stage-1 threshold/red line reached and verified.302- **ROI exhausted** — remaining bottlenecks' gain no longer justifies change cost.303304On stop: summarize rounds accepted/rejected, total measured gain vs baseline, remaining bottlenecks with ROI assessment.305306### Context discipline (long loops die of context bloat)307308Each round persists its outcome to the benchmark log and carries forward only: the round summary, the baseline-snapshot pointer, and the stop-condition counters. Raw profiles and intermediate data stay in the archive files — they are retrieved on demand, never carried in full across rounds.309310### Skill evolution (at every stop; or every ~5 rounds in long loops)311312Skills are code too — the project's `code-insight` / `code-optimizer` are themselves artifacts of the paradigm, improved by use. At each stop condition:313314- Fold this campaign's **validated lessons** into the two skills: attribution patterns that worked, optimizations that failed (with the rejection data), stack/project-specific pitfalls discovered.315- The benchmark log's invalidation rows and negative results are the primary feed — they encode exactly what the skills got wrong or missed.316- **Review the update from the stack's specialist perspectives** (e.g. language semantics / runtime & framework / hardware & platform) before landing: lessons gathered mid-campaign can contradict each other or the skill's existing content — correct the inconsistencies, then write.317- Update the skills in place; the next campaign starts smarter. This is where the paradigm compounds **across** campaigns, not just within one.318319## Output detail level (adaptive)320321- Simple problem, ample data: condense to "anomaly + causal chain + verdict".322- Complex/multi-module: brief per-stage outputs, key snippets attached.323- Stack-specific knowledge (framework versions, thresholds, patterns, tool tables): fold in from [reference.md](reference.md) conversationally — never hardcode stack specifics into this file's paradigm.