Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
vasilyu1983 avatar

Qa Refactoring

  • 164 installs
  • 73 repo stars
  • Updated July 13, 2026
  • vasilyu1983/ai-agents-public

Helps with code review & quality tasks.

About

qa-refactoring is a Claude Code skill for code review & quality. It helps solo builders move faster with AI-assisted development.

  • qa-refactoring
  • Code Review & Quality
  • AI-coding skill

Qa Refactoring by the numbers

  • 164 all-time installs (skills.sh)
  • +2 installs in the week ending Jul 27, 2026 (Skillselion tracking)
  • Ranked #365 of 1,352 Code Review & Quality skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/vasilyu1983/ai-agents-public --skill qa-refactoring

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs164
repo stars73
Last updatedJuly 13, 2026
Repositoryvasilyu1983/ai-agents-public

What it does

Helps with code review & quality tasks.

Files

SKILL.mdMarkdownGitHub ↗

QA Refactoring Safety

Use this skill to refactor safely: preserve behavior, reduce risk, and keep CI green while improving maintainability and delivery speed.

Defaults: baseline first, smallest safe step next, and proof via tests/contracts/observability instead of intuition.

Quick Start (10 Minutes)

  • If key context is missing, ask for: what must not change (invariants), risk level (money/auth/migrations/concurrency), deployment constraints, and the smallest boundary that can be protected by tests.
  • Confirm baseline: main green; reproduce the behavior you must preserve.
  • Choose a boundary: API surface, module boundary, DB boundary, or request handler.
  • Add a safety net: characterization/contract/integration tests at that boundary.
  • Refactor in micro-steps: one behavior-preserving change per commit/PR chunk.
  • Prove: run the smallest relevant suite locally, then full CI; keep failures deterministic.

Core QA (Default)

Safe Refactor Loop (Behavior First)

  • Establish baseline: get main green; reproduce the behavior you must preserve.
  • Define invariants: inputs/outputs, error modes, permissions, data shape, performance budgets.
  • Add a safety net: write characterization/contract/integration tests around the boundary you will touch.
  • Create seams: introduce injection points/adapters to isolate side effects and external dependencies.
  • Refactor in micro-steps: one behavior-preserving change at a time; keep diffs reviewable.
  • Prove: run the smallest relevant suite locally, then full CI; keep failures debuggable and deterministic.
  • Ship safely: use canary/dark launch/feature flags when refactors touch production-critical paths.

Risk Levels (Choose Safety Net)

RiskExamplesMinimum required safety net
Lowrename, extract method, formatting-onlyunit tests + lint/type checks
Mediummoving logic across modules, dependency inversionunit + integration/contract tests at boundary
Highauth/permission paths, concurrency, migrations, money/data-loss pathsintegration + contract tests, observability checks, canary + rollback plan

Test Strategy for Refactors

  • Prefer contract and integration tests around boundaries to preserve behavior.
  • Use snapshots/golden masters only when outputs are stable and reviewed (avoid "approve everything" loops).
  • For invariants, consider property-based tests or table-driven cases (inputs, edge cases, error modes).
  • Avoid making E2E/UI tests the primary safety net for refactors; keep most safety below the UI.
  • For flaky areas: fix determinism first (seeds, time, ordering, network) before trusting results.

CI Economics and Debugging Ergonomics

  • Keep refactor PRs small and reviewable; avoid refactor + feature in one PR.
  • Require failure artifacts for tests guarding refactors (logs, trace IDs, deterministic seeds, repro steps).
  • Reduce diff noise: isolate formatting-only changes (or apply formatting repo-wide once with buy-in).
  • Keep git bisect viable: avoid mixed "mechanical + semantic" changes unless necessary.

Do / Avoid

Do:

  • Add missing tests before refactoring high-risk areas.
  • Add guardrails (linters, type checks, contract checks, static analysis/security checks) so refactors don't silently break interfaces.
  • Prefer "branch by abstraction" / adapters when you need to swap implementations safely.

Avoid:

  • Combining large structural refactors with behavior changes.
  • Using flaky E2E as the primary safety net for refactors.

Quick Reference

TaskTool/PatternCommand/ApproachWhen to Use
Long method (>50 lines)Extract MethodSplit into smaller functionsSingle method does too much
Large class (>300 lines)Split ClassCreate focused single-responsibility classesGod object doing too much
Duplicated codeExtract Function/ClassDRY principleSame logic in multiple places
Complex conditionalsReplace Conditional with PolymorphismUse inheritance/strategy patternSwitch statements on type
Long parameter listIntroduce Parameter ObjectCreate DTO/config objectFunctions with >3 parameters
Legacy code modernizationCharacterization Tests + Strangler FigWrite tests first, migrate incrementallyNo tests, old codebase
Automated quality gatesESLint, SonarQube, Prettiernpm run lint, CI/CD pipelinePrevent quality regression
Technical debt trackingSonarQube, CodeClimateTrack trends + hotspotsPrioritize refactoring work

