Skip to content

Commit b66f727

Browse files
committed
fix(ai/repl): make human-code-refactor preserve valuable comments
Split comment rules into explicit REMOVE vs KEEP categories so the refactor command only strips decorative/obvious comments while preserving technical ones that explain WHY, edge cases, algorithm notes, and caveats.
1 parent 7d4f3f1 commit b66f727

File tree

5 files changed

+90
-40
lines changed

5 files changed

+90
-40
lines changed

home/ai/repl/claude/commands.nix

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,23 @@ _: {
180180
## Forbidden Patterns
181181
182182
### Comments
183-
- No decorative comment blocks (`# ===`, `# ---`, `# ***`)
184-
- No section banners or ASCII art headers
185-
- No comments restating what code obviously does (`# increment counter` above `i += 1`)
186-
- No comments explaining every line or block
187-
- No "TODO: implement" placeholders unless specifically requested
188-
- No comments like `# Main entry point`, `# Helper function`, `# Utility method`
189-
- Comments only where genuinely non-obvious or for complex business logic
183+
**REMOVE** (obvious/decorative):
184+
- Decorative blocks (`# ===`, `# ---`, `# ***`)
185+
- ASCII art headers or section banners
186+
- Comments restating what code obviously does (`# increment i` above `i += 1`)
187+
- Generic labels (`# Main entry point`, `# Helper function`, `# Utility method`)
188+
- Comments repeating variable/function names in prose form
189+
- "TODO: implement" placeholders unless specifically requested
190+
191+
**KEEP** (adds value):
192+
- Technical explanations of WHY not WHAT (`# offset by 1 to skip header row`)
193+
- Non-obvious edge cases (`# nil check: upstream API returns null on 404`)
194+
- Performance/algorithm notes (`# O(n log n) - sorted for binary search`)
195+
- Caveats or gotchas (`# WARN: not thread-safe, caller must hold lock`)
196+
- Brief clarifications for dense/tricky logic
197+
- References to specs, tickets, or external docs
198+
199+
Comments should be terse and technical. When in doubt, keep the comment if it explains something non-obvious from the code itself.
190200
191201
### Naming
192202
- No overly verbose names (`user_authentication_service_handler_manager`)
@@ -229,7 +239,7 @@ _: {
229239
230240
## Refactoring Checklist
231241
232-
1. Strip decorative/redundant comments
242+
1. Strip decorative/obvious comments (keep technical ones that add value)
233243
2. Shorten verbose variable/function names
234244
3. Inline trivial helper functions
235245
4. Remove unnecessary abstraction layers

home/ai/repl/codex/commands.nix

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,23 @@ _: {
159159
## Forbidden Patterns
160160
161161
### Comments
162-
- No decorative comment blocks (`# ===`, `# ---`, `# ***`)
163-
- No section banners or ASCII art headers
164-
- No comments restating what code obviously does (`# increment counter` above `i += 1`)
165-
- No comments explaining every line or block
166-
- No "TODO: implement" placeholders unless specifically requested
167-
- No comments like `# Main entry point`, `# Helper function`, `# Utility method`
168-
- Comments only where genuinely non-obvious or for complex business logic
162+
**REMOVE** (obvious/decorative):
163+
- Decorative blocks (`# ===`, `# ---`, `# ***`)
164+
- ASCII art headers or section banners
165+
- Comments restating what code obviously does (`# increment i` above `i += 1`)
166+
- Generic labels (`# Main entry point`, `# Helper function`, `# Utility method`)
167+
- Comments repeating variable/function names in prose form
168+
- "TODO: implement" placeholders unless specifically requested
169+
170+
**KEEP** (adds value):
171+
- Technical explanations of WHY not WHAT (`# offset by 1 to skip header row`)
172+
- Non-obvious edge cases (`# nil check: upstream API returns null on 404`)
173+
- Performance/algorithm notes (`# O(n log n) - sorted for binary search`)
174+
- Caveats or gotchas (`# WARN: not thread-safe, caller must hold lock`)
175+
- Brief clarifications for dense/tricky logic
176+
- References to specs, tickets, or external docs
177+
178+
Comments should be terse and technical. When in doubt, keep the comment if it explains something non-obvious from the code itself.
169179
170180
### Naming
171181
- No overly verbose names (`user_authentication_service_handler_manager`)
@@ -208,7 +218,7 @@ _: {
208218
209219
## Refactoring Checklist
210220
211-
1. Strip decorative/redundant comments
221+
1. Strip decorative/obvious comments (keep technical ones that add value)
212222
2. Shorten verbose variable/function names
213223
3. Inline trivial helper functions
214224
4. Remove unnecessary abstraction layers

home/ai/repl/copilot/commands.nix

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,23 @@ _: {
180180
## Forbidden Patterns
181181
182182
### Comments
183-
- No decorative comment blocks (`# ===`, `# ---`, `# ***`)
184-
- No section banners or ASCII art headers
185-
- No comments restating what code obviously does (`# increment counter` above `i += 1`)
186-
- No comments explaining every line or block
187-
- No "TODO: implement" placeholders unless specifically requested
188-
- No comments like `# Main entry point`, `# Helper function`, `# Utility method`
189-
- Comments only where genuinely non-obvious or for complex business logic
183+
**REMOVE** (obvious/decorative):
184+
- Decorative blocks (`# ===`, `# ---`, `# ***`)
185+
- ASCII art headers or section banners
186+
- Comments restating what code obviously does (`# increment i` above `i += 1`)
187+
- Generic labels (`# Main entry point`, `# Helper function`, `# Utility method`)
188+
- Comments repeating variable/function names in prose form
189+
- "TODO: implement" placeholders unless specifically requested
190+
191+
**KEEP** (adds value):
192+
- Technical explanations of WHY not WHAT (`# offset by 1 to skip header row`)
193+
- Non-obvious edge cases (`# nil check: upstream API returns null on 404`)
194+
- Performance/algorithm notes (`# O(n log n) - sorted for binary search`)
195+
- Caveats or gotchas (`# WARN: not thread-safe, caller must hold lock`)
196+
- Brief clarifications for dense/tricky logic
197+
- References to specs, tickets, or external docs
198+
199+
Comments should be terse and technical. When in doubt, keep the comment if it explains something non-obvious from the code itself.
190200
191201
### Naming
192202
- No overly verbose names (`user_authentication_service_handler_manager`)
@@ -229,7 +239,7 @@ _: {
229239
230240
## Refactoring Checklist
231241
232-
1. Strip decorative/redundant comments
242+
1. Strip decorative/obvious comments (keep technical ones that add value)
233243
2. Shorten verbose variable/function names
234244
3. Inline trivial helper functions
235245
4. Remove unnecessary abstraction layers

home/ai/repl/crush/commands.nix

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,23 @@ _: {
180180
## Forbidden Patterns
181181
182182
### Comments
183-
- No decorative comment blocks (`# ===`, `# ---`, `# ***`)
184-
- No section banners or ASCII art headers
185-
- No comments restating what code obviously does (`# increment counter` above `i += 1`)
186-
- No comments explaining every line or block
187-
- No "TODO: implement" placeholders unless specifically requested
188-
- No comments like `# Main entry point`, `# Helper function`, `# Utility method`
189-
- Comments only where genuinely non-obvious or for complex business logic
183+
**REMOVE** (obvious/decorative):
184+
- Decorative blocks (`# ===`, `# ---`, `# ***`)
185+
- ASCII art headers or section banners
186+
- Comments restating what code obviously does (`# increment i` above `i += 1`)
187+
- Generic labels (`# Main entry point`, `# Helper function`, `# Utility method`)
188+
- Comments repeating variable/function names in prose form
189+
- "TODO: implement" placeholders unless specifically requested
190+
191+
**KEEP** (adds value):
192+
- Technical explanations of WHY not WHAT (`# offset by 1 to skip header row`)
193+
- Non-obvious edge cases (`# nil check: upstream API returns null on 404`)
194+
- Performance/algorithm notes (`# O(n log n) - sorted for binary search`)
195+
- Caveats or gotchas (`# WARN: not thread-safe, caller must hold lock`)
196+
- Brief clarifications for dense/tricky logic
197+
- References to specs, tickets, or external docs
198+
199+
Comments should be terse and technical. When in doubt, keep the comment if it explains something non-obvious from the code itself.
190200
191201
### Naming
192202
- No overly verbose names (`user_authentication_service_handler_manager`)
@@ -229,7 +239,7 @@ _: {
229239
230240
## Refactoring Checklist
231241
232-
1. Strip decorative/redundant comments
242+
1. Strip decorative/obvious comments (keep technical ones that add value)
233243
2. Shorten verbose variable/function names
234244
3. Inline trivial helper functions
235245
4. Remove unnecessary abstraction layers

home/ai/repl/gemini/commands.nix

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,23 @@ _: {
165165
## Forbidden Patterns
166166
167167
### Comments
168-
- No decorative comment blocks (`# ===`, `# ---`, `# ***`)
169-
- No section banners or ASCII art headers
170-
- No comments restating what code obviously does (`# increment counter` above `i += 1`)
171-
- No comments explaining every line or block
172-
- No "TODO: implement" placeholders unless specifically requested
173-
- No comments like `# Main entry point`, `# Helper function`, `# Utility method`
174-
- Comments only where genuinely non-obvious or for complex business logic
168+
**REMOVE** (obvious/decorative):
169+
- Decorative blocks (`# ===`, `# ---`, `# ***`)
170+
- ASCII art headers or section banners
171+
- Comments restating what code obviously does (`# increment i` above `i += 1`)
172+
- Generic labels (`# Main entry point`, `# Helper function`, `# Utility method`)
173+
- Comments repeating variable/function names in prose form
174+
- "TODO: implement" placeholders unless specifically requested
175+
176+
**KEEP** (adds value):
177+
- Technical explanations of WHY not WHAT (`# offset by 1 to skip header row`)
178+
- Non-obvious edge cases (`# nil check: upstream API returns null on 404`)
179+
- Performance/algorithm notes (`# O(n log n) - sorted for binary search`)
180+
- Caveats or gotchas (`# WARN: not thread-safe, caller must hold lock`)
181+
- Brief clarifications for dense/tricky logic
182+
- References to specs, tickets, or external docs
183+
184+
Comments should be terse and technical. When in doubt, keep the comment if it explains something non-obvious from the code itself.
175185
176186
### Naming
177187
- No overly verbose names (`user_authentication_service_handler_manager`)
@@ -214,7 +224,7 @@ _: {
214224
215225
## Refactoring Checklist
216226
217-
1. Strip decorative/redundant comments
227+
1. Strip decorative/obvious comments (keep technical ones that add value)
218228
2. Shorten verbose variable/function names
219229
3. Inline trivial helper functions
220230
4. Remove unnecessary abstraction layers

0 commit comments

Comments
 (0)