Rental SaaS Demo - Claude Agent Rules
Goal
Deliver the BUILD_PLAN in phase order while protecting tenant isolation and compliance requirements.
Global Engineering Rules
- Keep implementation aligned with the monorepo plan in BUILD_PLAN.md.
- Do not introduce cross-tenant data access. Every data path must be organization scoped.
- Prefer simple managed infrastructure choices over custom platform engineering.
- Keep feature flags database-backed and environment-aware.
- Add tests for behavior changes, especially security and isolation logic.
Backend Rules
- Use NestJS module boundaries by feature under apps/api/src/modules.
- Use Prisma as the single data access layer.
- Never execute bare Prisma queries that bypass organization filters.
- Keep auth-protected endpoints behind JWT guard unless explicitly public.
- Log sensitive actions through AuditLog service.
Tenant Isolation Rules
- All tenant data models must include organizationId.
- Prisma middleware must inject organization constraints on read and write operations.
- Tenant context must come from AsyncLocalStorage request context, not from client body.
- Any exception to tenant filter rules must be documented in code comments and tests.
AI Integration Rules
- Default model for this demo is gemini-2.0-flash.
- Persist AI outputs to domain entities and log the execution in AuditLog.
- Include user-facing disclaimer for generated screening and lease output.
- Handle API failures gracefully and return safe errors.
Frontend Rules
- Build App Router pages under apps/web/app as planned.
- Keep auth flow and API client behavior consistent across routes.
- Provide explicit loading, empty, and error states.
- Guard private routes and redirect on unauthorized responses.
Infrastructure and Delivery Rules
- Keep IaC under infra with comments for Canadian data residency.
- CI must block merge on lint, test, and build failures.
- Keep deploy workflows explicit and reversible.
Source Control Safety Rules
- Never push to remote unless the user explicitly asks for push.
- Never create or modify tags unless the user explicitly asks.
- Before any commit or push, summarize intended changes and wait for user confirmation.
Secret and Environment File Rules
- Never commit or push .env files or secret-bearing local config files.
- Keep only safe templates like .env.example in version control.
- If a secret is found in tracked files, stop and notify the user immediately.
Done Criteria (Global)
- Phase artifact exists in expected path.
- Behavior is tested or validated with reproducible steps.
- No security regression for tenant isolation.
- Documentation updated when assumptions change.