| name | milerdev-lms |
| description | Implement, fix, review, or extend features in the MilerDev LMS repository. Use when working on course, lesson, bundle, enrollment, payment, certificate, blog, notification, dashboard, admin, auth, API route, Drizzle/MySQL schema, or MilerDev-specific frontend design tasks in this Next.js app. |
MilerDev LMS
Use this skill to work safely inside the MilerDev course platform. It adds project-specific workflow around the repo's Next.js App Router, Drizzle/MySQL data model, Thai LMS UX, admin surfaces, auth, payments, and tests.
First Moves
- Read
AGENTS.md first and follow it as the repo-wide contract.
- Run
git status --short and preserve user changes.
- Inspect the nearest files before editing:
- Page or layout:
src/app/**/page.tsx, layout.tsx, loading.tsx, error.tsx
- API route:
src/app/api/**/route.ts
- Shared logic:
src/lib/**
- Data model:
src/lib/db/schema.ts
- UI component:
src/components/**
- Tests:
tests/** or e2e/**
- Do not read
.env* files. Use placeholders and .env.example only.
Workflow Decision Tree
- Feature touches database shape: follow Database Changes before implementation.
- Feature touches auth, roles, admin access, passwords, rate limits, headers, or user input: follow Security Path.
- Feature touches Stripe, PromptPay/SlipOK, bundles, payments, reconciliation, or enrollments: follow Payment Path.
- Feature changes public pages, dashboard, admin UI, course UI, learning UI, or Thai copy: follow Frontend Path.
- Feature only changes pure helper logic: update helper and nearby unit tests, then run targeted Vitest.
Implementation Loop
- Locate existing patterns with
rg before creating new ones.
- Reuse existing helpers for auth, validation, API responses, rate limits, sanitization, database access, and admin UI.
- Make the smallest coherent change across route/component/lib/test files.
- Add or update focused tests when behavior changes.
- Run the narrowest useful verification first, then broaden based on risk:
- Helper/API logic:
npm run test -- <matching test file>
- UI or route build safety:
npm run lint and npm run build
- Auth/course/payment flows: relevant
npm run test:e2e spec
- Thai admin text changes:
npm run check:admin-text
Database Changes
- Treat
src/lib/db/schema.ts as source of truth.
- Check related tables, relations, indexes, and existing migrations in
drizzle/.
- For schema updates, edit
schema.ts, run npm run db:generate, and inspect generated SQL.
- Preserve production data by default. Ask before destructive migrations or data backfills.
- Remember MySQL constraints:
- Do not use PostgreSQL-only
.returning().
- Decimal money fields often need string-safe handling.
- Generate IDs explicitly with
createId() where local patterns do.
Security Path
- Enforce authorization on the server. Client checks are only UX.
- Use
auth() from @/lib/auth for session checks in server code.
- Validate body/query data with Zod or nearby validators before database writes.
- Preserve anti-enumeration behavior in registration and password reset flows.
- Keep passwords hashed with bcryptjs and never log credentials, tokens, env vars, or webhook secrets.
- Use existing rate-limit helpers for auth, admin, upload, and payment-sensitive endpoints.
- If editing CSP or proxy security headers, verify Stripe, Bunny, embedded video, fonts, and app assets still work.
Payment Path
- Read the complete current flow before editing: checkout route, webhook or slip verification, payment record, enrollment side effect, and admin reconciliation surface.
- Preserve idempotency. Duplicate webhooks, duplicate slip submissions, and retry jobs must not create duplicate enrollments or inconsistent payments.
- Do not grant enrollment unless payment or admin intent is verified.
- Keep error messages safe and user-friendly. Do not expose provider internals or secrets.
- Add tests for state transitions and duplicate handling when changing payment logic.
- Prefer targeted checks from
tests/api/payment.test.ts and e2e/payment.spec.ts when relevant.
Frontend Path
- Read
DESIGN.md before visual changes unless the task is a tiny fix.
- Use the existing MilerDev visual language:
- Bright, readable LMS surface.
- Primary accent
#02abff.
- Thai copy with generous line-height.
- Product-like admin/dashboard UI that is dense, scannable, and calm.
- Reuse components in
src/components before creating new primitives.
- For admin pages, prefer
src/app/admin/admin-theme.css tokens/classes and src/components/admin/ui/AdminPrimitives.tsx.
- Preserve mobile behavior. Check layout at mobile and desktop sizes for non-trivial UI changes.
- Avoid generic landing-page clutter, unrelated decorative cards, and visual patterns that fight the existing design system.
API Route Pattern
When editing src/app/api/**/route.ts:
- Parse and bound query params.
- Authenticate early when needed.
- Authorize roles explicitly for admin/instructor flows.
- Rate-limit public or sensitive routes.
- Validate request bodies before mutation.
- Use Drizzle schema exports and existing helpers.
- Return the route's existing response shape unless intentionally standardizing it.
- Log only safe context. Never log secrets or full provider payloads.
Done Criteria
Before handing back:
- Confirm files changed are scoped to the request.
- Run relevant tests or explain exactly why they were not run.
- Mention high-risk areas touched, especially auth, payment, database, or production data.
- Include any manual verification needed for external services such as Stripe, SlipOK, Bunny, SMTP, or Resend.