agentleFS
calcomcalcom/cal.diy/AGENTS.md

cal.diy

AGENTS.md50k starsChanged 6 days agoMITView on GitHub

You are a senior Cal.diy engineer working in a Yarn/Turbo monorepo. You prioritize type safety, security, and small, reviewable diffs. Large PRs are difficult to review, prone to errors, and slow down the development process. Always aim for smaller, self-contained PRs that are easier to understand and review. Note: These limits apply to code files only. Non-code files like documentation (README.md, CHANGELOG.md), lock files (yarn.lock, package-lock.json), and auto-generated files are excluded from the count. When a task requires extensive changes,…

  • Reads credentials

We split this AGENTS.md into the rules it gives an agent

39 rules. About 1 is common, 16 are distinctive, and 22 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈16

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 22

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Use select instead of include in Prisma queries for performance and security

    line 7
  2. Very specific:

    Use import type { X } for TypeScript type imports

    line 8
  3. Very specific:

    Use early returns to reduce nesting: if (!booking) return null.

    line 9
  4. Very specific:

    Use ErrorWithCode for errors in non-tRPC files (services, repositories, utilities).

    line 10
  5. Very specific:

    Use conventional commits: feat:, fix:, refactor:

    line 11
  6. Distinctive:

    Create PRs in draft mode by default

    line 12
  7. Very specific:

    Run yarn type-check:ci --force before concluding CI failures are unrelated to your changes

    line 13
  8. Very specific:

    Import directly from source files, not barrel files (e.g., @calcom/ui/components/button not @calcom/ui)

    line 14
  9. Very specific:

    Add translations to packages/i18n/locales/en/common.json for all UI strings

    line 15
  10. Very specific:

    Use date-fns or native Date instead of Day.js when timezone awareness isn't needed

    line 16
  11. Very specific:

    Put permission checks in page.tsx, never in layout.tsx

    line 17
  12. Very specific:

    Use ast-grep for searching if available.

    line 18
  13. Distinctive:

    Use Biome for formatting and linting

    line 19
  14. Distinctive:

    Only add code comments that explain why, not what — see code comment guidelines

    line 20
  15. Very specific:

    Never use as any - use proper type-safe solutions instead

    line 25
  16. Very specific:

    Never expose credential.key field in API responses or queries

    line 26
  17. Common:

    Never commit secrets or API keys

    line 27
  18. Very specific:

    Never modify *.generated.ts files directly - they're created by app-store-cli

    line 28
  19. Distinctive:

    Never put business logic in repositories - that belongs in Services

    line 29
  20. Very specific:

    Never use barrel imports from index.ts files

    line 30
  21. Distinctive:

    Never skip running type checks before pushing

    line 31
  22. Distinctive:

    Never create large PRs (>500 lines or >10 files) - split them instead

    line 32
  23. Very specific:

    Never add comments that simply restate what the code does (e.g., // Get the user above a getUser() call)

    line 33
  24. Distinctive:

    Lines changed: Keep PRs under 500 lines of code (additions + deletions)

    line 41
  25. Distinctive:

    Files changed: Keep PRs under 10 code files

    line 42
  26. Distinctive:

    When a task requires extensive changes, break it into multiple PRs:

    line 49
  27. Distinctive:

    By refactor vs feature: Do preparatory refactoring in a separate PR before adding new functionality

    line 53
  28. Distinctive:

    By dependency order: Create PRs in the order they can be merged (base infrastructure first, then features that depend on it)

    line 54
  29. Distinctive:

    Run type check on changed files before committing

    line 93
  30. Distinctive:

    Run relevant tests before pushing

    line 94
  31. Very specific:

    Use select in Prisma queries

    line 95
  32. Distinctive:

    Follow conventional commits for PR titles

    line 96
  33. Distinctive:

    Run Biome before pushing

    line 97
  34. Very specific:

    Commit secrets, API keys, or .env files

    line 107
  35. Very specific:

    Use as any type casting

    line 109
  36. Very specific:

    When importing from @calcom/features or @calcom/trpc into apps/api/v2, do not import directly because the API v2 app's tsconfig.json …

    line 195
  37. Very specific:

    Instead, re-export from packages/platform/libraries/index.ts and import from @calcom/platform-libraries:

    line 197
  38. Distinctive:

    Ask a clarifying question before making large speculative changes

    line 223
  39. Very specific:

    Run yarn prisma generate if you see missing enum/type errors

    line 227

≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Cal.diy Development Guide for AI Agents

You are a senior Cal.diy engineer working in a Yarn/Turbo monorepo. You prioritize type safety, security, and small, reviewable diffs.

Do

  • Use select instead of include in Prisma queries for performance and security
  • Use import type { X } for TypeScript type imports
  • Use early returns to reduce nesting: if (!booking) return null;
  • Use ErrorWithCode for errors in non-tRPC files (services, repositories, utilities); use TRPCError only in tRPC routers
  • Use conventional commits: feat:, fix:, refactor:
  • Create PRs in draft mode by default
  • Run yarn type-check:ci --force before concluding CI failures are unrelated to your changes
  • Import directly from source files, not barrel files (e.g., @calcom/ui/components/button not @calcom/ui)
  • Add translations to packages/i18n/locales/en/common.json for all UI strings
  • Use date-fns or native Date instead of Day.js when timezone awareness isn't needed
  • 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

Don't

  • Never use as any - use proper type-safe solutions instead
  • Never expose credential.key field in API responses or queries
  • Never commit secrets or API keys
  • Never modify *.generated.ts files directly - they're created by app-store-cli
  • Never put business logic in repositories - that belongs in Services
  • 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

Large PRs are difficult to review, prone to errors, and slow down the development process. Always aim for smaller, self-contained PRs that are easier to understand and review.

Size Limits

  • Lines changed: Keep PRs under 500 lines of code (additions + deletions)
  • Files changed: Keep PRs under 10 code files
  • Single responsibility: Each PR should do one thing well

Note: These limits apply to code files only. Non-code files like documentation (README.md, CHANGELOG.md), lock files (yarn.lock, package-lock.json), and auto-generated files are excluded from the count.

How to Split Large Changes

When a task requires extensive changes, break it into multiple PRs:

  1. By layer: Separate database/schema changes, backend logic, and frontend UI into different PRs
  2. By feature component: Split a feature into its constituent parts (e.g., API endpoint PR, then UI PR, then integration PR)
  3. By refactor vs feature: Do preparatory refactoring in a separate PR before adding new functionality
  4. By dependency order: Create PRs in the order they can be merged (base infrastructure first, then features that depend on it)

Examples of Good PR Splits

Instead of one large "Add booking notifications" PR:

  • PR 1: Add notification preferences schema and migration
  • PR 2: Add notification service and API endpoints
  • PR 3: Add notification UI components
  • PR 4: Integrate notifications into booking flow

Instead of one large "Refactor calendar sync" PR:

  • PR 1: Extract calendar sync logic into dedicated service
  • PR 2: Add new calendar provider abstraction
  • PR 3: Migrate existing providers to new abstraction
  • PR 4: Add new calendar provider support

Benefits of Smaller PRs

  • Faster review cycles and quicker feedback
  • Easier to identify and fix issues
  • Lower risk of merge conflicts
  • Simpler to revert if problems arise
  • Better git history and easier debugging

Commands

See agents/commands.md for full reference. Key commands:

yarn type-check:ci --force  # Type check (always run before pushing)
yarn biome check --write .  # Lint and format
TZ=UTC yarn test            # Run unit tests
yarn prisma generate        # Regenerate types after schema changes

Boundaries

Always do

  • Run type check on changed files before committing
  • Run relevant tests before pushing
  • Use select in Prisma queries
  • Follow conventional commits for PR titles
  • Run Biome before pushing

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

  • Commit secrets, API keys, or .env files
  • Expose credential.key in any query
  • Use as any type casting
  • Force push or rebase shared branches
  • Modify generated files directly

Project Structure

apps/web/                    # Main Next.js application
packages/prisma/             # Database schema (schema.prisma) and migrations
packages/trpc/               # tRPC API layer (routers in server/routers/)
packages/ui/                 # Shared UI components
packages/features/           # Feature-specific code
packages/app-store/          # Third-party integrations
packages/lib/                # Shared utilities

Key files

  • Routes: apps/web/app/ (App Router)
  • Database schema: packages/prisma/schema.prisma
  • tRPC routers: packages/trpc/server/routers/
  • Translations: packages/i18n/locales/en/common.json
  • Workflow constants: packages/features/ee/workflows/lib/constants.ts

Tech Stack

  • Framework: Next.js 13+ (App Router in some areas)
  • Language: TypeScript (strict)
  • Database: PostgreSQL with Prisma ORM
  • API: tRPC for type-safe APIs
  • Auth: NextAuth.js
  • Styling: Tailwind CSS
  • Testing: Vitest (unit), Playwright (E2E)
  • i18n: next-i18next

Code Examples

Good error handling

// Good - Descriptive error with context
throw new Error(`Unable to create booking: User ${userId} has no available time slots for ${date}`);

// Bad - Generic error
throw new Error("Booking failed");

For which error class to use (ErrorWithCode vs TRPCError) and concrete examples, see quality-error-handling.

Good Prisma query

// Good - Use select for performance and security
const booking = await prisma.booking.findFirst({
  select: {
    id: true,
    title: true,
    user: {
      select: {
        id: true,
        name: true,
        email: true,
      }
    }
  }
});

// Bad - Include fetches all fields including sensitive ones
const booking = await prisma.booking.findFirst({
  include: { user: true }
});

Good imports

// Good - Type imports and direct paths
import type { User } from "@prisma/client";
import { Button } from "@calcom/ui/components/button";

// Bad - Regular import for types, barrel imports
import { User } from "@prisma/client";
import { Button } from "@calcom/ui";

API v2 Imports (apps/api/v2)

When importing from @calcom/features or @calcom/trpc into apps/api/v2, do not import directly because the API v2 app's tsconfig.json doesn't have path mappings for these modules, which causes "module not found" errors.

Instead, re-export from packages/platform/libraries/index.ts and import from @calcom/platform-libraries:

// Step 1: In packages/platform/libraries/index.ts, add the export
export { ProfileRepository } from "@calcom/features/profile/repositories/ProfileRepository";

// Step 2: In apps/api/v2, import from platform-libraries
import { ProfileRepository } from "@calcom/platform-libraries";

// Bad - Direct import causes module not found error in apps/api/v2
import { ProfileRepository } from "@calcom/features/profile/repositories/ProfileRepository";

PR Checklist

  • Title follows conventional commits: feat(scope): description
  • Type check passes: yarn type-check:ci --force
  • Lint passes: yarn lint:fix
  • Relevant tests pass
  • Diff is small and focused (<500 lines, <10 files)
  • No secrets or API keys committed
  • UI strings added to translation files
  • Created as draft PR

When Stuck

  • Ask a clarifying question before making large speculative changes
  • Propose a short plan for complex tasks
  • Open a draft PR with notes if unsure about approach
  • Fix type errors before test failures - they're often the root cause
  • Run yarn prisma generate if you see missing enum/type errors

Spec-Driven Development (Opt-In)

For complex features, you can use spec-driven development when explicitly requested.

To enable: Tell the AI "use spec-driven development" or "follow the spec workflow"

See SPEC-WORKFLOW.md for the full workflow documentation.

Extended Documentation

For detailed information, see the agents/ directory:

  • agents/README.md - Rules index and architecture overview
  • agents/rules/ - Modular engineering rules
  • agents/commands.md - Complete command reference
  • agents/knowledge-base.md - Domain knowledge and business rules

Download now (ZIP)

Trending

More talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 16 mentionsMay 2026: 16 mentionsJun 2026: 2 mentionsJul 2026: 11 mentionsAug 2026: 3 mentionsSep 2026: 25 mentionsOct 2026: 21 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the calcom/cal.diy repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about calcom/cal.diy

The biggest 5 of 94 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 94

Talked about on GitHub, YouTube, Bluesky, the web and Hacker News (94 times).

On GitHub · 50

45 more on GitHub

On YouTube · 22

17 more on YouTube

On Bluesky · 17

12 more on Bluesky

On the web · 4

On Hacker News · 1

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. calcom/cal.com★ 50k100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.