cc-defensive-programming
Applies Code Complete's defensive programming rules: barricade design, assertion vs error-handling selection, input validation policy, and correctness-vs-robustness strategy for the current context.
cc-refactoring-guidance
Guides safe refactoring using Code Complete's fix-first-then-refactor discipline: decides between refactor, rewrite, and fix-first; enforces separate commits; applies small-change rigor to high-error-rate one-liners.
Full skill instructions
Refactoring is behavior-preserving change to working code. Three rules govern it:
| Rule | Value | Source |
|---|---|---|
| Small-change error rate | Peaks at 1–5 lines | Weinberg 1983 |
| First-attempt success | <50% for any change | Yourdon 1986b |
| Review effect on 1-line changes | 55% → 2% error rate | Freedman and Weinberg 1982 |
Shared thresholds (routine length, parameters, cohesion): Read(${CLAUDE_PLUGIN_ROOT}/references/cc-foundations.md). The full 40-item refactoring checklist: Read(${CLAUDE_SKILL_DIR}/checklists.md).
Definitions:
Refactor toward something, not just away from bad code. Find the best examples of the target pattern in this codebase, the module's conventions, and how similar refactorings were structured; match the existing pattern exactly, or — if none exists — be deliberate about the precedent you're setting. Full gate: Read(${CLAUDE_PLUGIN_ROOT}/references/pattern-reuse-gate.md).
Guide the refactoring decision and the safe process.
When production is down: fix only — no refactoring or cleanup — deploy, then refactor as a separate activity when stable. Combining the two raises complexity and error likelihood.
Refactor vs rewrite:
Safe process (priority order):
If tests fail after a refactoring: don't debug extensively — back out the change, take a smaller step, and reconsider whether you understood the code.
When prerequisites are missing:
Read(${CLAUDE_PLUGIN_ROOT}/skills/welc-legacy-code/SKILL.md) and write characterization tests first; if impossible, document expected behavior, write a manual test script, and increase review rigor.Transform code smells into clean code while preserving all observable behavior (same tests pass before and after): setup/takedown smell → encapsulated interface; tramp data → direct access or restructure; duplicated code → extracted routine; speculative "design ahead" code → remove it. Behavior changes are fixing, not refactoring — fix first.
If you mixed fix and refactor in one commit:
git reset --soft HEAD~1, separate the changes, re-commit properly.If you skipped review on a small change:
Fixing a violation post-commit still costs less than the bugs it would otherwise cause.
| After | Next |
|---|---|
| Refactoring complete | Read(${CLAUDE_PLUGIN_ROOT}/skills/cc-control-flow-quality/SKILL.md) |
| Structure changed | Read(${CLAUDE_PLUGIN_ROOT}/skills/cc-routine-and-class-design/SKILL.md) |
| Reviewing a refactoring | Read(${CLAUDE_PLUGIN_ROOT}/skills/aposd-reviewing-module-design/SKILL.md) |
Applies Code Complete's defensive programming rules: barricade design, assertion vs error-handling selection, input validation policy, and correctness-vs-robustness strategy for the current context.
Structures routine design through pseudocode-first iteration: clarifies naming and purpose before any code, catches design flaws cheaply, and prevents compile-debug loops on poorly understood routines.
Transforms complex code by applying APOSD's pull-complexity-downward principle: resolves error hierarchies, collapses configuration, and moves caller-side logic into modules. Produces edited code, not just assessment.
Guides module and API design using APOSD principles: generates multiple design alternatives, compares them on information hiding and interface depth, and produces a documented design decision.
Assesses existing module and interface design for complexity symptoms: information leakage, shallow interfaces, pass-through layers, and unknown unknowns. Produces a structured assessment — not transformations.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience