Skip to main content

Core Principles

As a Cal.com contributor, you should prioritize:
  1. Type Safety - Use TypeScript strictly, avoid any
  2. Security - Never expose sensitive data or credentials
  3. Small PRs - Keep changes focused and reviewable (<500 lines, <10 files)
  4. 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 queries
Use import type { X } for TypeScript type imports
Use early returns to reduce nesting
Use ErrorWithCode for non-tRPC errors, TRPCError for tRPC routers
Use conventional commits: feat:, fix:, refactor:
Import directly from source files, not barrel files
Add translations to packages/i18n/locales/en/common.json
Use date-fns or native Date when timezone awareness isn’t needed
Put permission checks in page.tsx, never in layout.tsx
Use Biome for formatting and linting
Run yarn type-check:ci --force before pushing

Never Do

Never use as any - use proper type-safe solutions
Never expose credential.key field in API responses
Never commit secrets, API keys, or .env files
Never modify *.generated.ts files directly
Never put business logic in repositories
Never use barrel imports from index.ts files
Never skip running type checks before pushing
Never create large PRs (>500 lines or >10 files)
Never add comments that restate what code does

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 into apps/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.ts or .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:
Format: <type>(<scope>): <description> Types:
  • feat - New feature
  • fix - Bug fix
  • refactor - Code refactoring
  • docs - Documentation changes
  • test - Adding/updating tests
  • chore - 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:
By feature component:
By refactor vs feature:

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

Next Steps