Agent skill
rule-code-comments
Rule mapping for code-comments
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/rule-code-comments
SKILL.md
Rule code-comments
Apply this rule whenever work touches:
*.ts*.tsx
Comments should add information that the code cannot express on its own. If the code can be made clear enough without a comment, prefer that approach.
When to comment
Write a comment when:
- A business rule or domain constraint is not obvious from the code alone.
- A workaround exists for a known issue, library bug, or platform limitation.
- A non-trivial algorithm or calculation requires context about the approach chosen.
- A
TODOmarks future work that is tracked and assigned.
When NOT to comment
Do not write a comment when:
- The function name, parameter names, and return type already explain the behavior.
- The comment merely restates the code in English.
- The comment exists only because the code is too complex; simplify the code instead.
TSDoc for exports
Exported symbols may use TSDoc when additional guidance helps consumers:
/**
* Computes the carbon credit score based on the mass balance and
* methodology-specific weighting factors.
*
* Returns zero if the input document has no valid mass entries.
*/
export function computeCarbonCreditScore(input: MassBalance): number { ... }
Avoid boilerplate TSDoc that adds no value:
// Bad - repeats the signature
/**
* @param input - the input
* @returns the result
*/
export function computeCarbonCreditScore(input: MassBalance): number { ... }
Commented-out code
Never commit commented-out code. If the code is no longer needed, delete it. Git history preserves everything. If you need to temporarily disable logic during development, remove it before committing.
Stale comments
When modifying a function or behavior, review any adjacent comments. If a comment no longer matches reality, update or remove it in the same commit.
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?