Skip to content

chore: Testing out AI instructions for shorter comments - #11438

Draft
alin-at-dfinity wants to merge 1 commit into
masterfrom
alin/shorter-comments
Draft

chore: Testing out AI instructions for shorter comments#11438
alin-at-dfinity wants to merge 1 commit into
masterfrom
alin/shorter-comments

Conversation

@alin-at-dfinity

Copy link
Copy Markdown
Contributor

[DO NOT MERGE. This is just for reference.]

I asked Claude to rewrite the comments for commit e120aa1 given its current local rules, pointing out that I had modified ~/.claude/CLAUDE.md. This is the result.

For reference, here are the instructions if you want to iterate on them (tweak the rules, then pick a commit you don't like and ask Claude to redo the comments):

# Be very concise

Try very, very hard to be as concise as you can when writing documents or comments; and when chatting. Unless it's really necessary to refer to some other concept / comment / document section, prefer not to. Definitely do not explain the same concept repeatedly, in multiple locations. Explain it once and simply mention it when actually necessary (i.e. when the statement you are making is likely to be hard to understand without this extra context).

# Comments / Doc comments

- **Why, Not What:** Never comment *what* the code is doing (e.g., avoid `// Reset foo`). Comment only *why* it is being done, or the non-obvious architectural context.
- **Micro-Comments Only:** Keep inline comments to one or two hyper-focused lines. No multi-paragraph prose blocks.
- **High Signal-to-Noise:** If the code is clear, write zero comments. With very few exceptions, there should be more code than documentation. Else, the code is likely too opaque and needs refactoring.
- **Context:** Comments must make sense to a future reader in the context of all of the surrounding code (and codebase), NOT in the context of the changes being made now. Code represents the current state; let git handle history.
- **Hierarchy of Detail:** Where context is needed (e.g. "the resources returned here were reserved when...") provide it at the highest appropriate level (e.g. describe the resource reservation model once in the module or crate doc comment, instead of selective bits across function or inline comments). Expect future readers to acquire the full context by reading the documentation of the full hierarchy.

[I've had the first section for a while now, the rest I just added. I left it all in just in case you tested out the new instructions only and got very different results. I suspect we could get rid of the first.]

I asked Claude to rewrite the comments for commit e120aa1 given its current local rules, pointing out that I had modified `~/.claude/CLAUDE.md`. This is the result.

For reference, here are the instructions (first section has been there for a while now, the rest I just added) if you want to iterate on them (tweak the rules, then pick a commit you don't like and ask Claude to redo the comments):

```md

Try very, very hard to be as concise as you can when writing documents or comments; and when chatting. Unless it's really necessary to refer to some other concept / comment / document section, prefer not to. Definitely do not explain the same concept repeatedly, in multiple locations. Explain it once and simply mention it when actually necessary (i.e. when the statement you are making is likely to be hard to understand without this extra context).

- **Why, Not What:** Never comment *what* the code is doing (e.g., avoid `// Reset foo`). Comment only *why* it is being done, or the non-obvious architectural context.
- **Micro-Comments Only:** Keep inline comments to one or two hyper-focused lines. No multi-paragraph prose blocks.
- **High Signal-to-Noise:** If the code is clear, write zero comments. With very few exceptions, there should be more code than documentation. Else, the code is likely too opaque and needs refactoring.
- **Context:** Comments must make sense to a future reader in the context of all of the surrounding code (and codebase), NOT in the context of the changes being made now. Code represents the current state; let git handle history.
- **Hierarchy of Detail:** Where context is needed (e.g. "the resources returned here were reserved when...") provide it at the highest appropriate level (e.g. describe the resource reservation model once in the module or crate doc comment, instead of selective bits across function or inline comments). Expect future readers to acquire the full context by reading the documentation of the full hierarchy.
```
@github-actions github-actions Bot added the chore label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant