{"slug": "show-hn-nightshift-guardrails-for-running-a-coding-agent-overnight", "title": "Show HN: Nightshift, guardrails for running a coding agent overnight", "summary": "Toolshed Labs released Nightshift, a set of bash scripts and patterns for running coding agents like Claude Code unattended overnight without excessive token usage or unverified output. The four core habits are a handoff file for state persistence, a verification gate that rejects unverified code, a three-way cost cap (iteration limit, wall-clock deadline, stop file), and a structured log that summarizes decisions first. The repo is MIT-licensed and dependency-free.", "body_md": "Patterns and small tools for running a coding agent unattended overnight without it turning into a token bonfire.\n\nLeaving Claude Code (or any coding agent) running while you sleep is a great deal when it works. You wake up to real progress. The way it fails is worse than most people brace for. A crash would be fine, you lose a few hours and start over. What actually happens is it keeps going for nine hours, confident and wrong, or loops on an error it cannot see and spends money on every retry. In the morning you have a pile of unverified output and a bill.\n\nThis repo is the boring layer that makes the good outcome the normal one. No framework, no dependencies, no loop of its own. It assumes you already have a way to run the agent. It gives you the four habits that decide whether an overnight run is worth doing, plus a handful of tiny bash tools that make those habits automatic instead of aspirational.\n\nWe build developer tools and we run coding agents unattended a lot. These are the patterns we reach for every time. They are generic on purpose. Use the ideas, use the scripts, or read the README and write your own. All of it is MIT.\n\nAn overnight run will be interrupted. Rate limits, a crash, a quota reset, you killing it at 2am. If the only record of where it got to lives in the agent's context window, the interruption costs you the whole night.\n\nThe fix is one file that always describes the current state, rewritten (not appended) at the end of every unit of work. Goal, status right now, the single next action, known traps, what has actually been verified. A fresh run reads that file first and continues as if nothing happened. It is the cheapest reliability you can buy.\n\nSee [ templates/HANDOFF.md](/toolshedlabs-hash/nightshift/blob/main/templates/HANDOFF.md).\n\nAn agent will report success on code that does not compile. Not because it is lying, because \"I wrote the code\" and \"the code works\" feel the same from the inside. If you trust overnight output, you are building the next eight hours of work on top of things that were never checked.\n\nSo do not trust it. Gate it. Put your real checks (build, tests, a linter, a smoke script) behind a wrapper that fails closed. If the checks pass, accept the work and move on. If they fail, stop or escalate instead of piling more work on a broken base.\n\nSee [ bin/verify-gate](/toolshedlabs-hash/nightshift/blob/main/bin/verify-gate).\n\nThe run that costs you is the one that works perfectly and does the wrong thing for six hours. A crash is cheap next to that. You want a hard ceiling so the worst possible night still has a bounded cost.\n\nCap the loop three ways: a maximum number of iterations, a wall-clock deadline, and a stop file you (or a failed gate) can drop to halt it immediately. Any one of the three ends the run cleanly. A bad night becomes a small bill instead of an open question.\n\nSee [ bin/runaway-guard](/toolshedlabs-hash/nightshift/blob/main/bin/runaway-guard).\n\nIf reviewing the night means scrolling ten thousand lines of agent chatter, you will not do it, and the whole point was to save your attention. The run should narrate itself as it goes, in a format something can summarize. Then you wake up to a single page: the decisions waiting on you first, then what got done, then cost and notes.\n\nDecisions first is the important part. That is the only section that needs you before the next run starts.\n\nSee [ bin/nightlog](/toolshedlabs-hash/nightshift/blob/main/bin/nightlog) (the run narrates) and\n\n[(you read the summary).](/toolshedlabs-hash/nightshift/blob/main/bin/morning-brief)\n\n`bin/morning-brief`\n\nEverything is bash with no dependencies. Clone it and run the demo to see the whole kit work end to end in about a second:\n\n```\ngit clone https://github.com/toolshedlabs-hash/nightshift\ncd nightshift\n./examples/demo.sh\n```\n\nThat simulates a short night: bounded iterations under the guard, a couple of logged events, a verification gate with one pass and one deliberate fail, and the morning brief it all produces.\n\nTo use the tools in your own run, put `bin/`\n\non your `PATH`\n\n(or call the scripts by\npath) and wire them into however you already launch the agent:\n\n```\n# stop after 40 iterations or 8 hours, whichever comes first\nwhile runaway-guard --max-iters 40 --max-minutes 480; do\n\n  # ... your agent does one bounded unit of work here ...\n\n  # the run narrates what happened\n  nightlog done \"refactored the parser and added a test\"\n\n  # only accept the work if it actually passes\n  if ! verify-gate \"npm test\" \"npm run build\"; then\n    nightlog blocked \"tests failed after the parser change, needs a look\"\n    break\n  fi\ndone\n\n# in the morning\nmorning-brief > MORNING-BRIEF.md\n```\n\nTo halt a running loop by hand, drop a stop file:\n\n```\ntouch .nightshift/STOP\n```\n\n| Tool | What it does |\n|---|---|\n`bin/runaway-guard` |\n\n`bin/verify-gate`\n\n`bin/nightlog`\n\n`done`\n\n, `blocked`\n\n, `note`\n\n, `cost`\n\n) to the night log.`bin/morning-brief`\n\n`templates/HANDOFF.md`\n\nState (the log, iteration counter, deadline) lives in `.nightshift/`\n\nby default. Set\n`NIGHTSHIFT_DIR`\n\nto move it. That directory is gitignored, since it is per-run state and\ndoes not belong in your history.\n\nBecause the hard part is the discipline, not the code, and discipline survives better as four ideas you actually understand than as a framework you install and forget. Every script here is short enough to read in a minute and change to fit your setup. That is the intent. Fork it, gut it, keep the two tools you like.\n\nWe built a harder version of this for our own overnight runs and packaged it as a Pro pack. What it adds: a cost governor with a real dollar ledger and a hard ceiling that fails closed, a supervisor that backs off and retries a rate limit or a crash instead of losing the night, a verification gate that runs named checks from config and writes a structured report, stuck-loop detection on top of the iteration and time caps, desktop, email and webhook escalation, and an orchestrator that runs all of it as one loop. This free kit is the honest core of it, not a crippled teaser.\n\nTwo limits worth knowing before you spend anything. The ledger is manual: you feed it the numbers your run reports and it enforces the ceiling against that running total, so it cannot read your provider's live bill for you. And because the budget is checked after each unit is recorded, the ceiling can overshoot by up to one unit's cost.\n\nIt is 79 dollars, one payment, and you get the whole kit as a download (the tools, a worked example that drives a real agent, tests, and a setup guide). The honest test is simple: if the four free scripts already stop your bad nights, keep your money, you are done. If you would rather buy the hardened version than build it, what it does and what it does not do is written up here:\n\n[https://nightshift.pagelens.dev](https://nightshift.pagelens.dev)\n\nIf the download fails, or it is not what you expected, or you just changed your mind,\nemail [toolshedlabs@gmail.com](mailto:toolshedlabs@gmail.com) within 30 days and we refund it. No argument, no form to\nfill in. Same address for bugs and questions.\n\nBuilt by [toolshed](https://github.com/toolshedlabs-hash), maker pen name Cal. We make\ndeveloper tools and we operate coding agents unattended, so we care a lot about the\ndifference between an overnight run that pays off and one that just spends. If these\npatterns save you a bad morning, good.\n\nIssues and pull requests welcome. If you have a pattern that has saved you on an unattended run, open one.\n\nMIT. See [LICENSE](/toolshedlabs-hash/nightshift/blob/main/LICENSE). Copyright toolshed.", "url": "https://wpnews.pro/news/show-hn-nightshift-guardrails-for-running-a-coding-agent-overnight", "canonical_source": "https://github.com/toolshedlabs-hash/nightshift", "published_at": "2026-07-29 14:15:31+00:00", "updated_at": "2026-07-29 14:22:39.604917+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents", "ai-tools"], "entities": ["Toolshed Labs", "Claude Code", "Nightshift"], "alternates": {"html": "https://wpnews.pro/news/show-hn-nightshift-guardrails-for-running-a-coding-agent-overnight", "markdown": "https://wpnews.pro/news/show-hn-nightshift-guardrails-for-running-a-coding-agent-overnight.md", "text": "https://wpnews.pro/news/show-hn-nightshift-guardrails-for-running-a-coding-agent-overnight.txt", "jsonld": "https://wpnews.pro/news/show-hn-nightshift-guardrails-for-running-a-coding-agent-overnight.jsonld"}}