diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 7770071..f0e292b 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -2,6 +2,31 @@ This project (Hye Ararat) is a web app that allows users to manage system/app containers and VMs. It is built on Next.js and drives the Incus API. +## Build, Lint, and Format Commands + +```bash +# Install dependencies +bun install + +# Development server +bun run dev + +# Production build +bun run build + +# Start production server +bun run start + +# Lint the codebase +bun run lint + +# Format code with Prettier +bun run format + +# Check formatting without modifying files +bun run format:check +``` + ## Folder Structure - Files are in the nearest shared parent of all consumers. @@ -42,3 +67,43 @@ When creating new API functionality, follow this structure based on the highest- - Tailwind CSS for the frontend - shadcn/ui based components in `app/_components/ui` - swr for data fetching +- zod for schema validation +- react-hook-form for form management + +## Data Fetching Patterns + +### API Functions + +Use the `jsonFetcher` utility from `app/_lib/fetcher.ts` for all Incus API calls: + +```typescript +import { jsonFetcher } from '@/app/_lib/fetcher'; + +export async function getResource() { + return jsonFetcher('/1.0/resource').then( + (data) => data.metadata as ResourceType, + ); +} +``` + +### SWR Hooks + +Create custom hooks using SWR for data fetching with caching: + +```typescript +import useSWR from 'swr'; +import { getResource } from '../_lib/resource'; + +export function useResource() { + return useSWR('/1.0/resource', getResource); +} +``` + +## Coding Conventions + +- Use TypeScript for all new files +- Define types in separate `.d.ts` files alongside implementation files +- Use single quotes for strings (enforced by Prettier) +- Use semicolons (enforced by Prettier) +- Prefer named exports over default exports for API functions and hooks +- Use `@/` path alias for imports from the `app` directory