Decision Tree: Refactoring Strategy

Code issue: [Refactoring Scenario]
    ├─ Code Smells Detected?
    │   ├─ Duplicated code? → Extract method/function
    │   ├─ Long method (>50 lines)? → Extract smaller methods
    │   ├─ Large class (>300 lines)? → Split into focused classes
    │   ├─ Long parameter list? → Parameter object
    │   └─ Feature envy? → Move method closer to data
    │
    ├─ Legacy Code (No Tests)?
    │   ├─ High risk? → Write characterization tests first
    │   ├─ Large rewrite needed? → Strangler Fig (incremental migration)
    │   ├─ Unknown behavior? → Characterization tests + small refactors
    │   └─ Production system? → Canary deployments + monitoring
    │
    ├─ Quality Standards?
    │   ├─ New project? → Setup linter + formatter + quality gates
    │   ├─ Existing project? → Add pre-commit hooks + CI checks
    │   ├─ Complexity issues? → Set cyclomatic complexity limits (<10)
    │   └─ Technical debt? → Track in register, 20% sprint capacity

Related Skills

  • Debugging production issues: qa-debugging
  • Code review process and checklists: software-code-review
  • New architecture design from scratch: software-architecture-design
  • Test strategy and coverage planning: qa-testing-strategy

Scope Boundaries (Handoffs)

  • Pure test flake cleanup (timers, ordering, retries): ../qa-debugging/SKILL.md
  • Pure performance tuning (SQL, indexing, query plans): ../data-sql-optimization/SKILL.md
  • Architecture redesign decisions (service boundaries, eventing): ../software-architecture-design/SKILL.md

Operational Deep Dives

Shared Foundation

  • ../software-clean-code-standard/references/clean-code-standard.md - Canonical clean code rules (CC-*) for citation
  • Legacy playbook: ../software-clean-code-standard/references/code-quality-operational-playbook.md - RULE-01RULE-13, decision trees, and operational procedures
  • ../software-clean-code-standard/references/refactoring-operational-checklist.md - Refactoring smell-to-action mapping, safe refactoring guardrails
  • ../software-clean-code-standard/references/working-effectively-with-legacy-code-operational-checklist.md - Seams, characterization tests, incremental migration patterns

Skill-Specific

See references/operational-patterns.md for detailed refactoring catalogs, automated quality gates, technical debt playbooks, and legacy modernization steps.

Templates

Use copy-paste templates in assets/ for checklists and quality-gate configs:

  • Refactoring: assets/process/refactoring-checklist.md, assets/process/code-review-quality.md
  • Technical debt: assets/tracking/tech-debt-register.md
  • Quality gates: assets/quality-gates/javascript/eslint-config.js, assets/quality-gates/platform-agnostic/sonarqube-setup.md

Resources

Use deep-dive guides in references/ (load only what you need):

  • Operational Patterns: references/operational-patterns.md - Core refactoring catalogs, quality gates, and legacy modernization
  • Refactoring Catalog: references/refactoring-catalog.md
  • Code Smells Guide: references/code-smells-guide.md
  • Technical Debt Management: references/tech-debt-management.md
  • Legacy Code Modernization: references/legacy-code-strategies.md
  • Characterization Testing: references/characterization-testing.md - Golden master and approval testing patterns
  • Strangler Fig Migration: references/strangler-fig-migration.md - Incremental legacy migration strategies
  • Automated Refactoring Tools: references/automated-refactoring-tools.md - Codemods, AST transforms, and IDE refactoring

Optional: AI / Automation

Do:

  • Use AI to propose mechanical refactors (rename/extract/move) only when you can prove behavior preservation via tests and contracts.
  • Use AI to summarize diffs and risk hotspots; verify by running targeted characterization tests.
  • Prefer tool-assisted refactors (IDE/compiler-aware, codemods) over freeform text edits when available.

Avoid:

  • Accepting refactors that change behavior without an explicit requirement and regression tests.
  • Letting AI "fix tests" by weakening assertions to make CI green.

See data/sources.json for curated external references.

Fact-Checking

  • Use web search/web fetch to verify current external facts, versions, pricing, deadlines, regulations, or platform behavior before final answers.
  • Prefer primary sources; report source links and dates for volatile information.
  • If web access is unavailable, state the limitation and mark guidance as unverified.

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.