Skip to main content
Back

Kun Chen's gnhf Lets Coding Agents Work All Night Without Babysitting

gnhf is a free, open-source CLI that runs your coding agents overnight, committing incremental progress toward a goal while you sleep

Repo, Full Access
  • What it is: gnhf is a free, open-source CLI that runs coding agents in an autonomous loop overnight toward a user-defined objective.
  • How it works: Each iteration builds a prompt, invokes an agent in non-interactive mode, commits on success, and hard-resets on failure with exponential backoff.
  • Agent support: Works out of the box with Claude Code, OpenAI Codex, Atlassian Rovo Dev, and OpenCode.
  • Cost controls: --max-iterations and --max-tokens flags cap spend; the circuit breaker aborts after 3 consecutive failures.
  • Best for: Large-scale refactors, test generation, docstring writing, and dependency migrations on well-defined codebases.
  • Install: npm install -g gnhf, requires Node.js 20+ and a Git repo with a clean working tree.

gnhf (short for "good night, have fun") is a deceptively simple idea: before you go to bed, you give your coding agent an objective, and it keeps working until you wake up. You get a clean Git branch full of incremental commits and a log of everything that happened. No babysitting required.

The project, built in TypeScript by Kun Chen, has quietly accumulated over 2,000 stars on GitHub. The pitch is blunt: stop leaving your AI token quota unused overnight when it could be chipping away at your backlog.

The loop that makes it work

gnhf is a specialized autonomous orchestrator designed for long-running, incremental code transformations. It follows a "ralph" or "autoresearch" style pattern where an agent is tasked with a high-level objective and proceeds through a series of small, documented, committed changes. The primary value proposition is reliability over long durations.

The "ralph loop" pattern is worth understanding. It is essentially a bash loop: simple, repeatable, and shockingly effective. The real secret to shipping reliable code at scale is ruthless simplicity and frequent context resets. gnhf takes that idea and wraps it in proper Git discipline, retry logic, and cross-iteration memory.

Here is what one iteration looks like under the hood:

  1. Context assembly: gnhf builds a prompt from your objective plus a notes.md file that accumulates summaries from every prior iteration. This is the agent's shared memory across runs.