π§Ή split AGENTS.md monolith into loadable skill files
Browse files at this commit1f9dcb1581933c095943f8ec6c1c1d0bd5a60664Parent: b695a7e- refactor
- π§Ή split AGENTS.md monolith into loadable skill files
7 changed files +252 -198
- .claude/skills/api-layer/SKILL.md +24 -0
- .claude/skills/commit-workflow/SKILL.md +38 -0
- .claude/skills/dashboard-design/SKILL.md +20 -0
- .claude/skills/solidjs-pitfalls/SKILL.md +40 -0
- .claude/skills/ui-conventions/SKILL.md +44 -0
- AGENTS.md +70 -198
- CLAUDE.md +16 -0
.claude/skills/api-layer/SKILL.mdadded+24 -0
| @@ -0,0 +1,24 @@ | |||
| 1 | +--- | ||
| 2 | +name: api-layer | ||
| 3 | +description: Structure and mandatory-test rules for the src/api/ layer in hezarfen_frontend β domain folders, one verb-first file per endpoint, index re-exports, fetch only in client.ts, and required vitest tests per domain. Load before adding or changing any API endpoint file. | ||
| 4 | +--- | ||
| 5 | + | ||
| 6 | +# API layer | ||
| 7 | + | ||
| 8 | +## Structure | ||
| 9 | + | ||
| 10 | +- Domain-based folders under `src/api/` (e.g. `src/api/notes/`, `src/api/exams/`). | ||
| 11 | +- One file per request under its domain folder, camelCase and verb-first, mirroring the endpoint exactly: `src/api/notes/getNoteById.ts`, `src/api/exams/deleteExamResultByUserId.ts`. | ||
| 12 | +- Each file exports exactly one function matching its filename. | ||
| 13 | +- Each domain must have an `index.ts` re-exporting its endpoints. | ||
| 14 | +- Only `src/api/client/client.ts` calls `fetch` directly. Pages/components never call `fetch` β they call `src/api/<domain>` functions inside `createResource`. | ||
| 15 | + | ||
| 16 | +## Tests β mandatory | ||
| 17 | + | ||
| 18 | +Every new or modified API endpoint file must have a corresponding test file at `src/api/__tests__/<domain>/<domain>.test.ts` (one test file per domain, not per endpoint). | ||
| 19 | + | ||
| 20 | +- Use **vitest** (globals enabled) and shared helpers from `src/api/__tests__/helpers/mock-fetch.ts`: `mockFetchSuccess`, `mockFetch204`, `mockFetchError`, `lastFetchCall`. | ||
| 21 | +- Each test asserts correct URL, HTTP method, and request body (when applicable). | ||
| 22 | +- `afterEach` must call `vi.restoreAllMocks()`. | ||
| 23 | +- Run `bun run test` before committing. | ||
| 24 | +- Do not skip or defer API tests β they are part of the definition of done for every API change. | ||
.claude/skills/commit-workflow/SKILL.mdadded+38 -0
| @@ -0,0 +1,38 @@ | |||
| 1 | +--- | ||
| 2 | +name: commit-workflow | ||
| 3 | +description: This repo's git commit rules β Conventional-Commit + emoji format, mandatory explicit approval before `git commit`, and the mandatory `bun run build` pre-commit check. Load before proposing or running any commit in hezarfen_frontend. | ||
| 4 | +--- | ||
| 5 | + | ||
| 6 | +# Commit workflow | ||
| 7 | + | ||
| 8 | +## Message format | ||
| 9 | + | ||
| 10 | +Conventional Commits + a short emoji + bullet detail: | ||
| 11 | + | ||
| 12 | +``` | ||
| 13 | +<type>: <emoji> <short summary> | ||
| 14 | +- <concrete sub-change 1> | ||
| 15 | +- <concrete sub-change 2> | ||
| 16 | +``` | ||
| 17 | + | ||
| 18 | +Example: | ||
| 19 | + | ||
| 20 | +``` | ||
| 21 | +feat: β¨ live exams, Turkish i18n, and mobile tab bar | ||
| 22 | +- mirror the backend exam contract: schedule fields, attempts, | ||
| 23 | + questions/answers, live monitor, /time clock sync, ws proxy | ||
| 24 | +- exam scheduling UI in plain words with client-side window validation | ||
| 25 | +- student exam room: server-judged countdown, WebSocket autosave with | ||
| 26 | + REST fallback, two-step turn-in, review after submit or expiry | ||
| 27 | +- full English/Turkish dictionaries, persisted toggle, localized dates | ||
| 28 | +- bottom tab bar within thumb reach on small screens | ||
| 29 | +``` | ||
| 30 | + | ||
| 31 | +## Rules | ||
| 32 | + | ||
| 33 | +- **Title:** `type: emoji short summary` β `type` β `feat|fix|refactor|chore|docs|style|test|perf`. Short, plain, no marketing tone. | ||
| 34 | +- **Body:** one concrete sub-change per line, technical but plain language. Continuation lines indented two spaces. | ||
| 35 | +- **Language:** every commit message is in English, always β regardless of the conversation language. | ||
| 36 | +- **When to commit:** one commit per significant/complete feature. Not for tiny one-line fixes alone; never commit half-finished or non-building code. | ||
| 37 | +- **Approval is mandatory, no exceptions:** before running `git commit`, show the user the exact proposed message (title + all bullets) and get **explicit approval**. `git commit` never runs before approval β every commit, including small ones. | ||
| 38 | +- **Mandatory pre-commit check:** once approved, right before committing, run `bun run build` (`tsc --noEmit && vite build`) unless a build already passed since the last code change. If the user explicitly waived the build for this action, skip it. On failure, remove unused imports/vars and re-run until green. Only commit once green (or explicitly waived). | ||
.claude/skills/dashboard-design/SKILL.mdadded+20 -0
| @@ -0,0 +1,20 @@ | |||
| 1 | +--- | ||
| 2 | +name: dashboard-design | ||
| 3 | +description: Rules for the hezarfen_frontend dashboard/homepage β a read-only status board (no mutations), monochrome palette with semantic-only status color, portal-card layout, grid, and role scoping. Load before editing src/pages/dashboard-page.tsx or the homepage. | ||
| 4 | +--- | ||
| 5 | + | ||
| 6 | +# Dashboard / homepage design | ||
| 7 | + | ||
| 8 | +Reference: `src/pages/dashboard-page.tsx`. The homepage is a **read-only status board**, not a marketing landing or action hub. | ||
| 9 | + | ||
| 10 | +- **No mutations:** no create/edit/delete buttons, no primary CTAs that open forms. Links only navigate to existing list/detail routes. | ||
| 11 | +- **Palette:** monochrome / grayscale surfaces (border, card, muted). No decorative color accents, gradients, activity charts, or multi-tone portal cards. **Semantic color only** for status (active / today / soon / danger). | ||
| 12 | +- **Layout order (top β bottom):** | ||
| 13 | + 1. Compact header β greeting, role chip (neutral), date. | ||
| 14 | + 2. Role-scoped **workspace portal cards** (section links with optional counts). | ||
| 15 | + 3. **Needs attention** + **Upcoming** side by side on `lg+`, stacked on mobile. | ||
| 16 | +- **Portal cards:** horizontal dense rows β icon | title + short desc | optional count. On desktop, title and count share one line as `Title | 12` (pipe separator, mono tabular count). No separate KPI strip repeating the same numbers. | ||
| 17 | +- **Grid:** `1` col mobile β `2` sm β `3` lg β `4` xl. Equal-ish min height; avoid uneven multi-line stat stacks. | ||
| 18 | +- **Role scoping:** card set matches nav/role matrix (student personal tools; teacher teaching tools; manager+ management; admin gets staff-work + users, not personal `/work`). Optional min-role badge is muted/neutral, not rainbow. | ||
| 19 | +- **Attention list:** active / today / soon exams and events only; rows navigate to detail. Empty state is plain text, not a create CTA. | ||
| 20 | +- Do not reintroduce guide marketing blocks, vanity charts, or redundant bottom KPI tiles. | ||
.claude/skills/solidjs-pitfalls/SKILL.mdadded+40 -0
| @@ -0,0 +1,40 @@ | |||
| 1 | +--- | ||
| 2 | +name: solidjs-pitfalls | ||
| 3 | +description: The two high-cost SolidJS resource pitfalls in hezarfen_frontend β using resource.latest for always-rendered/shell reads to avoid whole-page blanking on refetch, and using a local signal (not mutate/refetch) for live save-on-click toggles to avoid refetch cascades. Load when touching createResource reads outside <Suspense>, polling, or inline PATCH toggles. | ||
| 4 | +--- | ||
| 5 | + | ||
| 6 | +# SolidJS resource pitfalls | ||
| 7 | + | ||
| 8 | +Baseline SolidJS rules (run-once, no destructure, signals, control-flow components) live in `AGENTS.md`. These two are the expensive, non-obvious ones. | ||
| 9 | + | ||
| 10 | +## 1. `resource.latest` for reads outside `<Suspense>` | ||
| 11 | + | ||
| 12 | +A bare `resource()` re-suspends on **every** `refetch()` β not just the first load, and `initialValue` does NOT stop it. If that read sits outside a `<Suspense>` (e.g. an always-rendered badge/count in a shell component mounted beside `<Outlet>`), the suspension bubbles up and **blanks the whole page** for the entire fetch duration, once per poll/refetch. Invisible on a fast local backend; a multi-second blank on a real one. | ||
| 13 | + | ||
| 14 | +Rule: | ||
| 15 | +- Reads under a page's `<Suspense>` β use `resource()`. | ||
| 16 | +- Always-rendered / shell / badge reads of a periodically-refetched resource β use `resource.latest` (last value, no suspend). | ||
| 17 | +- Poll-driven revalidation belongs behind `.latest`. | ||
| 18 | + | ||
| 19 | +## 2. Live save-on-click toggles use a local signal, not `mutate`/`refetch` | ||
| 20 | + | ||
| 21 | +For an inline switch that PATCHes one field (e.g. the exam-review toggle in `exam-detail-page.tsx`): | ||
| 22 | + | ||
| 23 | +- Do NOT `refetch()` the shared resource β re-suspends β page spinner. | ||
| 24 | +- Do NOT `mutate({...res, field})` either β mutating a shared resource changes its object identity, so every *other* `createResource` whose source reads it (directly or via a memo like `hasCourseManagementRights()`) re-runs and refetches, cascading the same spinner. | ||
| 25 | + | ||
| 26 | +Instead keep a local signal, sync from the resource in a `createEffect`, flip optimistically, revert on failure: | ||
| 27 | + | ||
| 28 | +```ts | ||
| 29 | +const [on, setOn] = createSignal(false); | ||
| 30 | +createEffect(() => { const e = res(); if (e) setOn(e.field); }); | ||
| 31 | +const toggle = async (next: boolean) => { | ||
| 32 | + if (saving()) return; | ||
| 33 | + setOn(next); setSaving(true); | ||
| 34 | + try { await patchX(id(), { field: next }); } | ||
| 35 | + catch (err) { setOn(!next); setError(fmt(err)); } | ||
| 36 | + finally { setSaving(false); } | ||
| 37 | +}; | ||
| 38 | +``` | ||
| 39 | + | ||
| 40 | +A correct toggle fires exactly one PATCH and zero GETs. No success toast β the switch position is the feedback. Pitfall #1's `resource.latest` is the read-side companion (survive a refetch without blanking); this is the write-side (don't trigger the refetch at all). `mutate()` (`settings-page.tsx`) is fine for a form that owns its whole resource, but still cascades for a shared one β the local signal is the safe default. | ||
.claude/skills/ui-conventions/SKILL.mdadded+44 -0
| @@ -0,0 +1,44 @@ | |||
| 1 | +--- | ||
| 2 | +name: ui-conventions | ||
| 3 | +description: hezarfen_frontend UI conventions β SidePanel vs full-page, header button sizing/radius, DataTable-only tables, date/time forms, attendance/roll-call rules, Note Import Assistant, and DrawCanvas. Load before building or restyling pages, tables, headers, dialogs, forms, or the notes/draw features. | ||
| 4 | +--- | ||
| 5 | + | ||
| 6 | +# UI conventions | ||
| 7 | + | ||
| 8 | +Active project reference docs (read the relevant one before changing that area): | ||
| 9 | +- `docs/navigation-patterns.md` β interaction rules, role scope, side-panel/full-page decisions, dashboard structure. | ||
| 10 | +- `docs/ui-redesign-tokens.md` β visual density, radius, table, side-panel, status UI, dashboard card conventions. | ||
| 11 | +- `docs/role-scope-matrix.md` β role access matrix for pages/nav/dashboard cards. | ||
| 12 | +- `docs/frontend-next-steps.md` β completed audit summary plus active follow-up notes. | ||
| 13 | +- `docs/backend-ui-alignment-plan.md` β completed archive; not active work unless backend scope changes. | ||
| 14 | + | ||
| 15 | +## Layout & panels | ||
| 16 | + | ||
| 17 | +- Durable resources use full detail pages. Short create/edit/filter work uses `SidePanel`. Destructive actions use confirm dialogs. | ||
| 18 | +- Disclosure sections may defer mounting (request savings) or stay mounted (state preservation) β choose deliberately; avoid hidden heavy requests unless needed. | ||
| 19 | + | ||
| 20 | +## Buttons | ||
| 21 | + | ||
| 22 | +- Header create actions: compact icon+label, consistent size and current radius. | ||
| 23 | +- Page header primary create/add: `size="sm" class="min-w-[7.5rem] rounded-lg"`. Secondary/import: `variant="outline"` with the same size/class. | ||
| 24 | +- Section/sub-panel header actions: `variant="outline" size="sm" class="rounded-lg"` unless matching a page header button. | ||
| 25 | +- Actions inside sub-panels must not duplicate section headers β primary create/add/assign actions go in the header `actions` prop of the parent disclosure or page header. | ||
| 26 | + | ||
| 27 | +## Tables | ||
| 28 | + | ||
| 29 | +- Application tables must use `src/components/ui/data-table.tsx` `DataTable`. | ||
| 30 | +- Actions columns use `w-28 min-w-[7rem] text-center whitespace-nowrap` to prevent truncation of localized headers like `"Δ°ΕLEMLER"`. | ||
| 31 | +- Table-page headers fold into the `DataTable` title/description/actions area; do not render a separate `PageHeader` above table-primary pages. | ||
| 32 | +- Search inputs, dropdown filters, filter buttons, and toolbar actions share the same height/radius (`h-9 rounded-lg` unless the shared component changes the standard globally). | ||
| 33 | +- Pages/domain components must not import or render `Table` primitives directly; only the `DataTable` wrapper and table primitive files may. | ||
| 34 | + | ||
| 35 | +## Date/time & attendance | ||
| 36 | + | ||
| 37 | +- Date/time product forms use shared `DatePicker` plus a separate `HH:mm` input. Backend schedule fields are UTC unix-millisecond values; backend rejects newly set past event/exam/session schedules with `400`. Use `GET /time` for server-clock-aware checks when accuracy matters. | ||
| 38 | +- Lesson session roll call is teacher/manager workflow only. Students never self-mark lesson sessions; the session teacher or course manager marks enrolled students, and the session teacher's own presence row is manager-only per backend rules. | ||
| 39 | +- Attendance status UI uses shared localized metadata: label, short detail text, semantic colors. | ||
| 40 | + | ||
| 41 | +## Features | ||
| 42 | + | ||
| 43 | +- **Note Import Assistant:** Raw PDF/TXT/MD converted to structured Markdown via `src/lib/note-importer.ts`. Noise (page numbers, headers/footers, watermarks) removed, PDF mid-sentence line wraps re-joined, headings (`##`) and bullet lists formatted, OCR-unreadable artifacts flagged with `β οΈ Some content may be unreadable due to OCR/extraction issues`. Never invent content or add fluff preamble. Lives in a dedicated `SidePanel` triggered from the Notes page header, right of the "Yeni Not" button. | ||
| 44 | +- **Drawing Canvas (`DrawCanvas`):** Freehand drawings saved as `.hzdraw.png` with embedded scene JSON metadata. Live drawing effects must guard `initialScene` against re-initializing during active strokes. | ||
AGENTS.mdmodified+70 -198
| @@ -1,221 +1,93 @@ | |||
| 1 | # AGENTS.md β Hezarfen Frontend | 1 | # AGENTS.md β Hezarfen Frontend |
| 2 | 2 | ||
| 3 | -This file is the persistent rulebook for any agent (OpenCode, Claude Code, etc.) | 3 | +Persistent rulebook for any agent (Claude Code, Codex, OpenCode, β¦) in this repo. |
| 4 | -working in this repository. It applies to every session, not just one-off task | 4 | +Applies to every session. Always written and read in English. |
| 5 | -instructions. Always written and read in English. | 5 | + |
| 6 | +Keep this file lightweight β hard constraints and repo gotchas only. Detailed | ||
| 7 | +procedures live as loadable references (see **On-demand references** below); open | ||
| 8 | +the relevant one when a task touches that area instead of inlining it here. | ||
| 6 | 9 | ||
| 7 | ## Stack (hard constraints) | 10 | ## Stack (hard constraints) |
| 8 | 11 | ||
| 9 | - SolidJS + TypeScript, Vite scaffold. | 12 | - SolidJS + TypeScript, Vite scaffold. |
| 10 | - Routing: **TanStack Router** (`@tanstack/solid-router`), hand-written code-based | 13 | - Routing: **TanStack Router** (`@tanstack/solid-router`), hand-written code-based |
| 11 | - route tree. Only add `@tanstack/router-plugin` (file-based routing) if | 14 | + route tree. Add `@tanstack/router-plugin` (file-based routing) only if explicitly |
| 12 | - explicitly requested later. | 15 | + requested. |
| 13 | -- UI: **shadcn-solid** primitives (`src/components/ui/`) following | 16 | +- UI: **shadcn-solid** primitives (`src/components/ui/`) styled with Tailwind. Do |
| 14 | - https://shadcn-solid.com/docs/installation and component docs, styled with | 17 | + not import Kobalte primitives directly in pages/domain components β add or update |
| 15 | - Tailwind CSS. Do not import Kobalte primitives directly from pages/domain | 18 | + the matching `src/components/ui/` wrapper first. Dialogs, alert dialogs, dropdowns, |
| 16 | - components. If a component is needed, add or update the matching | 19 | + popovers, and comboboxes use the documented shadcn-solid wrapper API. If |
| 17 | - shadcn-solid-style wrapper under `src/components/ui/` first. Dialogs, | 20 | + shadcn-solid lacks a suitable component, ask before adding a library or hand-rolling. |
| 18 | - alert dialogs, dropdowns, popovers, and comboboxes must use the documented | 21 | +- Runtime deps: `solid-js`, `@tanstack/solid-router`, shadcn-solid/Kobalte peer deps, |
| 19 | - shadcn-solid wrapper API. If shadcn-solid does not provide a suitable | 22 | + `clsx` + `tailwind-merge` + `class-variance-authority` (for `cn()` and variants). |
| 20 | - component, ask before adding another library or hand-rolling one. | 23 | + No axios (use `fetch`), no date libs (`Intl.DateTimeFormat` only), no lodash, no |
| 21 | -- Runtime dependencies: `solid-js`, `@tanstack/solid-router`, shadcn-solid/Kobalte | 24 | + separate state-management library. |
| 22 | - peer deps, and `clsx` + `tailwind-merge` + `class-variance-authority` (for | ||
| 23 | - `cn()` and variant helpers, <2KB total). No axios (use `fetch`), no date libs | ||
| 24 | - (`Intl.DateTimeFormat` only), no lodash, no separate state-management library. | ||
| 25 | - Bundle target: under ~70KB gzipped. Justify any addition beyond that. | 25 | - Bundle target: under ~70KB gzipped. Justify any addition beyond that. |
| 26 | 26 | ||
| 27 | ## Naming & file structure | 27 | ## Naming & file structure |
| 28 | 28 | ||
| 29 | -- **One component per file.** Never two sibling components in the same file. | 29 | +- **One component per file.** Never two sibling components in one file. Exception: |
| 30 | - Exception: shadcn-solid primitive wrapper files under `src/components/ui/` | 30 | + shadcn-solid wrapper files under `src/components/ui/` may export the documented |
| 31 | - may export the documented compound component API from one file (for example | 31 | + compound API from one file (`Dialog`, `DialogContent`, `DialogHeader`, β¦). |
| 32 | - `Dialog`, `DialogContent`, `DialogHeader`, `DialogTitle`). | 32 | +- File name = component name in kebab-case; exported component is PascalCase |
| 33 | -- File name = component name in kebab-case; the exported component is | 33 | + (`note-card.tsx` β `NoteCard`). Colocated files keep the base name |
| 34 | - PascalCase. Example: `note-card.tsx` β `NoteCard`. Colocated files (types, | 34 | + (`note-card.types.ts`, `note-card.test.tsx`). |
| 35 | - tests) keep the same base name: `note-card.tsx`, `note-card.types.ts`, | 35 | +- Same-domain components share a folder: `components/notes/`, `events/`, `exams/`, |
| 36 | - `note-card.test.tsx`. | 36 | + `users/`, `attendance/`, `courses/`, `marks/`, `sessions/`, `messages/`, |
| 37 | -- Components in the same domain live in the same folder: `components/notes/`, | 37 | + `homework/`, `appointments/`, `layout/`, `ui/`. |
| 38 | - `components/events/`, `components/exams/`, `components/users/`, | ||
| 39 | - `components/attendance/`, `components/courses/`, `components/marks/`, | ||
| 40 | - `components/sessions/`, `components/messages/`, `components/homework/`, | ||
| 41 | - `components/appointments/`, `components/layout/`, `components/ui/`. | ||
| 42 | - Cross-cutting app state lives in `src/stores/` (`auth-context.tsx`, | 38 | - Cross-cutting app state lives in `src/stores/` (`auth-context.tsx`, |
| 43 | `preferences-context.tsx`) β context providers only, never domain components. | 39 | `preferences-context.tsx`) β context providers only, never domain components. |
| 44 | School-policy lists (exam kinds, attendance statuses, grade bands) come from | 40 | School-policy lists (exam kinds, attendance statuses, grade bands) come from |
| 45 | - `getSettings()` in a `createResource`, never hardcoded in components. | 41 | + `getSettings()` in a `createResource`, never hardcoded. |
| 46 | -- **API layer:** Domain-based folders under `src/api/` (e.g., `src/api/notes/`, | 42 | +- **API layer** lives under `src/api/` β domain folders, one verb-first file per |
| 47 | - `src/api/exams/`). One file per request under its domain folder, camelCase and verb-first, | 43 | + endpoint, `fetch` only in `client.ts`, mandatory per-domain tests. Full rules and |
| 48 | - mirroring the endpoint exactly (`src/api/notes/getNoteById.ts`, | 44 | + the test contract: **api-layer** reference. |
| 49 | - `src/api/exams/deleteExamResultByUserId.ts`). Each file exports exactly one function | 45 | + |
| 50 | - matching its filename. Each domain must have an `index.ts` re-exporting its endpoints. | 46 | +## SolidJS β do not write React patterns |
| 51 | - Only `src/api/client/client.ts` calls `fetch` directly. Pages/ | 47 | + |
| 52 | - components never call `fetch` β they call `src/api/<domain>` API functions inside | 48 | +Solid components run **once**; there is no re-render. |
| 53 | - `createResource`. | 49 | + |
| 54 | -- **API tests β mandatory:** Every new or modified API endpoint file must have a | 50 | +1. Never destructure props β use `props.title` or `splitProps`. |
| 55 | - corresponding test file under `src/api/__tests__/<domain>/<domain>.test.ts` (one | 51 | +2. Signals are functions: read `count()`, write `setCount(v)`. |
| 56 | - test file per domain, not per endpoint). Tests use **vitest** (globals enabled) and | 52 | +3. Use `createSignal`/`createMemo`/`createEffect`/`createResource` β never |
| 57 | - the shared helpers from `src/api/__tests__/helpers/mock-fetch.ts` (`mockFetchSuccess`, | ||
| 58 | - `mockFetch204`, `mockFetchError`, `lastFetchCall`). Each test asserts the correct | ||
| 59 | - URL, HTTP method, and request body (when applicable). The `afterEach` hook must call | ||
| 60 | - `vi.restoreAllMocks()`. Run all tests with `bun run test` before committing. Do not | ||
| 61 | - skip or defer API tests β they are part of the definition of done for every API | ||
| 62 | - change. | ||
| 63 | - | ||
| 64 | -## SolidJS rules β do not write React patterns | ||
| 65 | - | ||
| 66 | -Solid components run **once**, there is no re-render: | ||
| 67 | - | ||
| 68 | -1. Never destructure props (`function Card({title})` β) β use `props.title` | ||
| 69 | - or `splitProps`. | ||
| 70 | -2. Signals are functions: read with `count()`, write with `setCount(v)`. | ||
| 71 | -3. Use `createSignal`, `createMemo`, `createEffect`, `createResource` β never | ||
| 72 | `useState`/`useEffect`/`useMemo`, no dependency arrays. | 53 | `useState`/`useEffect`/`useMemo`, no dependency arrays. |
| 73 | -4. Use `<Show>`, `<For>`, `<Switch>/<Match>` for conditional/list rendering; | 54 | +4. Conditional/list rendering: `<Show>`, `<For>`, `<Switch>/<Match>`; server data: |
| 74 | - `<Suspense>` + `createResource` for server data. | 55 | + `<Suspense>` + `createResource`. |
| 75 | -5. Use `class`, not `className`. Route components are `lazy()`-loaded and wired | 56 | +5. Use `class`, not `className`. Route components are `lazy()`-loaded into the |
| 76 | - into the TanStack Router route tree. | 57 | + TanStack Router tree. |
| 77 | -6. **`resource.latest` for reads outside `<Suspense>`.** A bare `resource()` | 58 | +6. **Two expensive resource pitfalls** β use `resource.latest` for always-rendered/ |
| 78 | - re-suspends on **every** `refetch()` (not just the first load, and | 59 | + shell reads of a refetched resource (a bare `resource()` re-suspends on every |
| 79 | - `initialValue` does NOT stop it). If that read sits outside a `<Suspense>` β | 60 | + refetch and blanks the whole page), and drive live save-on-click toggles with a |
| 80 | - e.g. an always-rendered badge/count in a shell component mounted beside | 61 | + local signal, not `mutate`/`refetch`. Full explanation + code: **solidjs-pitfalls** |
| 81 | - `<Outlet>` β the suspension bubbles up and **blanks the whole page** for the | 62 | + reference. |
| 82 | - entire fetch duration, once per poll/refetch. Invisible on a fast local | ||
| 83 | - backend, a multi-second blank on a real one. Rule: reads under a page's | ||
| 84 | - `<Suspense>` use `resource()`; always-rendered/shell/badge reads of a | ||
| 85 | - periodically-refetched resource use `resource.latest` (last value, no | ||
| 86 | - suspend). Poll-driven revalidation belongs behind `.latest`. | ||
| 87 | -7. **Live save-on-click toggles use a local signal, not `mutate`/`refetch`.** | ||
| 88 | - For an inline switch that PATCHes one field (e.g. the exam-review toggle in | ||
| 89 | - `exam-detail-page.tsx`), do NOT `refetch()` the shared resource (re-suspends | ||
| 90 | - β page spinner) and do NOT `mutate({...res, field})` either β mutating a | ||
| 91 | - shared resource changes its object identity, so every *other* `createResource` | ||
| 92 | - whose source reads it (directly or via a memo like `hasCourseManagementRights()`) | ||
| 93 | - re-runs and refetches, cascading the same spinner. Instead keep a local | ||
| 94 | - signal, sync it from the resource in a `createEffect`, flip it optimistically | ||
| 95 | - on toggle, and revert on failure: | ||
| 96 | - ```ts | ||
| 97 | - const [on, setOn] = createSignal(false); | ||
| 98 | - createEffect(() => { const e = res(); if (e) setOn(e.field); }); | ||
| 99 | - const toggle = async (next: boolean) => { | ||
| 100 | - if (saving()) return; | ||
| 101 | - setOn(next); setSaving(true); | ||
| 102 | - try { await patchX(id(), { field: next }); } | ||
| 103 | - catch (err) { setOn(!next); setError(fmt(err)); } | ||
| 104 | - finally { setSaving(false); } | ||
| 105 | - }; | ||
| 106 | - ``` | ||
| 107 | - A correct toggle fires exactly one PATCH and zero GETs. No success toast β the | ||
| 108 | - switch position is the feedback. Rule #6's `resource.latest` is the read-side | ||
| 109 | - companion (survive a refetch without blanking); this is the write-side (don't | ||
| 110 | - trigger the refetch at all). `mutate()` (`settings-page.tsx`) is fine for a | ||
| 111 | - form that owns its whole resource, but still cascades for a shared one β the | ||
| 112 | - local signal is the safe default. | ||
| 113 | 63 | ||
| 114 | ## Performance | 64 | ## Performance |
| 115 | 65 | ||
| 116 | - Every route component is `lazy()` (code-split per page). | 66 | - Every route component is `lazy()` (code-split per page). |
| 117 | -- Server data always goes through `createResource` β `<Suspense>` (lightweight | 67 | +- Server data goes through `createResource` β `<Suspense>` (lightweight fallback), |
| 118 | - fallback), `refetch()` after mutations. | 68 | + `refetch()` after mutations. |
| 119 | - One `<Suspense>` boundary per page, no spinner-cascades, fixed-height list rows. | 69 | - One `<Suspense>` boundary per page, no spinner-cascades, fixed-height list rows. |
| 120 | 70 | ||
| 121 | -## Project docs and current UI rules | ||
| 122 | - | ||
| 123 | -- Treat these docs as active project context before changing related areas: | ||
| 124 | - - `docs/frontend-next-steps.md` β completed audit summary plus active backend-dependent/frontend follow-up notes. | ||
| 125 | - - `docs/navigation-patterns.md` β interaction rules, role scope, side-panel/full-page decisions, dashboard structure. | ||
| 126 | - - `docs/ui-redesign-tokens.md` β visual density, radius, table, side-panel, status UI, and dashboard card conventions. | ||
| 127 | - - `docs/role-scope-matrix.md` β role access matrix for pages/nav/dashboard cards. | ||
| 128 | - - `docs/backend-ui-alignment-plan.md` β completed backend-alignment archive; do not treat it as active work unless backend scope changes. | ||
| 129 | -- Durable resources use full detail pages. Short create/edit/filter work uses `SidePanel`. Destructive actions use confirm dialogs. | ||
| 130 | -- Header create actions use compact icon+label buttons with consistent size and current radius. Page header primary create/add buttons use `size="sm" class="min-w-[7.5rem] rounded-lg"`; secondary/import buttons use `variant="outline"` with the same size/class. Section/sub-panel header actions use `variant="outline" size="sm" class="rounded-lg"` unless matching a page header button. Action buttons inside sub-panels must not duplicate section headers β primary create/add/assign actions must be placed in the header `actions` prop of the parent disclosure or page header. | ||
| 131 | -- Application tables must use `src/components/ui/data-table.tsx` `DataTable`. Actions columns must use `w-28 min-w-[7rem] text-center whitespace-nowrap` to prevent truncation of localized headers like `"Δ°ΕLEMLER"`. | ||
| 132 | -- Table-page headers are folded into the `DataTable` title/description/actions area; do not render a separate `PageHeader` above pages whose primary content is a table. Search inputs, dropdown filters, filter buttons, and table toolbar actions must always share the same height and radius (`h-9 rounded-lg` unless the shared component changes the standard globally). | ||
| 133 | -- Pages/domain components must not import or render `Table` primitives directly; only the `DataTable` wrapper and table primitive files may do that. | ||
| 134 | -- **Note Import Assistant**: Raw PDF/TXT/MD files are converted to structured Markdown notes using `src/lib/note-importer.ts`. Noise (page numbers, headers/footers, watermarks) is removed, PDF mid-sentence line wraps are re-joined, headings (`##`) and bullet lists are formatted, and OCR unreadable artifacts are flagged with `β οΈ Some content may be unreadable due to OCR/extraction issues`. Never invent content or fluff preamble. Note Import Assistant lives in a dedicated `SidePanel` triggered from the Notes page header to the right of the "Yeni Not" button. | ||
| 135 | -- **Drawing Canvas (`DrawCanvas`)**: Freehand drawings are saved as `.hzdraw.png` files with embedded scene JSON metadata. Live drawing effects must guard `initialScene` against re-initializing during active strokes. | ||
| 136 | -- Disclosure sections may either defer mounting for request savings or keep content mounted for state preservation; choose deliberately and avoid hidden heavy requests unless needed. | ||
| 137 | -- Date/time product forms use shared `DatePicker` plus a separate `HH:mm` input. Backend schedule fields are UTC unix-millisecond values and the backend rejects newly set past event/exam/session schedules with `400`; use `GET /time` for server-clock-aware checks when accuracy matters. | ||
| 138 | -- Lesson session roll call is teacher/manager workflow only. Students never self-mark lesson sessions; the session teacher or course manager marks enrolled students, and the session teacher's own presence row is manager-only per backend rules. | ||
| 139 | -- Attendance status UI uses shared localized metadata: label, short detail text, and semantic colors. | ||
| 140 | - | ||
| 141 | -## Dashboard / homepage design | ||
| 142 | - | ||
| 143 | -Reference: `src/pages/dashboard-page.tsx`. Homepage is a **read-only status board**, not a marketing landing or action hub. | ||
| 144 | - | ||
| 145 | -- **No mutations** on the dashboard: no create/edit/delete buttons, no primary CTAs that open forms. Links only navigate to existing list/detail routes. | ||
| 146 | -- **Palette:** monochrome / grayscale surfaces (border, card, muted). Decorative color accents, gradients, activity charts, and multi-tone portal cards are out. **Semantic color only** for status (active / today / soon / danger). | ||
| 147 | -- **Layout order (top β bottom):** | ||
| 148 | - 1. Compact header β greeting, role chip (neutral), date. | ||
| 149 | - 2. Role-scoped **workspace portal cards** (section links with optional counts). | ||
| 150 | - 3. **Needs attention** + **Upcoming** side by side on `lg+`, stacked on mobile. | ||
| 151 | -- **Portal cards:** horizontal dense rows β icon | title + short desc | optional count. On desktop, title and count share one line as `Title | 12` (pipe separator, mono tabular count). No separate KPI strip that repeats the same numbers under the cards. | ||
| 152 | -- **Grid:** `1` col mobile β `2` sm β `3` lg β `4` xl. Equal-ish min height; avoid uneven multi-line stat stacks. | ||
| 153 | -- **Role scoping:** card set matches nav/role matrix (student personal tools; teacher teaching tools; manager+ management; admin gets staff-work + users, not personal `/work`). Optional min-role badge on a card is muted/neutral, not rainbow. | ||
| 154 | -- **Attention list:** active / today / soon exams and events only; rows navigate to detail. Empty state is plain text, not a create CTA. | ||
| 155 | -- Do not reintroduce guide marketing blocks, vanity charts, or redundant bottom KPI tiles. | ||
| 156 | - | ||
| 157 | ## Containers | 71 | ## Containers |
| 158 | 72 | ||
| 159 | -- We use **Podman**, not Docker. Never suggest, generate, or run `docker` / | 73 | +- We use **Podman**, not Docker. Never suggest/generate/run `docker` / |
| 160 | - `docker-compose` commands or a `Dockerfile`-only workflow β use the Podman | 74 | + `docker-compose` or a `Dockerfile`-only workflow β use `podman build`, `podman run`, |
| 161 | - equivalents instead: `podman build`, `podman run`, `podman compose` (or | 75 | + `podman compose` (or `podman-compose`), and `Containerfile`. Translate any |
| 162 | - `podman-compose` if that's what's installed), and `Containerfile` (Podman's | 76 | + copy-pasted `docker ...` snippet to the `podman ...` equivalent before running it. |
| 163 | - name for the same syntax as a Dockerfile; `Dockerfile` also works but prefer | 77 | + |
| 164 | - `Containerfile` for new files). | 78 | +## On-demand references |
| 165 | -- If a task or a copy-pasted snippet from elsewhere uses `docker ...`, translate | 79 | + |
| 166 | - it to the matching `podman ...` command before running or proposing it. | 80 | +Detailed, area-specific procedures. These live under `.claude/skills/<name>/SKILL.md` |
| 167 | - | 81 | +β Claude Code auto-loads them when relevant; other agents open the file by path when |
| 168 | -## Git commit workflow | 82 | +a task touches that area. Load the one that matches, not all of them. |
| 169 | - | 83 | + |
| 170 | -**Commit message format** (Conventional Commits + short emoji + bullet detail): | 84 | +- **commit-workflow** β commit message format, mandatory approval, pre-commit build. |
| 171 | - | 85 | +- **api-layer** β `src/api/` structure and the mandatory per-domain vitest contract. |
| 172 | -``` | 86 | +- **solidjs-pitfalls** β `resource.latest` and the save-on-click toggle pattern. |
| 173 | -<type>: <emoji> <short summary> | 87 | +- **ui-conventions** β SidePanel vs page, header buttons, `DataTable`, date/time, |
| 174 | -- <concrete sub-change 1> | 88 | + attendance, Note Import Assistant, `DrawCanvas`. |
| 175 | -- <concrete sub-change 2> | 89 | +- **dashboard-design** β the read-only status-board homepage rules. |
| 176 | -- ... | 90 | + |
| 177 | -``` | 91 | +Project docs under `docs/` remain the deeper reference (`navigation-patterns.md`, |
| 178 | - | 92 | +`ui-redesign-tokens.md`, `role-scope-matrix.md`, `frontend-next-steps.md`, |
| 179 | -Example: | 93 | +`backend-ui-alignment-plan.md`). |
| 180 | - | ||
| 181 | -``` | ||
| 182 | -feat: β¨ live exams, Turkish i18n, and mobile tab bar | ||
| 183 | -- mirror the backend exam contract: schedule fields, attempts, | ||
| 184 | - questions/answers, live monitor, /time clock sync, ws proxy | ||
| 185 | -- exam scheduling UI in plain words with client-side window validation | ||
| 186 | -- teacher question authoring: choice/written, points, correct pick | ||
| 187 | -- student exam room: server-judged countdown, WebSocket autosave with | ||
| 188 | - REST fallback, two-step turn-in, review after submit or expiry | ||
| 189 | -- teacher live monitor over SSE with answer sheets, auto-score | ||
| 190 | - suggestion, and inline grading | ||
| 191 | -- full English/Turkish dictionaries, persisted toggle, localized dates, | ||
| 192 | - document lang so Turkish casing renders Δ° correctly | ||
| 193 | -- weight badges speak plain words ("counts Γ2" / "Γ2 sayΔ±lΔ±r") | ||
| 194 | -- bottom tab bar within thumb reach on small screens | ||
| 195 | -``` | ||
| 196 | - | ||
| 197 | -Rules: | ||
| 198 | - | ||
| 199 | -- **Title:** `type: emoji short summary` β `type` β | ||
| 200 | - `feat|fix|refactor|chore|docs|style|test|perf`. Keep the summary short, | ||
| 201 | - plain, no marketing tone. | ||
| 202 | -- **Body:** one concrete sub-change per line, technical but plain language (the | ||
| 203 | - reader should understand what actually changed). Wrapped lines are indented | ||
| 204 | - two spaces on the continuation, as in the example above. | ||
| 205 | -- **Language:** every commit message is written in English, always β regardless | ||
| 206 | - of what language the conversation with the user is in. | ||
| 207 | -- **When to commit:** one commit per significant/complete feature. Not for tiny | ||
| 208 | - one-line fixes on their own, and never commit half-finished or non-building | ||
| 209 | - code. | ||
| 210 | -- **Approval is mandatory, no exceptions:** before running `git commit`, the | ||
| 211 | - agent shows the user the exact proposed commit message (title + all bullets) | ||
| 212 | - and asks for **explicit approval**. `git commit` never runs before approval | ||
| 213 | - is given. This applies to every commit, including small ones β no exceptions. | ||
| 214 | -- **Mandatory pre-commit check:** once approved, right before running the commit, | ||
| 215 | - run `bun run build` (`tsc --noEmit && vite build`) unless a build has already | ||
| 216 | - passed since the last code change. If the user explicitly says not to run a | ||
| 217 | - build for the current action, do not run it. If the build fails, remove the | ||
| 218 | - unused imports/variables and re-run until it passes. Only commit once the build | ||
| 219 | - is green or the user explicitly waived the build for that action. | ||
| 220 | -- This workflow (format + approval + pre-commit check) applies always, without | ||
| 221 | - exception, to every commit in this repo. | ||
CLAUDE.mdadded+16 -0
| @@ -0,0 +1,16 @@ | |||
| 1 | +# CLAUDE.md | ||
| 2 | + | ||
| 3 | +Hezarfen Frontend β SolidJS + TypeScript + TanStack Router + shadcn-solid, built | ||
| 4 | +with Vite/Bun. Read-only status-board dashboard; Turkish/English i18n. | ||
| 5 | + | ||
| 6 | +**The rulebook is `AGENTS.md`** β one source of truth for every agent. Read it first. | ||
| 7 | + | ||
| 8 | +@AGENTS.md | ||
| 9 | + | ||
| 10 | +Detailed, area-specific procedures load on demand as Skills under `.claude/skills/` | ||
| 11 | +(commit-workflow, api-layer, solidjs-pitfalls, ui-conventions, dashboard-design). | ||
| 12 | +Claude Code surfaces them automatically when a task matches; you can also open any | ||
| 13 | +`SKILL.md` directly. Deeper design docs live under `docs/`. | ||
| 14 | + | ||
| 15 | +Keep this file thin. Put durable rules in `AGENTS.md`, detailed procedures in a | ||
| 16 | +Skill β not here. | ||