agentleFS
afaraha8403afaraha8403/balakit/.cursor/rules/comments.mdc

balakit / rules

Cursor rule1 starsChanged 2 months agoMITView on GitHub

Guidelines for code comments and documentation — document the why, not the what

The file

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

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    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:

    If removing the comment wouldn't confuse a future reader, delete it.

    line 17
  2. Distinctive:

    Every part of a module's public surface — exported functions, types, classes, constants — gets a documentation comment in your language's …

    line 39
  3. Distinctive:

    Document a parameter only when its name isn't self-explanatory.

    line 42
  4. Distinctive:

    Document the return only when it isn't obvious from the function name.

    line 43
  5. Distinctive:

    Document every error/exception the function can raise as part of its contract.

    line 44
  6. Distinctive:

    Add an example for non-trivial public APIs and shared utilities.

    line 45
  7. Distinctive:

    Don't duplicate what the language already expresses — let the type system, signatures, and tooling do their job.

    line 46
  8. Distinctive:

    When documentation strings are generated into a public API surface (OpenAPI/Swagger, SDK docs, generated reference sites, schema …

    line 50

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 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
comments.mdc
---
description: Guidelines for code comments and documentation — document the why, not the what
alwaysApply: true
---

# Comments & Documentation

## Default to zero comments

Names document code. Add an inline comment only when the WHY is non-obvious:

- A hidden constraint not visible in the code.
- A subtle invariant a reader might violate.
- A workaround for a specific bug (link the upstream issue).
- Behavior a competent reader would find surprising.

If removing the comment wouldn't confuse a future reader, delete it.

## Never write

- Restatements of the code — `increment counter` above `counter++`.
- Task / ticket references — `added for CAN-123`, `fixes billing bug`.
- Caller references — `used by the contacts module`.
- Change history — `was async before`, `removed old logic`.
- Commented-out code.
- Banner comments — `=== SECTION ===`.

## Authorized Tracking Tags (Exception)

You MUST use the following authorized tags to track technical debt and risks (as required by the Global Rules), using your language's comment syntax. These should cleanly describe the issue for IDE tracking:
- `BUG:` — For critical, immediate issues.
- `FIXME:` — For broken code or technical debt needing refactor.
- `TODO:` — For general planned work.
- `CONCERN:` — For edge cases or architectural risks.
- `OPTIMIZE:` — For performance improvements or clean-up tasks.

## Document every exported symbol

Every part of a module's public surface — exported functions, types, classes, constants — gets a documentation comment in your language's convention (doc comment, docstring, etc.). Internal/private helpers only get one when the WHY is non-obvious.

- The first line is a one-sentence summary ending with a period.
- Document a parameter only when its name isn't self-explanatory. Never restate information the signature already carries (e.g. the type, in a typed language).
- Document the return only when it isn't obvious from the function name.
- Document every error/exception the function can raise as part of its contract.
- Add an example for non-trivial public APIs and shared utilities.
- Don't duplicate what the language already expresses — let the type system, signatures, and tooling do their job.

## Externally-surfaced docs

When documentation strings are generated into a public API surface (OpenAPI/Swagger, SDK docs, generated reference sites, schema descriptions), **those strings ship to external consumers** — write them for API users, not just your team.

- Describe every public field/parameter with a short user-facing sentence.
- Map each endpoint/handler summary to the generated summary and description.
- Declare at least one example response for each public route.

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.