gnhf - An open-source AI agent autonomous orchestrator that iterates autonomously at night.
gnhf (short for Good Night, Have Fun) is an open-source AI Agent auto-orchestrator. Its core concept is to allow developers to set a goal for the AI before going to sleep, allowing it to iterate and work continuously while you rest. It does only one task at a time...
What is gnhf?
gnhf (full name) Good night, have funThis is an open-source AI agent auto-orchestrator. Its core concept is to allow developers to set a goal for the AI before going to sleep, allowing it to continuously iterate and work while you rest. Each time, only a small change is made, and upon success, it automatically... git commitIf it fails git reset --hard Roll back, and when you wake up, your repository branch will be full of clean commit history and complete logs. It natively supports mainstream AI programming assistants such as Claude Code, Codex, and GitHub Copilot CLI, and features cross-iteration memory sharing, breakpoint resume, multi-task worktree parallelism, and real-time token monitoring. It can be installed with one click via npm, runs across platforms, and is open-source on GitHub under the MIT license.
The main functions of gnhf
-
Nighttime autonomous iterationSimply set a development goal for the AI before going to bed, and the Agent will automatically execute it in a loop while you rest, making only a small change each time, and you can see the complete results when you wake up.
-
Git Discipline-DrivenEach successful iteration automatically generates an independent...
git commitFailed iteration immediatelygit reset --hardRollback ensures that the branch history is clean and traceable. -
Intelligent fault tolerance and retryAgent reports failures and proceeds to the next iteration. Hard errors are backed up exponentially, and permanent errors (such as insufficient API balance) are immediately stopped and the log path is output. The process stops automatically after 3 consecutive failures.
-
Cross-iteration memory sharingAgent via
notes.mdThe document passes on context and experience across multiple iterations, enabling continuous accumulation rather than starting from scratch. -
Worktree ParallelMultiple gnhf tasks can be started simultaneously in the same repository, each with its own independent working directory and branch, without interfering with each other, making it suitable for parallel processing of multiple technical debts.
-
Resume from breakpointIn the existing
gnhf/Rerunning the command on a branch will automatically restore the previous task progress, eliminating the need to start from scratch. -
Real-time status monitoringThe interactive runtime displays the current status, cumulative token consumption, and number of commits in real time in the terminal title bar, making it easy to keep track of progress at any time.
-
Anti-hibernation mechanismAutomatically prevents the system from hibernating during operation, macOS uses
caffeinateLinuxsystemd-inhibitFor Windows, use the native PowerShell solution. -
Native support for multiple agentsIt supports six major AI programming assistants out of the box: Claude Code, Codex, GitHub Copilot CLI, Rovo Dev, OpenCode, and Pi. Custom paths and parameters can be configured.
-
Flexible runtime control:support
--max-iterationsLimit the number of iterations--max-tokensLimit the total amount of tokens.--stop-whenSet the natural language stopping conditions. -
Zero-intrusion integrationAll operations only apply to automatically created operations.
gnhf/The process is performed on the branch, and the main branch remains completely unaffected; the worktree mode does not even pollute the original repository's workspace.
How to use gnhf
-
Installation and Deployment:pass
npm install -g gnhfInstall globally, or clone the source code from the GitHub repository and then execute.npm install && npm run build && npm linkLocal build. -
Basic StartupRun in the root directory of the target repository
gnhf "你的开发目标",For examplegnhf "reduce complexity of the codebase without changing functionality"The tool will create automatically.gnhf/Branch and begin iterating. -
Limiting the size of iterations:use
--max-iterations 10Set the maximum number of iterations.--max-tokens 5000000Set a limit on token consumption to prevent resources from getting out of control. -
Setting Natural Language Stop Conditions:pass
--stop-when "所有测试通过"Allow the Agent to automatically terminate its task when certain conditions are met. -
Resume running from breakpointIn the existing
gnhf/Rerun on branchgnhfThe command allows you to resume previous progress by selecting "Continue Previous Task," eliminating the need to start from the beginning. -
Multi-task parallel:use
gnhf --worktree "任务A" &andgnhf --worktree "任务B" &Multiple agents can be launched simultaneously in the same repository, each with its own independent working directory and branch. -
Custom Agent Configuration:edit
~/.gnhf/config.ymlSet the default agent (e.g.)claude,codex,copilot(etc.), anti-sleep switch, custom binary path and additional CLI parameters. -
View the runtime logAll runtime metadata is stored in
.gnhf/runs/The directory contains the complete inputs and outputs for each iteration, facilitating auditing and troubleshooting. -
Safe AbortDuring operation, according to
Ctrl+CIt can be stopped at any time, or it can automatically end after reaching the configured limit; it will also automatically stop and display the log path after 3 consecutive failures.
gnhf's official website address
- Github repositoryhttps://github.com/kunchenguid/gnhf
Key information and usage requirements of gnhf
-
Project Full Namegnhf, i.e. Good night, have funCreated and open-sourced by developer kunchenguid
-
technology stackTypeScript / Node.js, relying on Git as the version control platform.
-
Platform supportmacOS, Linux, and Windows are the three major operating systems.
-
Community dataWithin about two weeks of its launch, it garnered over 550 GitHub stars and received 73 active PRs from the community.
-
Core ConceptsSet a development goal for the AI before bed, allowing it to iterate continuously while you rest; make only small changes each time, and automatically update it upon success.
git commitIf it failsgit reset --hardrollback -
Natively supported AgentSix mainstream AI programming assistants: Claude Code, Codex, GitHub Copilot CLI, Rovo Dev, OpenCode, and Pi.
-
Branch isolation mechanismAll operations are automatically created.
gnhf/<slug>Executing on a branch does not affect the main branch at all; it supports independent working directories in the worktree. -
Configuration directoryRuntime configuration is located at
~/.gnhf/config.ymlThe runtime logs and metadata are stored in the repository..gnhf/runs/Directory
-
Environmental requirementsThe system needs to have Node.js and npm pre-installed, and the target project must be a Git repository (gnhf relies on Git for commit and rollback operations).
-
Agent PreconditionsYou must first install and configure at least one supported AI programming assistant (such as Claude Code, Codex, etc.) locally, and ensure that its CLI commands are available in the system PATH.
-
API resource preparationWhen using cloud agents (such as Claude Code or Codex), ensure your API account has sufficient funds; otherwise, it will be flagged as a permanent error and immediately terminated.
-
Access RequirementsThe directory to run must be writable by the current user in order to create it.
gnhf/Branches.gnhf/Log directory andnotes.mdMemory Files -
Anti-hibernation dependencymacOS requires system support.
caffeinateCommand, Linux requiressystemd-inhibitWindows relies on PowerShell; the anti-sleep function will be silently disabled if the corresponding tool is not available. -
Configuration initializationEditing is recommended before first use.
~/.gnhf/config.ymlSpecify the default Agent and preference parameters to avoid manually specifying them on the command line each time. -
Operation monitoringIt is recommended to use the terminal title bar or
--max-tokens/--max-iterationsParameter settings limit resource consumption to prevent uncontrolled token consumption overnight. -
LogoutDuring operation, you can press [the button] at any time.
Ctrl+CInterruption, or automatic termination mechanism after 3 consecutive failures; abnormal exit can be detected via log path..gnhf/runs/Investigate the cause
gnhf's core advantages
-
Automatic nighttime iteration frees up developer time.Assign tasks before bed, and AI will continue working while you rest. You can check the results when you wake up, turning "fragmented time" and "sleep time" into effective development productivity.
-
Git discipline is natively built-in.Automatic modification every time it is successfully changed
git commitFailure immediatelygit reset --hardRollback ensures that branch history is clean, auditable, and can be rolled back at any time without manual review. -
Zero-intrusion isolationAll operations are limited to those created automatically.
gnhf/The branch and the main branch are completely unaffected;--worktreeThe model even creates a separate working directory for each task, achieving physical-level isolation. -
Multiple Agents Can Be Switched FreelyIt natively supports six major tools: Claude Code, Codex, GitHub Copilot CLI, Rovo Dev, OpenCode, and Pi. It is not tied to a single vendor and can be seamlessly switched or customized through configuration.
-
Production-level fault tolerance and cost controlAutomatic termination after 3 consecutive failures; immediate exit upon permanent error (such as insufficient API balance).
--max-tokensand--max-iterationsA hard cap is set to prevent resources from spiraling out of control at night. -
Resume execution from where you left off, and don't lose progress.In the existing
gnhf/Re-running on a branch restores the historical task without having to start from scratch, making it suitable for tackling long-term, complex objectives continuously. -
Cross-iteration memory accumulation:pass
notes.mdBy passing on context and lessons learned from failures across multiple iterations, the agent becomes "smarter" with each run, rather than figuring things out from scratch every time. -
Multi-task parallelism in the same warehouse:
--worktreeIt supports the simultaneous advancement of multiple technical debts in the same project (such as one undergoing supplementary testing and another undergoing refactoring) without interference, thereby significantly improving throughput. -
Natural Language Level Operation Control:
--stop-whenIt allows setting stop conditions in plain language (such as "all tests passed"), enabling precise control over task boundaries without the need to write complex scripts. -
Cross-platform, out of the boxSupports macOS, Linux, and Windows, automatically adapting to the anti-sleep mechanisms of each platform.
npm install -g gnhfDeployment can be completed with a single command.
Application scenarios of gnhf
-
Test coverage completeAutomatically supplement unit tests and integration tests for legacy modules or new features, increasing coverage from 60% to 90% during nighttime without taking up daytime coding time.
-
New features will be implemented gradually.Break down large requirements into smaller goals (such as "implementing user authentication middleware"), allow the Agent to iterate gradually at night, commit upon success and automatically roll back upon failure, and accept and merge the results the next day.
-
Multi-module parallel tacklingThis allows multiple worktree tasks to be launched simultaneously within the same project. For example, one agent can perform supplementary testing, another can perform refactoring, and yet another can upgrade dependencies, all proceeding in parallel without interference.
-
Daily maintenance of open source projectsAutomatically handles simple refactoring, documentation completion, and dependency version upgrades marked as "good first issue," allowing maintainers to review PRs directly the next day.
-
API Layer Refactoring and MigrationThe system automatically performs low-risk but time-consuming mechanical modifications at night, such as adjusting interface parameters, replacing obsolete methods, and standardizing response formats, reducing interference with daytime business development.
-
Code style and Lint governanceBatch fix ESLint/Prettier warnings, standardize naming conventions, and remove unused variables to keep the codebase clean in the long term without taking up core development effort.