diff --git a/CLAUDE.md b/CLAUDE.md index 372835818e..e088e57021 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -140,6 +140,39 @@ seems like it should use `time.Sleep`, read through https://github.com/coder/qua - Follow [Uber Go Style Guide](https://github.com/uber-go/guide/blob/master/style.md) - Commit format: `type(scope): message` +### Writing Comments + +Code comments should be clear, well-formatted, and add meaningful context. + +**Proper sentence structure**: Comments are sentences and should end with +periods or other appropriate punctuation. This improves readability and +maintains professional code standards. + +**Explain why, not what**: Good comments explain the reasoning behind code +rather than describing what the code does. The code itself should be +self-documenting through clear naming and structure. Focus your comments on +non-obvious decisions, edge cases, or business logic that isn't immediately +apparent from reading the implementation. + +**Line length and wrapping**: Keep comment lines to 80 characters wide +(including the comment prefix like `//` or `#`). When a comment spans multiple +lines, wrap it naturally at word boundaries rather than writing one sentence +per line. This creates more readable, paragraph-like blocks of documentation. + +```go +// Good: Explains the rationale with proper sentence structure. +// We need a custom timeout here because workspace builds can take several +// minutes on slow networks, and the default 30s timeout causes false +// failures during initial template imports. +ctx, cancel := context.WithTimeout(ctx, 5*time.Minute) + +// Bad: Describes what the code does without punctuation or wrapping +// Set a custom timeout +// Workspace builds can take a long time +// Default timeout is too short +ctx, cancel := context.WithTimeout(ctx, 5*time.Minute) +``` + ## Detailed Development Guides @.claude/docs/ARCHITECTURE.md