Communitygithub.com

基準測試優化循環

當使用者要求讓某個東西更快時使用此技能:嘗試多種變體、執行遞迴優化、基準測試延遲/吞吐量/成本,或透過重複測量測試選擇最佳實作。

基準測試優化循環 是什麼?

此技能旨在將模糊的效能要求(例如「讓它快20倍」或「嘗試50次遞迴優化」)轉換為有界限、可測量的循環,從而真正改善系統。它要求先建立必要的基準:被優化的操作、正確性檢查、指標(如牆鐘時間、p95延遲、每秒處理行數、每次執行成本、記憶體用量、錯誤率)、當前基線以及搜尋預算(最大變體數、時間、開銷、資料影響)。循環步驟包括:測量基線、根據證據找出瓶頸、生成每次只測試一個假設的變體、使用相同輸入形狀執行變體、拒絕失敗的變體、晉升最快的安全變體、將勝利路徑編碼成腳本或命令,以及重新運行以確認差異。它還支援遞迴搜尋,並要求將所有運行持久化到記錄、與先前的獲勝者比較、保留驗證檢查,並在改善進入雜訊區、正確性失敗、成本超支或變更過多無法解釋時停止。最後,變體必須通過正確性測試、效能差異需重複或解釋、回滾要明確、變更需納入版本控制,最終總結需包含確切命令和測量結果。此技能適用於 Claude Code、Cursor 及其他基於終端機的 AI 代理平台。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/benchmark-optimization-loop

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

基準測試優化循環 是做什麼的?

使用此技能將「讓它快20倍」或「嘗試50次遞迴優化」轉換為有界限、可測量的循環,從而真正改善系統。

必要基準

在進行優化之前,必須存在以下項目:

  • 正在優化的操作;
  • 必須保持通過的正確性閘門;
  • 指標:牆鐘時間、p95 延遲、每秒處理行數、每次執行成本、記憶體用量、錯誤率;
  • 當前基線;
  • 搜尋預算:最大變體數、最大時間、最大花費、最大資料影響。

如果使用者要求不切實際的目標,請保留其野心,但將循環設為有界限且可測量的。

循環

  1. 測量基線。
  2. 根據證據找出瓶頸。
  3. 生成每次只測試一個假設的變體。
  4. 使用相同輸入形狀執行變體。
  5. 拒絕未通過正確性、安全性或可重複性的變體。
  6. 晉升最快的安全變體。
  7. 將勝利路徑編碼到腳本、命令、測試、設定或文件中。
  8. 重新執行基線和勝利者以確認差異。

變體表格

像這樣追蹤變體:

變體 | 假設 | 命令 | 時間 | 正確? | 備註
基線 | 當前路徑 | npm run job | 120 秒 | 是 | 穩定
批次-500 | 減少往返次數 | npm run job -- --batch 500 | 42 秒 | 是 | 獲勝者
並行-8 | 更多工作執行緒 | npm run job -- --workers 8 | 31 秒 | 否 | 受到速率限制

遞迴搜尋

對於遞迴或超參數調整工作:

  • 將每次運行持久化到記錄中;
  • 與先前的獲勝者比較,而不僅僅是前一次運行;
  • 保留驗證檢查或回放檢查;
  • 當改善進入雜訊區、正確性失敗、成本超出預算,或搜尋開始變更的變數多到無法解釋時停止。

使用「最佳測量到的安全變體」等措辭,而非「全域最優」,除非搜尋空間確實是窮舉的。

晉升閘門

變體不能成為新的預設值,直到:

  • 正確性測試通過;
  • 效能差異已重複出現或得到解釋;
  • 回滾方式明確;
  • 變更已編碼到原始碼控制或持久化的操作手冊中;
  • 最終總結包含確切的命令和測量結果。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

相關技能