Create a new merjs API route

SkillDev tools

Scaffold a new merjs API route. Use when the user wants to create a new API endpoint.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Create a new merjs API route skill

What this skill tells your AI

The instructions your AI receives, as published by justrach/merjs in .claude/skills/new-api/SKILL.md and read by ahel’s review.

Scaffold a new API route at api/$ARGUMENTS.zig.

Steps

  1. Create api/$ARGUMENTS.zig with this template:
const mer = @import("mer");

const Response = struct {
    // Define your response fields here
    message: []const u8,
};

pub fn render(req: mer.Request) mer.Response {
    return mer.typedJson(req.allocator, Response{
        .message = "hello",
    });
}
  1. Adapt the Response struct fields based on what the user described
  2. Run zig build codegen to regenerate routes
  3. Confirm the route appears at /api/$ARGUMENTS

Conventions

  • API routes live in api/ and map to /api/...
  • Use mer.typedJson(allocator, value) to return typed JSON responses
  • Use mer.json(string) for raw JSON strings
  • Access request body via req.body, method via req.method
  • Access query string via req.query_string
  • Access cookies via req.cookie("name")
  • For validation, use dhi: const dhi = @import("dhi_validator");
  • API routes do NOT need pub const meta

Signals

GitHub stars
354
Forks
17
Last commit
Aug 2026
Advanced
Catalog kind
skill
Gateway key
new-api-justrach
Source
github.com/justrach/merjs