From 177c2e71767d261c911538734e83ed5f3ce109da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20J=C3=A4derberg?= Date: Mon, 8 Dec 2025 12:23:22 +0000 Subject: [PATCH] Merged in feature/ai-instructions (pull request #3293) chore: add ai instruction files * chore: add ai instruction files * let the instruction file apply to all files, not only ts files Approved-by: Linus Flood --- .github/copilot-instructions.md | 45 +++++++++++++++++++ .../instructions/redis-api.instructions.md | 16 +++++++ 2 files changed, 61 insertions(+) create mode 100644 .github/copilot-instructions.md create mode 100644 .github/instructions/redis-api.instructions.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 000000000..e6b8d1a86 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,45 @@ +--- +applyTo: "{apps/scandic-web/**/*,apps/partner-sas/**/*,apps/scandic-redirect/**/*,packages/**/*}" +--- + +# Monorepo and Project Overview + +**OVERVIEW:** This is a monorepository managed by **[Turborepo]** containing Next.js applications and several shared internal packages. + +**PROJECT STRUCTURE:** + +- `/apps/*`: Where public-facing applications live. + - `/apps/scandic-web`: The public-facing site for Scandic Hotels. Displaing cms content from Contentstack, a hotel room booking flow, and user profile management. Hosted on Netlify. + - `/apps/partner-sas`: A whitelabel version of the Scandic site for SAS customers that mostly relates to booking a hotel room. Hosted on Netlify + - `/apps/scandic-redirect`: A service for handling redirects when a url doesn' + t match any static content or a page in Contentstack. Hosted on Netlify + - `/apps/redis-api`: An api that acts as a http front to Redis due to serveless constraints. Hosted as a container app in Azure. +- `/packages/*`: Where shared code and utilities are stored. They are built with `transpilePackages` so they do not have their own build pipeline + - `/packages/design-system`: Shared React/UI components hosted as a Storybook. + - `/packages/trpc`: Shared trpc routers and logic. + - `/packages/tracking`: Shared tracking utilities and analytics. + - `/packages/booking-flow`: The main revenue-generating part where you find booking flow logic and related components. + +**INSTRUCTIONS FOR GENERATION:** + +1. **Shared Code:** When generating code that could be reusable (components, hooks, utility functions, types), check the `/packages` directory for existing files. If a new, shared piece of logic is needed, generate it within the appropriate `/packages` subdirectory. +2. **Imports:** All imports from shared packages must use the configured package name (e.g., `import { Button } from '@repo/ui'`). **Do not use relative paths** to import code between apps and packages. +3. **Dependency Manager:** All package installations, script commands, and documentation examples must use **Yarn**. +4. **Testing:** All unit testing must use **Vitest**. + +## Next.js & React Best Practices + +**FRAMEWORK:** Next.js (Use **App Router**) and React. +**LANGUAGE:** TypeScript with strict mode enabled. + +**COMPONENTS:** + +1. **Default to Server Components:** All components in the `/app` directory are **Server Components** by default. Only use `'use client'` when necessary for interactivity (hooks, event handlers, etc.). +2. **Styling:** Use **Css Modules**. +3. **Immutability:** Never mutate props or state directly. Always return new objects or arrays for updates. +4. **Data Fetching** All client-side and server-side data fetching logic should use types and procedures defined in the shared /packages/trpc + +**FILE NAMING:** + +- Components: `PascalCase` (`ProductCard.tsx`). +- Hooks: `camelCase` and start with `use` (`useUser.ts`). diff --git a/.github/instructions/redis-api.instructions.md b/.github/instructions/redis-api.instructions.md new file mode 100644 index 000000000..2e178a2b8 --- /dev/null +++ b/.github/instructions/redis-api.instructions.md @@ -0,0 +1,16 @@ +--- +applyTo: "apps/redis-api/**/*.ts" +--- + +# ⚙️ Redis API Specific Instructions + +**CONTEXT:** This is a dedicated, Bun HTTP API, deployed as a container app in Azure. It acts as an HTTP proxy/cache layer for a Redis instance. + +**INSTRUCTIONS FOR GENERATION:** + +1. **Framework:** This code uses **Elysia**. **DO NOT** generate React, Next.js, or browser-side code. +2. **Language:** Always use pure **TypeScript**. Do not use `.tsx` files. +3. **Data Models:** Always use **t** from **Elysia** i.e. `import { t } from "elysia";` for schema definition and runtime validation of incoming request bodies and query parameters. +4. **Security:** Ensure all generated endpoints follow RESTful conventions and include necessary request validation and authorization checks. +5. **Redis:** Code must use the official `ioredis` library for interaction. +6. **Logging:** Use **loggerModule** or **baseLogger** for all informational, warning, and error messages.