
Simplify and refine existing code for clarity, consistency, and maintainability while preserving exact functionality. Use after writing or modifying code, when asked to simplify or clean up code without changing behavior, or when recently touched code should be made easier to read and more consistent with project standards.
Add, review, or rewrite code comments so they explain intent, invariants, branch rationale, and multi-step flows without narrating obvious syntax. Use when documenting newly added or recently changed code, converting line-by-line comments into concise block comments, checking whether comment density is too sparse or too heavy, or making non-obvious branches, scripts, and side effects easier for reviewers to scan.
Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.