CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/nextjs-api-patterns

Next.js App Router API patterns — Route Handlers, Server Actions, middleware, validation, caching, error handling

92

1.58x
Quality

90%

Does it follow best practices?

Impact

95%

1.58x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-2/

{
  "context": "Tests whether the agent correctly chooses Route Handlers for external API and Server Actions for internal forms. The task mentions both external consumers and an admin UI, so the agent should use the right abstraction for each. Also tests validation, revalidation after mutations, and proper error handling in both patterns.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "Route Handlers for public API",
      "description": "Public-facing read endpoints (GET posts, GET post by slug) are implemented as Route Handlers in app/api/*/route.ts files, not as Server Actions",
      "max_score": 14
    },
    {
      "name": "Server Actions for admin forms",
      "description": "Create and edit post forms use Server Actions (functions with 'use server' directive) rather than client-side fetch to Route Handler endpoints",
      "max_score": 14
    },
    {
      "name": "Revalidation after mutations",
      "description": "Server Actions call revalidatePath() or revalidateTag() after creating or editing a post so the post list and post pages reflect the changes",
      "max_score": 13
    },
    {
      "name": "Validation in both Route Handlers and Server Actions",
      "description": "Both Route Handlers and Server Actions validate input with a schema library (zod recommended). Server Actions return field-level errors as state for the form to display.",
      "max_score": 12
    },
    {
      "name": "Server Action error handling pattern",
      "description": "Server Actions return error state objects (e.g. { errors: {...}, message: '...' }) rather than throwing exceptions, so the form can display validation errors to the user",
      "max_score": 10
    },
    {
      "name": "Params awaited in dynamic routes",
      "description": "Dynamic routes (e.g. [slug]) await the params object before accessing values",
      "max_score": 10
    },
    {
      "name": "Structured error responses from Route Handlers",
      "description": "Route Handler errors use consistent { error: { code, message } } shape with appropriate status codes",
      "max_score": 9
    },
    {
      "name": "use client on form components",
      "description": "Form components that use hooks (useActionState, useState) are correctly marked with 'use client' directive",
      "max_score": 8
    },
    {
      "name": "Functional implementation",
      "description": "Posts can be created, listed, and read via the implemented endpoints and forms. Slug uniqueness is enforced.",
      "max_score": 10
    }
  ]
}

evals

tile.json