Skip to content

braydio/CUSTODIAN / .claude/skills/refactor-safely

refactor-safely

Verified

Plan and execute safe refactoring using dependency analysis

Refactor Safely

Use the knowledge graph to plan and execute refactoring with confidence.

Steps

  1. Use refactor_tool with mode="suggest" for community-driven refactoring suggestions.
  2. Use refactor_tool with mode="dead_code" to find unreferenced code.
  3. For renames, use refactor_tool with mode="rename" to preview all affected locations.
  4. Use apply_refactor_tool with the refactor_id to apply renames.
  5. After changes, run detect_changes_tool to verify the refactoring impact.

Safety Checks

  • Always preview before applying (rename mode gives you an edit list).
  • Check get_impact_radius_tool before major refactors.
  • Use get_affected_flows_tool to ensure no critical paths are broken.
  • Run find_large_functions to identify decomposition targets.

Token Efficiency Rules

  • In the persistent coordination checkout, start with get_minimal_context(task="<your task>") when the graph is ready.
  • In a linked/ephemeral worktree, do not cold-build a graph merely because the first call reports missing_graph, not_ready, empty/unmapped, or stale coverage. If baseline structural context is useful, point CRG at the persistent coordination root; then verify every implementation/review fact against the current worktree.
  • If the graph is unusable after one cheap attempt, immediately use targeted symbol/path reads. Current worktree files and git diff are authoritative for branch-local changes.
  • When the task packet provides a bounded ## Context Pack, generate it once from the claimed worktree with scripts/ai/pack-context.sh task ... and use it instead of broad file dumping.
  • Use detail_level="minimal" on graph calls. Escalate only when minimal is insufficient.
  • Target: complete any review/debug/refactor task in ≤5 graph calls and ≤800 graph-output tokens.
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: 318kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 318kUpdated 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: 318kUpdated 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: 318kUpdated Claude CodeCodexVerifiedInstall