Agent skill
code-hygiene
Apply code hygiene standards for clean, maintainable code. Use when writing, refactoring, or reviewing code.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/code-hygiene
SKILL.md
Code Hygiene Standards
Core Principles
- Comments explain WHY, not WHAT - Code shows what through clear naming
- Self-documenting code - Descriptive names > comments
- Git captures history - Never add "moved from X" or "extracted from Y" comments
Comment Rules
Never write:
- Archaeological: "Extracted from X to reduce complexity"
- Motion tracking: "Moved from Y on DATE"
- Obvious: "Increment counter" above
counter += 1 - Vague TODOs: "TODO: fix this" (add ticket number + context)
- Commented-out code (Git remembers)
Do write:
- Design rationale: "Binary search because dataset >10k items"
- Security markers: "SECURITY: Validate path to prevent traversal"
- Performance constraints: "Must complete <50ms for 60Hz tick"
- External quirks: "GitHub API returns max 100 items per page"
- Actionable TODOs: "TODO(#423): Replace with spatial hash for >1000 entities"
File Size Limits
- >500 lines: Stop. Refactor before adding code.
- >300 lines + new code: Ask about extraction first.
Responsibility Check
Before adding code: Does this add a different responsibility? If yes, suggest where it should live instead.
Naming
- Descriptive:
validate_path_within_boundarynotcheck_path - No vague names:
data,info,temp,mgr,handler - Booleans:
is_valid,has_permission,can_edit - Constants:
TIMEOUT_MS(include units)
Refactoring Hygiene
- Delete "extracted from" comments after moving code
- Delete code completely (don't comment out)
- Remove unused imports
- Update all call sites atomically
Remember: Every line should serve a purpose. Delete ruthlessly. Name precisely.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?