Skip to content
Agentmart
Submit a tool

nextjs-check-route-types

Type-system hygiene for Next.js App Router routes -- `any`-typed params, missing route handler signatures, generated-types staleness from `next dev` and `next…

Skill by MILTONADINA

IndexedMIT
Write a review

Chalk Labs

Need help deploying nextjs-check-route-types?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/miltonadina-nextjs-check-route-types

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Type-system hygiene for Next.js App Router routes -- `any`-typed params, missing route handler signatures, generated-types staleness from `next dev` and `next build` typecheck gaps. Triggers on Next.js route handler authoring (`app/**/route.ts`, `app/**/page.tsx` typed-segments). Not agent-specific security; complementary to runtime hardening.

Use cases: frontend, security, agent-building

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/nextjs-check-route-types

What's inside

Skill name
nextjs-check-route-types
Description
Type-system hygiene for Next.js App Router routes -- `any`-typed params, missing route handler signatures, generated-types staleness from `next dev` and `next build` typecheck gaps. Triggers on Next.js route handler authoring (`app/**/route.ts`, `app/**/page.tsx` typed-segments). Not agent-specific security; complementary to runtime hardening.
License
MIT
Instructions
203 lines in SKILL.md · view on GitHub

Agent Skills spec issues

  • name: "nextjs-check-route-types" does not match folder "check-route-types"

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Next.js Route Type Checking

> This skill addresses **type-system correctness**, not agent-specific
> security. The patterns here close compile-time blind spots that allow
> runtime bugs and complicate review; they are NOT the load-bearing
> defense against any OWASP ASI / AST threat. The runtime hardening of
> route handlers is the responsibility of
> `skills/stack-specific/nextjs/server-action-safety/SKILL.md` and the
> universal `security/prompt-injection-defense` skill.

**Tradeoff:** Stricter route typing catches a class of integration bugs
at build time rather than at request time. Cost: per-PR friction when
Next.js's generated types (`.next/types/...`) lag behind route file
changes during local development.

---

## Why this matters

Next.js App Router generates route types from the file system shape
during `next dev` and `next build` (and `next typegen` on 15.5+):
`app/posts/[slug]/route.ts` produces a typed
`{ params: Promise<{ slug: string }> }` context argument. When those generated
types are stale (e.g., a new dynamic segment added but `next dev` hasn't
re-generated), the handler signature reverts to a permissive default and
runtime arguments flow through unchecked. Reviewers see "the types pass"
without realizing the types are vacuous.

This is a footgun across the entire surface area:

- `app/api/**/route.ts` handlers with implicit-`any` parameters.
- `app/[slug]/page.tsx` route segments with un-narrowed param types.
- `searchParams` accessed without runtime validation.
- Proxy (`proxy.ts`; `middleware.ts` before Next.js 16) reading headers
  without typing them.

None of these are security failures on their own. They're conditions
under which a separate runtime-validation gap (the actual security
control) hides because the type checker isn't complaining.

---

## Pattern 1 -- Always type route handler signatures explicitly

The compile-time signature for an App Router handler:

```ts
// app/api/posts/[slug]/route.ts
import { NextRequest, NextResponse } from 'next/server';

type RouteContext = {
  params: Promise<{ slug: string }>;
};

export async function GET(
  request: NextRequest,
  context: RouteContext,
): Promise<NextResponse> {
  const { slug } = await context.params;
  // ... handler body ...
  return NextResponse.json({ slug });
}
```

Explicit `NextRequest` (NOT bare `Request`) gives access to Next.js-
specific fields (`request.nextUrl`, `request.cookies`). Explicit
`RouteContext` ties the handler's expected dynamic segments to the file
path; a renamed segment that doesn't match `slug` is a compile error.

Note Next.js 15+ awaits `params` as a Promise. Older code with sync
params won't compile against newer Next.js without migration.

---

## Pattern 2 -- Validate `searchParams` at the route boundary

```ts
import { z } from 'zod';

const SearchSchema = z.object({
  page: z.coerce.number().int().positive().default(1),
  perPage: z.coerce.number().int().min(1).max(100).default(20),
  q: z.string().max(200).optional(),
});

export async function GET(request: NextRequest) {
  const parsed = SearchSchema.safeParse(
    Object.fromEntries(request.nextUrl.searchParams),
  );
  if (!parsed.success) {
    return NextResponse.json({ error: 'invalid query' }, { status: 400 });
  }
  const { page, perPage, q } = parsed.data;
  // ... use typed values, NOT raw searchParams ...
}
```

`searchParams` is `URLSearchParams`. Its `.get()` returns `string | null`;
there's no compile-time guarantee that the query string contains what
the handler assumes. Runtime validation closes the gap.

---

## Pattern 3 -- Regenerate types on dynamic-segment renames

When you rename `app/posts/[slug]/route.ts` to `app/posts/[postId]/route.ts`,
the next `next build` (or `next dev` HMR refresh) regenerates the
RouteContext types with the new param name. UNTIL that happens, the
handler still compiles against the old generated types.

Discipline: after any file-system rename inside `app/`, run
`next typegen && tsc --noEmit` (Next.js 15.5+; on older versions,
`next build`) before committing. Run the same pair in CI: plain
`tsc --noEmit` does not generate route types, so on its own it checks
against stale or missing `.next/types` and can pass.

---

## Anti-patterns

From MILTONADINA/DevOPs, MIT.

More from MILTONADINA/DevOPs

Signals

Stars
0
Forks
0
Open issues
12
Last commit (this folder)
Sep 25, 2026 (1 month ago)
Last release
Sep 23, 2026 (1 month ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from MILTONADINA

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get nextjs-check-route-types running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying nextjs-check-route-types?

CallGet help
Cite this page

nextjs-check-route-types skill. Agent Mart. https://agentmart.dev/skills/miltonadina-nextjs-check-route-types (last updated 2026-10-24)