Webspresso — Claude Code Assistant Guide
Webspresso is a lightweight, zero-dependency-sprawl full-stack Node.js SSR & API framework.
[!IMPORTANT] Authoritative Rules & Architecture: Always follow AGENTS.md and the modular topic guides in .agents/. API & Types Ground Truth: Inspect index.d.ts for exact method signatures.
⚡ Essential Commands #
# Run test suite (Node >= 20 required)
npm test
npx vitest run tests/unit/
npx vitest run tests/integration/
npx vitest run tests/security/
# Development & diagnostics
npm run dev
npx webspresso doctor
npx webspresso db:migrate
🛡️ Critical Architecture Rules #
100% File-Based Routing (NO
routes/orapp.get()):- All endpoints live in
pages/api/...with HTTP method extensions:pages/api/notes.get.js→GET /api/notespages/api/notes.post.js→POST /api/notespages/api/notes/[id].get.js→GET /api/notes/:idpages/api/notes/[id].delete.js→DELETE /api/notes/:id
- Contract:
module.exports = { schema: ({ z }) => ({ body, query, params }), middleware: ['auth'], handler: async (req, res) => ... }
- All endpoints live in
Strict Repository Pattern (NO Raw
db('table')):- Never run raw Knex queries (
req.db('table')). - Always use
req.db.getRepository('ModelName')to ensure schema validation, hooks, scopes, and query caching.
- Never run raw Knex queries (
Services Layer (NO
controllers/):- Place business logic in
services/domain/action.jsand invoke viactx.service('domain.action', input).
- Place business logic in
Zero-Dependency Native Dual Auth:
- Never install
jsonwebtoken,passport, orexpress-session. - Use built-in
req.authandwebspresso/core/auth.
- Never install
Semantic Exceptions & Page Loaders:
- Throw
NotFoundError,ValidationError,UnauthorizedError,ForbiddenError. - For SSR pages (
pages/name.njk), use companion loaderspages/name.jsexportingasync function load({ req, res, db, ctx }). Never callres.render()manually.
- Throw
Zero Regression Policy:
- Always run the relevant Vitest tests before declaring any task complete.