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.
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
- Very specific: line 88
Run with --verbose to log every request with timing:
- Distinctive: line 97
When a route handler errors in dev mode, the browser shows a styled error page with:
- Very specific: line 141
Create app/mypage.zig (page) or api/myendpoint.zig (API)
- Very specific: line 143
Run zig build codegen to regenerate the route table
- Very specific: line 150
Use mer.h.div(...) for comptime HTML builder
- Very specific: line 151
Use mer.dhi.Model(...) for request validation
- Very specific: line 152
Use pub const meta: mer.Meta = .{ .title = "..." } for SEO
≈ “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.
Files
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 prodDebugging
Dev endpoints (only active in dev mode)
http://localhost:3000/_mer/debug— shows all routes, framework version, Zig version, route countshttp://localhost:3000/_mer/debug?format=json— same as above, machine-readable JSONhttp://localhost:3000/_mer/events— SSE hot reload stream
Production endpoints (always available)
GET /_mer/health— liveness probe, returns{"status":"ok",...}JSONGET /_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 to0.0.0.0in--no-dev,127.0.0.1in devMERJS_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µsError 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
| Symptom | Fix |
zig build fails with "missing fingerprint" | Run zig build once, copy the suggested value into build.zig.zon |
codegen: wrote 0 routes | Make sure app/ and api/ dirs exist with .zig files |
| Port 3000 in use | zig build serve -- --port 8080 |
| Server unreachable in Docker | Use --host 0.0.0.0 |
| CSS not working | Run zig build css (auto-downloads Tailwind CLI) or mer add css |
| WASM not loading | Run 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-idRoute 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 # defaultSends 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 merjsAdding routes
- Create
app/mypage.zig(page) orapi/myendpoint.zig(API) - Export
pub fn render(req: mer.Request) mer.Response - Run
zig build codegento regenerate the route table zig build servepicks 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
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
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.

