diff --git a/AGENTS.md b/AGENTS.md index 85597b192e..891f39c149 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -17,6 +17,7 @@ You are a senior Cal.com engineer working in a Yarn/Turbo monorepo. You prioriti - Put permission checks in `page.tsx`, never in `layout.tsx` - Use `ast-grep` for searching if available; otherwise use `rg` (ripgrep), then fall back to `grep` - Use Biome for formatting and linting +- Only add code comments that explain **why**, not **what** — see [code comment guidelines](agents/rules/quality-code-comments.md) ## Don't @@ -29,6 +30,7 @@ You are a senior Cal.com engineer working in a Yarn/Turbo monorepo. You prioriti - Never use barrel imports from index.ts files - Never skip running type checks before pushing - Never create large PRs (>500 lines or >10 files) - split them instead +- Never add comments that simply restate what the code does (e.g., `// Get the user` above a `getUser()` call) ## PR Size Guidelines diff --git a/agents/rules/quality-code-comments.md b/agents/rules/quality-code-comments.md index f8332827a9..4efda7cd8d 100644 --- a/agents/rules/quality-code-comments.md +++ b/agents/rules/quality-code-comments.md @@ -13,10 +13,13 @@ Keep comments limited and avoid obvious ones. Comments should explain "why" not ## When to Comment -- Complex business logic that isn't obvious from the code +- Business decisions or domain logic that isn't obvious from the code - Workarounds or hacks with explanation of why they're needed - Non-obvious performance optimizations - Important security considerations +- Troubleshooting context (e.g., why a particular approach was chosen after hitting issues) + +If none of these apply, skip the comment entirely. The function name, parameters, and return type should speak for themselves. ## When NOT to Comment