Comments Required
Delete commented-out code
Never commit code that is commented out. Delete it, because version control already keeps every old line.
How to do it
Remove dead blocks when you stop using them. If you might need them later, the commit history has them. To switch a feature off, use a setting or a feature flag, not a comment.
Example
// Bad: nobody knows if this still matters
// $total = $this->applyLegacyDiscount($total);
$total = $this->applyDiscount($total);
// Good: the old line lives in the history, not in the file
$total = $this->applyDiscount($total);
# A quick check in any repository: lines that look like commented-out code
grep -rnE '^\s*(//|#)\s*[a-zA-Z_$][\w.$]*\s*(\(.*\)|=[^=]).*;?\s*$' src/ && exit 1 || exit 0
How to check
A linter rule or a script fails the build on commented-out code. Examples are eslint-plugin-no-commented-code, SonarQube's commented-out code rule and Ruff's ERA001 for Python.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers architecture playbook: https://agentwranglers.se/playbook/architecture/comments/no-commented-out-code.