Code Refactoring, Quality & Local Scanner Skill (Phase D: REFACTOR Phase)
Overview
Refactor implementation for clean code structure, modularity, and maintainability while ensuring 100% passing test regressions and blocking pattern-based security flaws locally prior to commit.
Verification Guardrails
- Code Quality & Refactoring:
- Clean up boilerplate, eliminate dead code, and centralize common utilities.
- Improve variable naming, modularity, and type annotations without altering verified behavior.
- Deterministic Scans (Fast & Offline):
- Secrets: Check diffs for plaintext credentials, tokens, or private keys.
- Dependencies: Flag unpinned dependencies or known CVEs in new packages.
- Rules-Based SAST: Run local SAST rules on modified files (
semgrep scan --config auto --jsonorcm find).
- Guided AI Review:
- Audit architecture and design issues that static tools miss.
- Review business logic and edge cases for bypasses or regression risks.
- Small Diffs & Regression QA:
- Run the complete project test suite to verify zero regressions across existing and new tests.
- Ensure the diff contains only surgical changes directly related to the task scope.
Execution Sequence
- Review the git diff of modified files (
git diff). - Refactor code for clarity, maintainability, and helper reuse.
- Run local linters and security scanners on changed files.
- Run the full test suite to guarantee 100% passing tests.
- Continuous Evolution: Capture new conventions in
CONTEXT.mdand suggest/apply updates toSKILL.mdinstructions viaskill-evolution-updaterto permanently prevent recurrence of issues.