Your app goes live. Weeks later, the first sign anything is wrong shows up in a DM: "hey, the site just gives me an error." You open your terminal and there's nothing to look at, because nobody ever wired up logging. Now you're debugging by guessing while the user refreshes and gets angrier.
The gap between "it works when I click through it" and "it works at 3am for a stranger on a phone" is where small apps quietly lose users. The fix is not a monitoring stack and it's not a paid service. It's four small additions your coding agent can make in one session: structured logs, a health endpoint, an external ping, and a new habit for how you debug. Together they turn "it's broken somewhere" into "here is the exact request that failed."
"It works on my machine" is not monitoring
Vibe-coding an app is mostly building features. The agent writes the endpoint, you click it, it works, you deploy. What never gets built is the part that runs when you're not clicking: the record of what happened. So when production breaks, you have three sources of truth and all of them are bad: your memory of the code, the user's description of the bug, and the hosting provider's generic error page.
The habit that fixes this is boring. Every request that reaches your app should leave a trace you can read later, and there should be a machine-readable answer to "is the app up right now." Neither is a feature users will ever see, which is exactly why it never gets built unless you ask for it on purpose.
The rest of this post is the ask. Everything below can go in as one prompt to your coding agent, and the sections explain what you're asking for and why.
1. Structured logs: one JSON line per request
When something breaks, the useful question isn't "what's broken," it's "which request." A structured log answers it. Instead of prose like user tried to check out and it failed, every request writes exactly one line of JSON:
{"ts":"2026-11-07T21:04:11.482Z","request_id":"9b1c4e2a","method":"POST","route":"/checkout","status":500,"duration_ms":842}
In Express this is one middleware function registered before your routes (the middleware docs are the reference):
import express from "express";
import { appendFile } from "node:fs/promises";
import crypto from "node:crypto";
const app = express();
app.use(async (req, res, next) => {
const reqId = crypto.randomUUID();
const start = Date.now();
res.setHeader("X-Request-Id", reqId);
res.on("finish", () => {
const line = JSON.stringify({
ts: new Date().toISOString(),
request_id: reqId,
method: req.method,
route: req.path,
status: res.statusCode,
duration_ms: Date.now() - start,
});
appendFile("app.log", line + "\n").catch(() => {});
});
next();
});
On a host without a persistent disk, swap appendFile for console.log(line) and read the lines in your host's log viewer instead; the format is what matters.
The request id comes from crypto.randomUUID(), which is built into Node (docs) and also goes into the response header, so when a user hits an error page you can ask them for the id on it. Log errors in the same shape with an added error field (the prompt below asks for it), and duration_ms shows you which endpoints are slow before anyone complains. req.path keeps query strings out of the log, which is where tokens and emails tend to hide.
2. A /health endpoint that checks more than the port
Your host already restarts the process if it crashes. What it can't tell you is whether the app is working, and the most common way a vibe-coded app silently fails is the database. The app returns 200 on every route because the code is fine; every query fails because the connection pool is dead or the credentials expired.
So the health check does two probes, not one: is the process up, and can the app actually read the database.
app.get("/health", async (_req, res) => {
try {
await pool.query("SELECT 1");
res.status(200).json({ status: "ok" });
} catch (err) {
res.status(503).json({ status: "db_down" });
}
});
Return 503 on failure, not 200 with a sad message, because monitoring tools key on the status code. The process answering is not enough; "healthy" means its dependencies answer too.
3. A free external check pinging /health
Logs tell you what happened after the fact. An external monitor tells you now, which matters because the person who finds a dead app should be you, not your first user of the morning. Free uptime-monitoring services exist that ping a URL on an interval and email you when it starts failing; most hosts also offer a basic health check. Point it at https://yourapp.com/health and you inherit the database check too, since /health returns 503 when the DB is down.
One warning: don't point it at your homepage. A homepage can serve 200 all day while checkout is broken, which is exactly the failure you're trying to catch.
4. The habit: paste the log line, not the story
This is the part that changes your daily life with the agent. The next time something breaks, don't describe the bug. Go get the log lines for the failing request and paste them in:
grep '"request_id":"9b1c4e2a"' app.log
or, when you don't have an id yet, pull the recent failures:
grep '"status":500' app.log | tail -5
Then the conversation with your agent sounds like this: "these requests to /checkout are returning 500, here are the exact log lines, fix it." The agent reads the same facts you do, proposes a fix, and you verify against the next request's log line. If you're picking a plan for the agent you'll be doing this with every week, there's 10% off GLM coding plans. No "hmm, it works when I try it," no twenty-message back and forth about what the user might have clicked. The log line is the truth; everything else is a rumor about it.
The exact prompt for your coding agent
Paste this at the end of your build session, while the agent still has the full codebase in context:
Add observability to this app. No new paid services, no new dependencies
beyond what's needed:
1. Structured request logging: every request writes ONE JSON line to app.log
with ts, request_id, method, route, status, duration_ms. Generate the
request id with crypto.randomUUID(), return it in an X-Request-Id
response header, and show the request id on any error page the user sees.
Log uncaught errors in the same shape with an "error" field.
NEVER log request bodies, Authorization or Cookie headers, emails,
tokens, or any personal data.
2. A GET /health endpoint: 200 {"status":"ok"} when the process is up AND a
trivial database query succeeds, else 503.
3. Tell me how to add a free external uptime monitor that pings /health and
emails me on failure. Include the exact URL to paste.
4. A test that hits an endpoint and asserts the log line parses as JSON and
contains that request's id.
Want an agent harness to run it in? You can try the zcode agent harness free. Whatever you use, read the diff before you deploy: check that the logger really skips headers and bodies.
What NOT to log
The fastest way to make your log file a liability is to log the wrong things. Keep these out:
- Request bodies. They hold passwords, card numbers, and whatever users type into your forms.
AuthorizationandCookieheaders. One leaked session token in a log file is a compromised account.- Emails, names, addresses. If your log file ever leaves your machine, personal data in it becomes someone's problem, and it's yours.
- Full stack traces on every error in production. Log the message and a short error id; dump stacks only when you're actively debugging.
A good rule: every line in your log should be safe to paste into a chat with a stranger. Because with this habit, that's exactly what you'll be doing.
The before-you-call-it-live checklist
[ ] Every request writes one JSON line: request_id, route, status, duration
[ ] Errors log the same line plus an error field
[ ] GET /health returns 200 only when the app AND database are healthy
[ ] An external monitor pings /health and emails me on downtime
[ ] I know where the log file lives and can grep one request_id out of it
[ ] Nothing personal, no tokens, no request bodies in the log
Screenshot this one and keep it next to your deploy button.
There's more on our blog on running small apps with a coding agent. If this saved you an afternoon, a small tip on the post keeps these coming.






Latest comments
0