nifra-api

nifra-api is a skill for Claude Code from nifrajs/nifra. It costs 73 tokens per session (1,133 once invoked), scanned A, original, MIT.

A guide for building typed JSON APIs in Nifra, including routes, request validation, middleware, plugins, WebSockets, OpenAPI descriptions, and a client that needs no generated code. Typed APIs describe the expected shapes of requests and responses so mistakes can be caught earlier.

In plain words
What is it for?
Creating or changing Nifra API routes, validating bodies and parameters, adding middleware or WebSockets, publishing API contracts, and calling the API from the Nifra client.
Why use it?
It helps keep API inputs and outputs consistent and rejects invalid requests before application code handles them.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the nifra plugin — 4 skills shipped together

Good fit Creating or changing Nifra API routes, validating bodies and parameters, adding middleware or WebSockets, publishing API contracts, and calling the API from the Nifra client.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/nifrajs/nifra/nifra-api
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.

Any agent
npx skills add nifrajs/nifra --skill nifra-api
Clone the repo
git clone --depth 1 https://github.com/nifrajs/nifra

Made for: Claude Code.

Or install nifra, the plugin that ships this one along with the rest of its 4 skills.

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 nifra-api

README.md
[![agentmods](https://agentmods.dev/badge/skills/nifrajs/nifra/nifra-api.svg)](https://agentmods.dev/skills/nifrajs/nifra/nifra-api)
Your own site
<a href="https://agentmods.dev/skills/nifrajs/nifra/nifra-api"><img src="https://agentmods.dev/badge/skills/nifrajs/nifra/nifra-api.svg" alt="Measured on agentmods" height="20"></a>
Per session 73 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,133 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00073 $0.01133
Opus 5 $0.00036 $0.00566
Sonnet 5 $0.00015 $0.00227
Haiku 4.5 $0.00007 $0.00113

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

Security

Grade A, and why

nifra-api scanned grade A with 1 finding 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 8d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

The app is `app.fetch(Request): Promise<Response>`. Bun is first-class; Node
packages/skills/skills/nifra-api/SKILL.md · 98 lines

How it starts

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

Nifra: typed APIs and the typed client

Fetch exact signatures with nifra_types and compiling snippets with nifra_example before writing anything non-trivial. This skill is the shape of the thing, not a substitute for either.

Two ways to declare routes

server() - chainable, inference-first. Reach for this by default.

import { server } from "@nifrajs/core/server"
import { t } from "@nifrajs/schema"

export const app = server()
  .get("/notes", () => listNotes())
  .get("/notes/:id", { params: t.object({ id: t.string() }) }, (c) => getNote(c.params.id))
  .post("/notes", { body: t.object({ title: t.string(), body: t.string() }) }, (c) =>
    createNote(c.body),
  )

defineContract - the same routes as a standalone, versionable artifact when the contract must be published, shared across repos, or evolved independently of the handlers. Ask nifra_docs for the contract page before choosing it; do not reach for it just because a route feels important.

Validation belongs in the route options

body, query, params, headers, and response all take a schema. Anything that fails becomes a structured 422 before your handler runs, so a handler never defensively re-checks its own input.

@nifrajs/schema (t) is TypeBox-backed and gives you JSON Schema and OpenAPI for free. Any Standard Schema library works too - Zod and Valibot slot into the same option with no adapter.

import { z } from "zod"
app.post("/users", { body: z.object({ email: z.string().email() }) }, (c) => c.body.email)

Typed search params: declare query and read c.query typed. Do not parse new URL(c.req.url) by hand.

The client never throws

const res = await api.notes({ id }).get()
if (!res.ok) return handle(res.error)   // transport and HTTP failures both land here
res.data                                // typed from the route's return type

Three consequences worth internalising:

  • No try/catch around a client call for HTTP or network failure. Only genuinely exceptional code throws.
  • The client is browser-safe. It carries the server's types, never its code.
  • Changing a route's shape breaks every caller at compile time. That is the feature. Fix the callers; do not widen the type to silence tsc.

Read the full file on GitHub · 98 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. 8d ago First seen · 98 lines · 73 tokens per session scan A c5c19c0e7464

Subscribe to this mod's changes

nifra-api is a skill published in the GitHub repository nifrajs/nifra (2 stars, last pushed 5d ago), licensed MIT. It adds 73 tokens to every session and 1,133 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.