Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/server-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Server Tests

on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest

defaults:
run:
working-directory: server

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: server/package-lock.json

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test
12 changes: 11 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ npm run dev # tsx watch (hot reload)
npm run build # Compile TypeScript → dist/
npm start # Run compiled dist/src/index.js
npm test # Build then run node --test on dist/test/
npm run lint # Biome lint
npm run format # Biome format (auto-writes)
npm run check # Biome check (CI-safe, read-only)
```

### Client (`cd webClient`)
Expand All @@ -40,6 +43,12 @@ cd webClient && npm i && cd ..
cp server/.env.example server/.env # Then set JWT_SECRET (32+ chars)
```

## API Contract

**Full API reference: [`server/API.md`](./server/API.md).** Read it before touching any route, service validation, or request/response shape. It is the source of truth for all endpoint contracts.

**Keep it in sync:** Any change to a route path, HTTP method, request field, response field, status code, or validation rule **must** be reflected in `server/API.md` in the same commit/PR. Do not mark a feature done if the code and `server/API.md` disagree.

## Architecture

### Server Layer Pattern
Expand Down Expand Up @@ -71,9 +80,10 @@ Database (SQLite via better-sqlite3, sync API)
### Key Schema
```sql
users(id, email, password_hash, created_at)
medications(id, user_id, name, dose, start_date, daily_frequency, day_interval, created_at)
medications(id, user_id, name, dose, start_date, times, day_interval, created_at)
medication_consumptions(id, medication_id, date, time, created_at)
```
`times` is stored as a JSON array of `HH:MM` strings (e.g. `'["08:00","14:00"]'`).
Medications and consumptions are user-scoped — services always filter by `req.user.sub`.

### Frontend
Expand Down
59 changes: 59 additions & 0 deletions docs/plans/2026-03-01-code-quality-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Design: Server Code Quality Verification

**Date:** 2026-03-01
**Status:** Approved

## Overview

Add Biome (linter + formatter) to the server and create a `code-quality-check` skill that acts as the final gate before declaring server work complete.

## Goals

- Enforce consistent formatting and catch real code issues in `server/`
- Keep the client unchanged (it already has ESLint via Next.js)
- Create a skill that runs after TypeScript compilation and unit tests pass

## Part 1: Biome Installation

**Package:** `@biomejs/biome` (dev dependency, server only)

**Config (`server/biome.json`):**
- Recommended lint ruleset
- 2-space indentation
- Single quotes
- Semicolons
- Targets `src/` and `test/` directories

**New npm scripts in `server/package.json`:**
- `"lint": "biome lint src/ test/"`
- `"format": "biome format --write src/ test/"`

## Part 2: `code-quality-check` Skill

**Location:** User skill file
**Type:** Rigid checklist (must be followed exactly, not adapted)

**Trigger:** Invoked when the agent is about to declare server-side work complete.

**Prerequisites (assert, don't run):**
The agent must have already completed in this session:
- `npm run build` passing
- `npm test` passing

If either has not been run, stop and do those first before continuing.

**Steps:**
1. Run `npm run format` from `server/` — apply auto-fixes
2. Run `npm run lint` from `server/` — capture all errors
3. For each lint error:
- If fixable as a code issue → fix the code directly
- If it requires a type suppression (`// biome-ignore`) → present the specific error to the user and get explicit approval before adding the suppression comment
4. Re-run `npm run lint` — must exit clean (zero errors)
5. Only after a clean lint run may the agent claim the work is done

## Rationale

- Biome was chosen over ESLint+Prettier for simplicity: one tool, one config file, fast execution
- The recommended ruleset avoids excessive noise while still catching real bugs
- The skill is positioned as a final gate (not a per-edit check) to balance thoroughness against friction
- The prerequisite assertion (not re-running build/tests) avoids duplication when the `verification-before-completion` skill is also used
Loading