When to use
Use this skill when the request mentions:
- legacy code
- refactor
- spaghetti code
- explain this repo
- understand current behavior before changing it
- undocumented system
Core operating rules
- Do not remove or rewrite behavior before understanding why it exists.
- Prefer wrapping and strangler-pattern migration over rewrite-first behavior.
- Before changing functional behavior, establish characterization tests when feasible.
- Document risk, coupling, and likely side effects.
Investigation workflow
- Identify entry points and major modules.
- Trace data flow and mutation points.
- Detect global mutable state, circular imports, and hidden coupling.
- Describe current behavior in plain language.
- Recommend the smallest safe refactor path.
Preferred report structure
- Artifact analyzed
- Estimated age/style clues
- Inputs and outputs
- Dependencies and side effects
- Risk factors
- Safe refactoring plan
- Tests to add before deeper edits
Mandatory constraints
- No large rewrite without tests or a fallback plan.
- Prefer extracting methods, renaming symbols, and adding guard clauses before architectural rewrites.
- Explicitly mark unknowns and assumptions.