Skip to content

lootlog/monorepo / .agents/skills/refactor

refactor

Verified

Refactor existing code to reduce maintenance cost while preserving observable behavior. Use for focused cleanup, simplifying interfaces, removing duplication, and restructuring code that is difficult to change.

Refactor

Make the smallest complete change that reduces a demonstrated maintenance problem. Follow AGENTS.md for compatibility, verification, and delivery.

Understand

  1. Identify the concrete problem and the behavior that must remain unchanged.
  2. Trace the affected implementation and its callers. Use CodeGraph first when the repository is indexed.
  3. Inspect existing abstractions, types, and tests before choosing a new structure.

Change

  • Reuse existing code and native features before adding abstractions.
  • Delete dead code and redundant wrappers. Extract a function or module when it gives a coherent responsibility a useful interface; line count alone is not a reason to split code.
  • Keep ownership and dependencies clear. Use codebase-design when the interface itself needs redesign.
  • Preserve validation, error behavior, side effects, ordering, and public contracts. If the requested work also changes behavior, identify and verify that change explicitly.
  • Keep steps reviewable and preserve unrelated working-tree changes. Follow repository delivery rules for commits; each editing step does not require a commit.

Verify

Choose evidence in proportion to the changed behavior and risk. Reuse the existing test framework and run the checks required by the repository.

Add focused characterization coverage when behavior is subtle or insufficiently protected. A mechanical rename or similarly low-risk edit may be proven by typecheck, existing tests, and diff inspection without new tests. When an executable check is unavailable, report the limitation and the evidence actually obtained.

Inspect the final diff for accidental behavior changes, unnecessary abstractions, and incomplete caller migrations. Report what became simpler and how behavior preservation was checked.

receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 319kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 319kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 319kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 319kUpdated Claude CodeCodexVerifiedInstall