nxt-api-route

nxt-api-route is a command for Claude Code from mertjane/awesome-claude-commands. It costs 37 tokens per session (1,135 once invoked), scanned A, original, MIT.

A generator for Next.js App Router API route files. Next.js is a web framework, and an API route is server code that handles requests such as GET or POST.

In plain words
What is it for?
Use it to create a typed route.ts handler for a chosen path and HTTP methods, with request validation and error handling.
Why use it?
It avoids repeating route boilerplate and adapts the generated file to the project’s existing imports, authentication, and error-response patterns.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it to create a typed route.ts handler for a chosen path and HTTP methods, with request validation and error handling.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/mertjane/awesome-claude-commands/nxt-api-route
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/mertjane/awesome-claude-commands

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for nxt-api-route

README.md
[![agentmods](https://agentmods.dev/badge/commands/mertjane/awesome-claude-commands/nxt-api-route/github.svg)](https://agentmods.dev/commands/mertjane/awesome-claude-commands/nxt-api-route)
Your own site
<a href="https://agentmods.dev/commands/mertjane/awesome-claude-commands/nxt-api-route"><img src="https://agentmods.dev/badge/commands/mertjane/awesome-claude-commands/nxt-api-route/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for nxt-api-route

Your own site · 80×15
<a href="https://agentmods.dev/commands/mertjane/awesome-claude-commands/nxt-api-route"><img src="https://agentmods.dev/badge/commands/mertjane/awesome-claude-commands/nxt-api-route.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 37 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,135 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00037 $0.01135
Opus 5 $0.00018 $0.00567
Sonnet 5 $0.00007 $0.00227
Haiku 4.5 $0.00004 $0.00113

Measured 10d ago against content hash 2bf32314875b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

nxt-api-route scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/nxt-api-route.md · 172 lines

How it starts

The opening of the file, as written. The whole thing — 172 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Generate Next.js API Route Handler

Create a Next.js App Router route.ts file for the path provided in $ARGUMENTS.

Parse $ARGUMENTS:

  • First word → route path (e.g. users, auth/login, posts/[id])
  • Second word (optional) → comma-separated HTTP methods to generate (e.g. GET,POST). If not provided, infer from route name.

Step 1 — Detect Project Structure

Find the app directory: app/ or src/app/

Check for existing API routes:

Glob: {app,src/app}/**/route.ts

Read 1–2 existing route files to detect:

  • Import style (@/ aliases vs relative)
  • Auth middleware pattern (how protected routes validate tokens)
  • Error response format ({ error: string } vs { message: string } vs custom)
  • Response helper usage (NextResponse.json vs Response)

Step 2 — Detect Auth Pattern

Search for auth middleware or utility:

Glob: {lib,src/lib,middleware,src/middleware,utils,src/utils}/**/*.{ts,js}

Look for: verifyToken, getSession, auth, getCurrentUser, withAuth

If found, read the file and understand the signature so the generated route can import and use it correctly.

Step 3 — Infer HTTP Methods

If methods are not specified in $ARGUMENTS, infer from the route name:

Route contains Default methods
login, signin, register, signup POST
logout, signout POST
[id] or [slug] GET, PUT, DELETE
No dynamic segment GET, POST
search, filter GET
upload POST

Step 4 — Generate route.ts

Generate handlers only for the determined HTTP methods.

Base imports (always include):

import { NextRequest, NextResponse } from "next/server"

If dynamic segment in path:

interface RouteParams {
  params: Promise<{ {param}: string }>
}

GET handler template:

export async function GET(
  request: NextRequest,
  { params }: RouteParams  // only if dynamic segment
) {
  try {
    // const { {param} } = await params  // only if dynamic segment
    // const searchParams = request.nextUrl.searchParams
    // const query = searchParams.get("q")

    return NextResponse.json({ data: null }, { status: 200 })
  } catch (error) {
    return NextResponse.json(
      { error: "Internal server error" },
      { status: 500 }
    )
  }
}

Read the full file on GitHub · 172 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 172 lines · 37 tokens per session scan A 2bf32314875b

Subscribe to this mod's changes

nxt-api-route is a command published in the GitHub repository mertjane/awesome-claude-commands (2 stars, last pushed 6mo ago), licensed MIT. It adds 37 tokens to every session and 1,135 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.