cc-refactor-safety

Validates code refactoring against original source to prevent context and structure loss.

1.0k|109|Updated Jan 4, 2026
One-click install
npx skills add https://github.com/doccker/cc-use-exp --skill cc-refactor-safety
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cc-refactor-safety
Source: https://github.com/doccker/cc-use-exp/tree/main/.codex/skills/cc-refactor-safety
Command: npx skills add https://github.com/doccker/cc-use-exp --skill cc-refactor-safety

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Refactoring often silently breaks code when AI assistants rely on memory or assumptions instead of reading the original source, causing lost table columns, broken conditional branches, circular dependencies, and misaligned parallel lists. This Skill enforces a read-first, verify-after checklist workflow that catches these regressions before they ship.

Core Features & Use Cases

  • Read-Before-Refactor Discipline: Requires reading complete original code (all if/else/switch branches) before restructuring, with comparison tables for tables, data structures, and field mappings.
  • Ten Documented Pitfall Patterns: Covers circular dependencies from module extraction, state initialization conflicts in hooks, lost UI layouts in Modal/Dialog refactors, oversimplified render functions, field-name guessing, shotgun fixes, and distinct/filter misalignment in position-correlated lists.
  • Multi-Language Examples: Provides Java, Go, and TypeScript implementations for paired-collection handling in the references directory.
  • Use Case: When merging two tenant-specific table definitions into one shared component, the Skill forces a column-by-column comparison checklist so no column is dropped or renamed silently.

Quick Start

Ask the AI to refactor a component or merge duplicate logic, and it will apply the refactoring safety checklist to verify the result against the original code.

Frequently Asked Questions about cc-refactor-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor code without losing original logic?

Read the complete original code first, including all conditional branches, then build a comparison checklist of columns, fields, or branches before and after refactoring. Verify item counts, ordering, and naming match the original before committing.

How to avoid circular dependencies when extracting services in Spring?

Extract shared utility methods into an independent helper class before splitting sub-services, so children depend on the helper rather than the parent. Alternatives include @Lazy injection or functional callbacks, and always check whether earlier extractions had the same callback dependency.

Why does refactoring break parallel lists that correspond by index?

Applying distinct, filter, or sorted to only one of two position-correlated lists changes its length and breaks the implicit zip relationship. Either align operations across both lists or refactor to a list of paired records so operations apply to whole items.

Does this refactoring checklist work with React and Vue?

Yes, it covers React hooks and Modal components as well as Vue composables and el-dialog slots. It specifically guards against state initialization overwriting caller-set values and loss of conditionally rendered buttons in title or footer areas.

What are common mistakes when merging duplicate code branches?

Common mistakes include reading only one branch and assuming others are similar, guessing field names from type definitions instead of actual usage, and simplifying complex render functions into plain text. Always diff every branch against the original source.