AgentSkillsCN

refactor-efficiently

采用 .only 验证模式进行高效重构——在更新所有测试之前,先确保有一项代表性测试通过。适用于某项变更可能影响多个测试时使用。

SKILL.md
--- frontmatter
name: refactor-efficiently
description: Efficient refactoring using the .only validation pattern — get one representative test passing before updating all tests. Use when a change will break multiple tests.

Refactor Efficiently

Safely refactor APIs, call signatures, and cross-cutting behavior by validating one test before updating all.

Usage

/refactor-efficiently <package-name>

Process

  1. Mark one representative test as .only
  2. Implement the new pattern in that test
  3. Run npm test until it passes
  4. Update remaining tests to match
  5. Remove .only and run full suite

Rules

  • Never update all tests simultaneously
  • Never leave .only in committed code
  • Never create backward-compatible shims to avoid test updates