Communitygithub.com

基准测试优化循环

当用户要求让代码跑得更快、尝试多种变体、运行递归优化、基准测试延迟/吞吐量/成本,或通过反复测量来选择最佳实现时,使用此技能。

基准测试优化循环 是什么?

该技能为开发者提供了一个结构化、可重复的优化工作流,旨在将模糊的性能目标(如“提升20倍速度”或“尝试50种递归优化”)转化为一个有边界、可测量的循环,从而显著改进系统性能。其核心流程包括建立基线、基于证据识别瓶颈、生成和测试单一假设的变体、拒绝不符合正确性/安全性的变体、推广最快且安全的变体,最终将成果固化到脚本、配置或文档中。技能还引入了变体追踪表格、递归搜索(带停止条件)以及严格的升级门槛,确保每个优化决策都有据可查、可回滚、并且经过验证。它适用于Claude Code、Cursor、Codex等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. 重新运行基线及获胜者以确认差异。

变体记录表

按如下方式追踪变体:

变体 | 假设 | 命令 | 耗时 | 正确? | 备注
baseline | 当前路径 | npm run job | 120s | 是 | 稳定
batch-500 | 减少往返次数 | npm run job -- --batch 500 | 42s | 是 | 获胜者
parallel-8 | 更多工作进程 | npm run job -- --workers 8 | 31s | 否 | 受到速率限制

递归搜索

对于递归或超参数调优:

  • 每次运行都持久化到运行记录中;
  • 与前一个已接受的获胜者进行比较,而不仅仅是前一次运行;
  • 保留一个留出集或者回放校验;
  • 当出现以下情况时停止:改进幅度在噪声范围内、正确性检查失败、成本超出预算、或者搜索开始改变太多变量以至于无法解释。

使用诸如 “经过测量的最佳安全变体” 这样的措辞,除非搜索空间确实是穷尽的,否则不要使用“全局最优”。

升级门槛

一个变体在成为新的默认配置之前,必须满足:

  • 正确性测试通过;
  • 性能差异是可重复的或有合理解释;
  • 回滚路径清晰明确;
  • 变更已纳入版本控制或持久的运行手册中;
  • 最终总结中包含确切的命令和测量值。

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.

相关技能