agentleFS
justrachjustrach/merjs/AGENTS.md

merjs

AGENTS.md357 starsChanged 3 months agoMITView on GitHub

merjs is a Next.js-style web framework written in Zig. Zero Node.js. File-based routing, SSR, type-safe APIs, WASM client logic, Cloudflare Workers deploy. Zig pin: 0.17.0-dev.1862+40ebd8162 (build.zig.zon minimum_zig_version). Download from https://ziglang.org/download/ (master / builds). Run with --verbose to log every request with timing: When a route handler errors in dev mode, the browser shows a styled error page with: - The error name (e.g. OutOfMemory) - The request path - Debugging tips - Framework version In production (--no-dev), errors log to…

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 31,439 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository6 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run with --verbose to log every request with timing:

    line 88
  2. Distinctive:

    When a route handler errors in dev mode, the browser shows a styled error page with:

    line 97
  3. Very specific:

    Create app/mypage.zig (page) or api/myendpoint.zig (API)

    line 141
  4. Very specific:

    Run zig build codegen to regenerate the route table

    line 143
  5. Very specific:

    Use mer.h.div(...) for comptime HTML builder

    line 150
  6. Very specific:

    Use mer.dhi.Model(...) for request validation

    line 151
  7. Very specific:

    Use pub const meta: mer.Meta = .{ .title = "..." } for SEO

    line 152

≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md — for coding agents working on merjs

What is this?

merjs is a Next.js-style web framework written in Zig. Zero Node.js. File-based routing, SSR, type-safe APIs, WASM client logic, Cloudflare Workers deploy.

Zig pin: 0.17.0-dev.1862+40ebd8162 (build.zig.zon minimum_zig_version). Download from https://ziglang.org/download/ (master / builds).

Project structure

src/              Framework runtime (the library)
  mer.zig         Public API surface — thin re-exports
  server.zig      HTTP server, dev endpoints, error overlay
  router.zig      Route matching + dispatch
  session.zig     HMAC session sign/verify
  fetch.zig       SSR HTTP client (single + parallel)
  html.zig        Comptime HTML builder DSL
  static.zig      Static file serving from public/
  watcher.zig     File watcher + SSE hot reload
  main.zig        Server entry point (not app-specific)

build/            Build system modules
  helpers.zig     addDirModules, addWasmExe
  examples.zig    Example project targets
  tools.zig       Tailwind auto-download
  packages.zig    Package test wiring

examples/site/    Demo app (merlionjs.com) — NOT framework code
  app/            Page routes (*.zig → SSR HTML)
  api/            API routes (*.zig → JSON)
  wasm/           Client WASM modules
  public/         Static assets
  worker/         Cloudflare Workers config

cli.zig           `mer` CLI (init, dev, build, add, update)
build.zig         Top-level build — delegates to build/

Quick commands

# Build & run the demo site
zig build codegen       # scan app/ + api/, generate route table
zig build serve         # dev server on :3000 with hot reload

# With verbose request logging
zig build serve -- --verbose

# Build CLI
zig build cli

# Build WASM modules
zig build wasm

# Build for Cloudflare Workers
zig build worker

# Run tests
zig build test

# Full production build
zig build prod

Debugging

Dev endpoints (only active in dev mode)

  • http://localhost:3000/_mer/debug — shows all routes, framework version, Zig version, route counts
  • http://localhost:3000/_mer/debug?format=json — same as above, machine-readable JSON
  • http://localhost:3000/_mer/events — SSE hot reload stream

Production endpoints (always available)

  • GET /_mer/health — liveness probe, returns {"status":"ok",...} JSON
  • GET /_mer/ready — readiness probe, same payload (separate path for k8s)

Environment variables for deployment

  • PORT — listening port (PaaS standard: Fly, Render, Railway, Heroku, Cloud Run inject this)
  • HOST — bind interface; defaults to 0.0.0.0 in --no-dev, 127.0.0.1 in dev
  • MERJS_DEV=0 — disable hot reload (equivalent to --no-dev)

Verbose mode

Run with --verbose to log every request with timing:

info(server): GET / 266µs
info(server): GET /api/hello 42µs
info(server): GET /counter 891µs

Error overlay

When a route handler errors in dev mode, the browser shows a styled error page with:

  • The error name (e.g. OutOfMemory)
  • The request path
  • Debugging tips
  • Framework version

In production (--no-dev), errors log to stderr and return a clean 500.

Common issues

SymptomFix
zig build fails with "missing fingerprint"Run zig build once, copy the suggested value into build.zig.zon
codegen: wrote 0 routesMake sure app/ and api/ dirs exist with .zig files
Port 3000 in usezig build serve -- --port 8080
Server unreachable in DockerUse --host 0.0.0.0
CSS not workingRun zig build css (auto-downloads Tailwind CLI) or mer add css
WASM not loadingRun zig build wasm to compile .wasm files to public/

Telemetry (Sentry + Datadog)

Both are opt-in via env vars — zero overhead when not configured.

Sentry (error tracking):

SENTRY_DSN=https://your-key@sentry.io/your-project-id

Route handler errors are automatically reported with error name, request path, and framework version.

Datadog (request metrics via DogStatsD):

DD_AGENT_HOST=127.0.0.1
DD_DOGSTATSD_PORT=8125    # default

Sends per-request timing (merjs.request.duration) and error counts (merjs.request.error) with path/method/status tags.

Docker

docker build -t merjs .
docker run -p 3000:3000 merjs

Adding routes

  1. Create app/mypage.zig (page) or api/myendpoint.zig (API)
  2. Export pub fn render(req: mer.Request) mer.Response
  3. Run zig build codegen to regenerate the route table
  4. zig build serve picks it up

Key conventions

  • Pages return HTML: return mer.html("<h1>Hello</h1>");
  • APIs return JSON: return mer.json("{\"ok\":true}");
  • Use mer.h.div(...) for comptime HTML builder
  • Use mer.dhi.Model(...) for request validation
  • Use pub const meta: mer.Meta = .{ .title = "..." } for SEO
  • Layouts: export from app/layout.zig, pages auto-wrap
  • Dynamic routes: app/users/[id].zig → /users/:id

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.