Core Principles
As a Cal.com contributor, you should prioritize:- Type Safety - Use TypeScript strictly, avoid
any - Security - Never expose sensitive data or credentials
- Small PRs - Keep changes focused and reviewable (<500 lines, <10 files)
- Code Quality - Write clean, maintainable code that explains “why”, not “what”
Do’s and Don’ts
Always Do
Use
select instead of include in Prisma queriesUse
import type { X } for TypeScript type importsUse early returns to reduce nesting
Use
ErrorWithCode for non-tRPC errors, TRPCError for tRPC routersUse conventional commits:
feat:, fix:, refactor:Import directly from source files, not barrel files
Add translations to
packages/i18n/locales/en/common.jsonUse
date-fns or native Date when timezone awareness isn’t neededPut permission checks in
page.tsx, never in layout.tsxUse Biome for formatting and linting
Run
yarn type-check:ci --force before pushingNever Do
TypeScript Best Practices
Type Imports
Avoid any
Use Early Returns
Prisma Best Practices
Use select Over include
Using
select improves performance and prevents accidental exposure of sensitive data like credential.key.Never Expose Credentials
Import Best Practices
Direct Imports, Not Barrel Files
API v2 Imports
When importing intoapps/api/v2, re-export from platform libraries:
Error Handling
Use Appropriate Error Classes
Descriptive Error Messages
Always provide context in error messages:File Naming Conventions
Services
Repositories
- File names must match exported class names exactly (PascalCase)
- Avoid dot-suffixes like
.service.tsor.repository.ts(legacy patterns) - Reserve suffixes for
.test.ts,.spec.ts, and.types.ts
Code Comments
Only add comments that explain why, not what.Internationalization
Add all UI strings to translation files:Conventional Commits
Use conventional commit format for PR titles:<type>(<scope>): <description>
Types:
feat- New featurefix- Bug fixrefactor- Code refactoringdocs- Documentation changestest- Adding/updating testschore- Maintenance tasks
PR Size Guidelines
Keep PRs small and focused for faster reviews and easier debugging.Size Limits
- Lines changed: <500 lines of code
- Files changed: <10 code files
- Single responsibility: Each PR should do one thing well
These limits exclude documentation, lock files, and auto-generated files.
Splitting Large Changes
By layer:Testing Requirements
Before Committing
Before Pushing
Security Guidelines
Never Commit Secrets
Validate User Input
Sanitize Output
Boundaries
Ask First
- Adding new dependencies
- Schema changes to
packages/prisma/schema.prisma - Changes affecting multiple packages
- Deleting files
- Running full build or E2E suites
Never Do Without Permission
- Commit secrets or API keys
- Force push to shared branches
- Modify generated files directly
- Expose sensitive data in APIs
PR Checklist
Before submitting a PR:Code Review Guidelines
As a Contributor
- Respond to feedback promptly
- Ask questions if feedback is unclear
- Update your branch regularly
- Test suggested changes before pushing
As a Reviewer
- Be respectful and constructive
- Explain the “why” behind suggestions
- Approve when ready, don’t nitpick
- Use “Request changes” sparingly
Resources
- AGENTS.md - AI development guidelines
- agents/rules/ - Modular engineering rules
- agents/commands.md - Command reference
Next Steps
- Learn about Testing Practices
- Review Development Setup
- Explore Architecture Overview