knowledge-base
This file contains domain knowledge about the Cal.diy product and codebase. For coding…
**Impact: CRITICAL**
$ npx -y skills add calcom/cal.diy --agent claude-codeHow it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
**Impact: CRITICAL**
title: Prevent Circular Dependencies Between Packages impact: CRITICAL impactDescription: Prevents build failures, type errors, ensures honest implementation, and maintains clean dependency graph tags: architecture, dependencies, packages, imports, circular
**Impact: CRITICAL**
Circular dependencies between packages cause build failures, type errors, and make the codebase unmaintainable. The dependency graph must be acyclic, with clear layers from low-level utilities up to high-level features.
The dependency hierarchy (from lowest to highest):
packages/lib (lowest - no feature dependencies) ↓ packages/app-store ↓ packages/features ↓ packages/trpc ↓ apps/web (highest - can depend on all packages)
**Benefits:**
**Rules:** 1. No files in `packages/lib` import from `@calcom/app-store` or `../app-store/**` 2. No files in `packages/lib` import from `@calcom/features` or `../features/**` 3. No files in `packages/lib` import from `@calcom/trpc` or `../trpc/**` 4. No files in `packages/lib` import from `@trpc/server` 5. **BONUS:** No repository files allowed in `packages/lib` (repositories belong in features or app-store)
**Incorrect:**
// Bad - lib importing from features
import { getBooking } from "@calcom/features/bookings";
import { EventRepository } from "@calcom/features/events/repositories";
// Bad - lib importing from app-store
import { googleCalendarHandler } from "@calcom/app-store/googlecalendar";
// Bad - lib importing from trpc
import { router } from "@calcom/trpc/server/trpc";**Correct:**
// Good - lib only imports from other lib files or external packages
import { logger } from "@calcom/lib/logger";
import { prisma } from "@calcom/prisma";
import type { User } from "@prisma/client";**Rules:** 6. No files in `packages/app-store` import from `@calcom/features` or `../features/**` 7. No files in `packages/app-store` import from `@calcom/trpc` or `../trpc/**`
**Incorrect:**
// Bad - app-store importing from features
import { BookingService } from "@calcom/features/bookings/services";
// Bad - app-store importing from trpc
import { publicProcedure } from "@calcom/trpc/server/trpc";**Correct:**
// Good - app-store imports from lib and prisma
import { logger } from "@calcom/lib/logger";
import { prisma } from "@calcom/prisma";
import type { Credential } from "@prisma/client";**Rules:** 8. No files in `packages/features` import from `@calcom/trpc` or `../trpc/**` 9. No files in `packages/features` import from `@calcom/web` or `@calcom/web/**` 10. No files in `packages/features` import from `../../apps/web/**`
**Incorrect:**
// Bad - features importing from trpc
import { router } from "@calcom/trpc/server/trpc";
// Bad - features importing from web app
import { getServerSession } from "@calcom/web/lib/auth";
import { WebComponent } from "../../apps/web/components/WebComponent";**Correct:**
// Good - features import from lib, app-store, and prisma
import { logger } from "@calcom/lib/logger";
import { prisma } from "@calcom/prisma";
import { googleCalendarHandler } from "@calcom/app-store/googlecalendar";**Rules:** 11. No files in `packages/trpc` import from `../apps/web/**`
**Incorrect:**
// Bad - trpc importing from web app
import { getServerSession } from "../../apps/web/lib/auth";**Correct:**
// Good - trpc imports from features, lib, and prisma
import { BookingService } from "@calcom/features/bookings/services";
import { logger } from "@calcom/lib/logger";
import { prisma } from "@calcom/prisma";**Rules:** 12. No files in `packages/testing` import from `@calcom/web` or `@calcom/web/**` 13. No files in `packages/testing` import from `@calcom/features` or `@calcom/features/**` 14. No files in `packages/testing` import from `../../apps/web/**` 15. No files in `packages/testing` import from `../features/**`
**Incorrect:**
// Bad - testing importing from web or features
import { WebComponent } from "@calcom/web/components";
import { BookingService } from "@calcom/features/bookings";**Correct:**
// Good - testing imports from lib and prisma
import { prisma } from "@calcom/prisma";
import { logger } from "@calcom/lib/logger";**Rules:** 16. No files in `packages/platform/atoms` import from `@calcom/trpc` or `@calcom/trpc/**` 17. No files in `packages/platform/atoms` import from `../../trpc` or `../../trpc/**` 18. No files in `packages/platform/atoms` import from `@calcom/web`
**Incorrect:**
// Bad - platform/atoms importing from trpc or web
import { router } from "@calcom/trpc/server/trpc";
import { trpc } from "../../trpc";
import { WebComponent } from "@calcom/web";**Correct:**
// Good - platform/atoms imports from lib, features, and ui
import { logger } from "@calcom/lib/logger";
import { Button } from "@calcom/ui/components/button";
import type { Booking } from "@calcom/features/bookings/types";These rules should be enforced through:
Repo: calcom/cal.com
This file contains domain knowledge about the Cal.diy product and codebase. For coding…
The `packages/features` package should contain only framework-agnostic code: - Repositories…
**Impact: CRITICAL (Prevents unauthorized access to sensitive data)**