agentleFS
atuinshatuinsh/desktop/.cursor/rules/avoid-unnecessary-comments.mdc

desktop / rules

Cursor rule2.5k starsChanged 19 months agoApache-2.0Archived repositoryView on GitHub

Good comment style

The file

We split this avoid-unnecessary-comments.mdc into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Add noise that reduces readability

    line 39
  2. Distinctive:

    Instead of adding explanatory comments, prefer:

    line 47

≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
avoid-unnecessary-comments.mdc
---
description: Good comment style
globs: *
---
# Avoid Unnecessary Comments

A rule to discourage adding excessive or redundant comments to the codebase.

<rule>
name: avoid_unnecessary_comments
description: Prevents redundant, obvious, or excessive comments in code

filters:
  # Apply to all code files with common extensions
  - type: file_extension
    pattern: "\\.(js|jsx|ts|tsx|py|rb|java|c|cpp|cs|go|rs|php|swift|kt)$"

actions:
  - type: reject
    conditions:
      # Look for obvious/redundant comments
      - pattern: "(?m)^\\s*(?://|/\\*|#|<!--|--) (?:This|The) \\w+ (?:function|method|class|variable)"
        message: "Avoid comments that simply state what a function/method/class/variable is"
      
      # Look for comments that just repeat the code
      - pattern: "(?m)^\\s*(?://|/\\*|#|<!--|--) (?:Increment|Decrement|Add|Set|Get|Create|Delete|Update|Remove)"
        message: "Avoid comments that just repeat what the code does - use clear naming instead"

  - type: suggest
    message: |
      # Comment Guidelines
      
      ## Avoid unnecessary comments:
      
      ❌ **Don't add comments that:**
      - State the obvious (e.g., `// increment counter`)
      - Repeat information clearly visible in the code
      - Explain WHAT the code does rather than WHY
      - Add noise that reduces readability
      
      ✅ **Do add comments when:**
      - Explaining WHY something is implemented in a certain way
      - Documenting complex business logic or algorithms
      - Noting edge cases or non-obvious behavior
      - Explaining temporary workarounds (with tickets/issues referenced)
      
      Instead of adding explanatory comments, prefer:
      - Clear, descriptive variable and function names
      - Small, focused functions with single responsibilities
      - Proper code organization and structure

examples:
  - input: |
      // This function gets the user data
      function getUserData() {
          return userData;
      }
    output: |
      function getUserData() {
          return userData;
      }
  
  - input: |
      // This implementation uses a cache to avoid expensive recalculations
      // when handling high-volume requests in production environments
      function getCachedResults(query) {
          if (cache.has(query)) {
              return cache.get(query);
          }
          const result = computeExpensiveResult(query);
          cache.set(query, result);
          return result;
      }
    output: |
      // This implementation uses a cache to avoid expensive recalculations
      // when handling high-volume requests in production environments
      function getCachedResults(query) {
          if (cache.has(query)) {
              return cache.get(query);
          }
          const result = computeExpensiveResult(query);
          cache.set(query, result);
          return result;
      }

metadata:
  priority: high
  version: 1.0
</rule>

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.