|
| 1 | +# Copilot Instructions for jore4-ui |
| 2 | + |
| 3 | +These instructions define how AI coding assistants should work in this repository. |
| 4 | +Follow them for all code edits unless the user explicitly asks otherwise. |
| 5 | + |
| 6 | +## 1) Repository context |
| 7 | + |
| 8 | +- Monorepo with Yarn workspaces. |
| 9 | +- Main workspaces: |
| 10 | + - `ui` (main application) |
| 11 | + - `cypress` (e2e tests) |
| 12 | + - `codegen` (GraphQL code generation) |
| 13 | + - `test-db-manager` (test DB tooling) |
| 14 | + - `timetables-data-inserter` (submodule) |
| 15 | +- Prefer workspace-scoped commands (`yarn ws:...`) when possible. |
| 16 | + |
| 17 | +## 2) Default development workflow |
| 18 | + |
| 19 | +- Prefer day-to-day development flow: |
| 20 | + - `yarn ws:ui dev` |
| 21 | + - Run GraphQL generation manually when needed: `yarn ws:codegen generate` |
| 22 | +- Avoid defaulting to `yarn dev` for normal edits because continuous codegen can heavily degrade IDE performance. |
| 23 | +- If test-db seed data is changed, rebuild with `yarn ws:db build`. |
| 24 | + |
| 25 | +## 3) Environment and dependencies |
| 26 | + |
| 27 | +- For local backend dependencies, use `./scripts/development.sh` commands (for example `start:deps`, `setup:env`, `setup:test`, `stop`). |
| 28 | +- Do not introduce alternative local orchestration scripts if existing script targets are sufficient. |
| 29 | +- Assume UI runs on `http://localhost:3300` when using local dev server. |
| 30 | + |
| 31 | +## 4) Quality gates and verification |
| 32 | + |
| 33 | +Before finalizing a non-trivial change, run the smallest relevant checks first, then broaden only as needed: |
| 34 | + |
| 35 | +1. Targeted checks for changed area (tests/lint where applicable) |
| 36 | +2. Type checking: `yarn ts:check` |
| 37 | +3. Linting: `yarn lint` (or `yarn lint --fix` when safe) |
| 38 | +4. Formatting: `yarn prettier:check` (or `yarn prettier` when formatting is required) |
| 39 | + |
| 40 | +Use `yarn qa` for full local validation when appropriate. |
| 41 | +Use `yarn qa:fix` for automatic eslint/prettier fixes. |
| 42 | + |
| 43 | +## 5) Testing guidance |
| 44 | + |
| 45 | +- Unit/local tests: `yarn test` |
| 46 | +- Integration tests (require Hasura/deps running): `yarn test:integration` |
| 47 | +- E2E tests: |
| 48 | + - Open mode: `yarn test:e2e:open` |
| 49 | + - Headless: `yarn test:e2e` |
| 50 | + - Tag filtering example: `yarn test:e2e --env grepTags=@routes` |
| 51 | +- For map-related Cypress reliability/speed, optionally set `CYPRESS_DISABLE_MAP_TILES=true`. |
| 52 | +- When adding or changing user-interactive UI elements, include stable `data-testid` attributes. |
| 53 | + |
| 54 | +## 6) GraphQL codegen rules |
| 55 | + |
| 56 | +- GraphQL typings are generated from Hasura schema and `gql` definitions. |
| 57 | +- Because generation is heavy in this repo, prefer manual generation after finishing query edits: |
| 58 | + - `yarn ws:codegen generate` |
| 59 | +- Do not set up automatic codegen watch flows unless explicitly requested. |
| 60 | + |
| 61 | +## 7) Code style conventions |
| 62 | + |
| 63 | +### General |
| 64 | + |
| 65 | +- Keep changes minimal and scoped to the task. |
| 66 | +- Follow existing TypeScript/React patterns in the touched area. |
| 67 | +- Prefer editor/CI-aligned formatting and lint behavior over custom style choices. |
| 68 | + |
| 69 | +### Components |
| 70 | + |
| 71 | +- Avoid inline child components unless necessary; prefer extracted components. |
| 72 | +- Keep components composable and loosely coupled. |
| 73 | + |
| 74 | +### Imports |
| 75 | + |
| 76 | +- Prefer namespaced/barrel imports where available instead of fragmented deep imports. |
| 77 | + |
| 78 | +### Test IDs |
| 79 | + |
| 80 | +- Use `data-testid` for important interaction elements. |
| 81 | +- Follow naming convention: `ComponentName::camelCaseElementName`. |
| 82 | +- Define test IDs via a top-level `const testIds = { ... }` object instead of inline string literals where practical. |
| 83 | + |
| 84 | +### Tailwind class composition |
| 85 | + |
| 86 | +- Use `twJoin` for simple class concatenation and pass-through patterns. |
| 87 | +- Use `twMerge` as final composition step when conflicting utility classes are possible. |
| 88 | +- Do not rely on raw class order alone for override behavior. |
| 89 | + |
| 90 | +## 8) Workspace dependency management |
| 91 | + |
| 92 | +- Install workspace-specific dependencies into the correct workspace. |
| 93 | +- Install shared dependencies in repository root only when truly shared. |
| 94 | +- Do not move lint/prettier config out of root without explicit request. |
| 95 | + |
| 96 | +## 9) Git workflow |
| 97 | + |
| 98 | +- The user always makes git commits themselves. Never commit or offer to commit on behalf of the user. |
| 99 | + |
| 100 | +## 10) Operational guardrails for AI edits |
| 101 | + |
| 102 | +- Do not refactor unrelated areas. |
| 103 | +- Do not add new frameworks, state libraries, or architectural patterns without request. |
| 104 | +- Do not rewrite existing scripts when existing `yarn` and `development.sh` flows solve the task. |
| 105 | +- Keep generated-file churn minimal; regenerate only when required by changes. |
| 106 | +- When uncertain about behavior that depends on running services (Hasura, Docker stack, db seeds), state assumptions and choose the safest minimal change. |
| 107 | +- Avoid writing unnecessary comments. Explain your changes in chat instead of code comments. |
| 108 | +- Comments should be added only if they provide value beyond what the code itself can express. If you think a comment is needed, consider whether the code can be refactored to be more self-explanatory instead. |
| 109 | + |
| 110 | +## 11) Helpful commands reference |
| 111 | + |
| 112 | +- Dev UI only: `yarn ws:ui dev` |
| 113 | +- Full dev (heavy): `yarn dev` |
| 114 | +- GraphQL codegen: `yarn ws:codegen generate` |
| 115 | +- Build test DB manager: `yarn ws:db build` |
| 116 | +- Type check: `yarn ts:check` |
| 117 | +- Lint: `yarn lint` |
| 118 | +- Format check: `yarn prettier:check` |
| 119 | +- Full QA: `yarn qa` |
| 120 | +- Unit tests: `yarn test` |
| 121 | +- Integration tests: `yarn test:integration` |
| 122 | +- E2E tests: `yarn test:e2e` |
| 123 | +- Start dependencies: `./scripts/development.sh start:deps` |
| 124 | +- Stop dependencies: `./scripts/development.sh stop` |
0 commit comments