Skip to content

Commit 8ee7b12

Browse files
authored
docs: add review rules for agents (calcom#22527)
1 parent afe5fea commit 8ee7b12

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

.cursor/rules/review.mdc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Review Instructions
2+
3+
- Prefer early returns. It is recommended to throw/return early so we can ensure null-checks and prevent further nesting.
4+
- Prefer Composition over Prop Drilling. Instead of relying on prop drilling, let's try to take advantage of react children feature.
5+
- For Prisma queries:
6+
- Only select data you need
7+
1) Increased performance overhead: When you select all columns from a table, Prisma retrieves all the data associated with each row, which can result in a significant performance impact. This includes reading unnecessary columns and transferring a large volume of data between your application and the database.
8+
2) Unnecessary data exposure: Selecting all columns exposes sensitive data that might not be required by your application. This can pose security risks, especially if the table contains sensitive user information or proprietary data. (In our case app credentials and booking information)
9+
- TLDR: Never use Includes - use select
10+
- Select selects only the fields you specify explicitly
11+
- Include selects the relationship AND all the fields of the table the relationship belongs to
12+
- Make sure the credential.key field is never returned back from tRPC endpoints or APIs
13+
- Always use t() for text localization in frontend code; direct text embedding should trigger a warning.
14+
- Check if there's any O(n^2) logic in backend code; we should aim for O(n log n) or O(n) ideally.
15+
- Check if there are circular references introduced. We should never allow these.
16+
- Flag excessive Day.js use in performance-critical code. Functions like `.add`, `.diff`, `.isBefore`, and `.isAfter` are slow, especially in timezone mode. Prefer `.utc()` for better performance. Where possible, replace with native Date and direct `.valueOf()` comparisons for faster execution. Recommend using native methods or Day.js `.utc()` consistently in hot paths like loops.
17+
- When docs changes are made in /docs/api-reference/v2/openapi.json, ensure the following
18+
- "summary" fields are short and concise
19+
- "summary" fields do not end with a period
20+
- "summary" fields are written in proper American english
21+
- When changes to API v2 or v1 are made, ensure there are no breaking changes on existing endpoints. Instead, there needs to be a newly versioned endpoint with the updated functionality but the old one must remain functional

0 commit comments

Comments
 (0)