Community编程与开发github.com

优化测试

优化 OpenClaw 慢速测试、导入、误置覆盖率和 CI 耗时而不会降低覆盖率。

优化测试 是什么?

这个技能旨在优化 OpenClaw 项目的测试速度、导入性能、覆盖率定位和 CI 流程耗时,同时确保不降低测试覆盖率。它要求基于数据驱动的证据优先处理最高收益的热点问题,例如宽泛的桶形导入、`importActual()` 使用、`vi.resetModules()` 频率、昂贵的网关/服务器/客户端设置、重复的 fixture 构造和合约断言。技能提供了详细的运行手册,包括前置阅读、建立证据、攻击策略、生产级修复原则、基准测试验证、门禁检查(`pnpm check`、`pnpm test`、`pnpm build`)以及提交与 CI 状态跟踪。主要支持 pnpm 和 Vitest 生态,通过记录前后对比(墙钟时间、Vitest 时长、最大 RSS)和可视化输出(如 `gh run list/view`)来确保优化成果可量化且 CI 保持绿色。最终输出应包括推送的提交、前后时序、门禁运行状态、当前 CI 状态以及任何待优化的剩余分支。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/clawdbot/clawdbot/tree/main/.agents/skills/optimizetests

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

优化测试 是做什么的?

目标:在保持覆盖率不变的前提下,实现 OpenClaw 测试/运行时速度的实质性加速。不要通过增加分片、跳过断言、削弱门禁或调整 runner 标志作为主要修复手段。

运行手册

  1. 阅读 docs/help/testing.md、docs/ci.md 以及将要编辑的任何子树中对应的 AGENTS.md 文件。
  2. 在编辑前收集证据:
    • 完整排名:pnpm test:perf:groups --full-suite --allow-failures --output .artifacts/test-perf/<name>.json
    • 目标文件:timeout 240 /usr/bin/time -l pnpm test <file> --maxWorkers=1 --reporter=verbose
    • 导入怀疑:添加 OPENCLAW_VITEST_IMPORT_DURATIONS=1 OPENCLAW_VITEST_PRINT_IMPORT_BREAKDOWN=1
  3. 优先攻击收益最高的热点:
    • 热测试中的宽泛桶形导入或 importActual() 使用
    • 每个测试中的 vi.resetModules() 加上新的导入
    • 昂贵的网关/服务器/客户端设置(可重置或重用以验证相同行为)
    • 断言扩展所有权行为的核心测试
    • 重复的 fixture 构造或合约断言
  4. 更倾向生产级修复:
    • 窄的运行时接缝优于宽泛的模拟
    • 用于静态解析/元数据的纯帮助函数
    • 注入依赖优于模块重置
    • 扩展所有权的测试用于捆绑插件/提供者/通道行为
  5. 每次更改后,重新运行相同的基准测试和验证测试通道。记录前后对比的墙钟时间、Vitest 时长和最大 RSS(若可用)。
  6. 运行 pnpm check:changed;当触及的表面需要时,运行更宽泛的门禁(pnpm check、pnpm test、pnpm build)。
  7. 使用 scripts/committer "<conventional message>" <paths...> 提交作用域内的更改。当请求时推送。如果 CI 为红色,使用 gh run list/view 检查,修复,推送,重复直到当前 CI 变绿或阻塞项被证明无关。

输出

以推送的提交、前后时序、运行的门禁、当前 CI 状态以及任何需要单独优化的遗留分支结束。

Individual skills in this repo

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

1password

Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.

acp-router

Route plain-language requests for Claude Code, Cursor, Copilot, OpenClaw ACP, OpenCode, Gemini CLI, Grok Build, Qwen, Kiro, Kimi, iFlow, Factory Droid, Kilocode, or explicit ACP harness work into either OpenClaw ACP runtime sessions or direct acpx-driven sessions ("telephone game" flow). For coding-agent thread requests, read this skill first, then use only `sessions_spawn` for thread creation. Codex chat binding defaults to the native Codex app-server plugin unless ACP is explicit or background spawn needs ACP.

add-model-provider

Add and live-prove a model provider with non-interactive config one-liners, without exposing credentials.

agent-transcript

Requested GitHub PR/issue agent transcripts: redact, trim, preview, and insert safely.

apple-notes

Create, view, edit, delete, search, move, or export Apple Notes via the memo CLI on macOS.

apple-reminders

List, add, edit, complete, or delete Apple Reminders and reminder lists via remindctl.

auto-qa

Run OpenClaw-wide autonomous QA and live/stress campaigns across independent subsystem lanes, with verified fixes and a resumable evidence report.

autoreview

Structured code review through the shared OpenClaw agent-skills installation.

bear-notes

Create, search, and manage Bear notes via grizzly CLI.

blacksmith-testbox

Run Blacksmith Testbox for CI-parity checks, secrets, hosted services, migrations, or builds local cannot reproduce.

block-kit

Use proactively for structured or interactive Slack replies, and when asked to author or validate native Slack Block Kit JSON.

blogwatcher

Monitor blogs and RSS/Atom feeds for updates using the blogwatcher CLI.

blucli

BluOS CLI (blu) for discovery, playback, grouping, and volume.

bluebubbles

Send and manage iMessages via BlueBubbles, including attachments, tapbacks, edits, replies, and groups.

browser-automation

Use when controlling web pages with the OpenClaw browser tool, especially multi-step flows, login checks, tab management, or recovery from stale refs/timeouts.

camsnap

Capture frames or clips from RTSP/ONVIF cameras and local webcams, including USB pan/tilt/zoom control.

canvas

Present HTML on connected OpenClaw node canvases, navigate/eval/snapshot, and debug canvas host URLs.

channel-message-flows

Use when running QA Lab channel message flow evidence.

clawdtributor

Clawtributor PRs here, last week or another window: discover conversation refs, recheck GitHub, rank by impact.

clawhub

Search ClawHub for plugins by default, or skills and agent Templates when requested; add Templates; install, verify, update, uninstall, publish, or sync skills.

相关技能