gnhf AGENTS.md

A guide for gnhf, a command-line tool that repeatedly runs a coding agent inside a Git repository.

In plain words
What is it for?
Use it when changing gnhf, running its tests, working on releases, or deciding whether a proposed feature fits the project’s stated scope.
Why use it?
It explains the project’s workflow, including commits, branches, publishing, failure recovery, supported agents, and required development commands.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/kunchenguid/gnhf/agents-md
Clone the repo
git clone --depth 1 https://github.com/kunchenguid/gnhf

Made for: Codex, OpenCode.

Per session 3,302 This file is loaded in full into every session.
When invoked 3,302 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.03302 $0.03302
Opus 5 $0.01651 $0.01651
Sonnet 5 $0.00660 $0.00660
Haiku 4.5 $0.00330 $0.00330

Measured today against content hash 14a46765d262, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

gnhf AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 76 lines

How it starts

The opening of the file, as written. The whole thing — 76 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AGENTS.md

This file provides guidance to agents when working with code in this repository.

Project

gnhf ("good night, have fun") is a CLI that runs a coding agent in a loop inside a git repo. The supported-agent roster is owned by the README's Agents table. Each successful iteration is a separate commit, normally on a dedicated gnhf/<slug> branch; --current-branch uses the existing branch instead, and --push publishes each successful iteration. Failure and rollback semantics are owned by the README's How It Works section. The acceptance policy for what gnhf should and should not become is owned by VISION.md; test feature or scope decisions against its aligns/resist criteria. Target: Node 20+, published to npm as a bundled ESM CLI with optional agent-facing skills under skills/.

Commands

package.json scripts are the source of truth for build/test/lint commands; the "Developing" section in CONTRIBUTING.md documents them plus single-test invocation, the e2e prior-build requirement, and the CI matrix - keep all CI jobs green. pnpm test builds and then runs all tests. Releases are automated via release-please; never hand-edit CHANGELOG.md or .release-please-manifest.json.

Architecture

Entry point is src/cli.ts. It parses flags with commander, resolves config, handles stdin/worktree/resume setup, then hands off to the orchestrator. Everything else is plain modules under src/.

Run lifecycle (the critical flow)

  1. cli.ts decides one of four modes: new branch, resume an existing gnhf/<slug> branch, --current-branch, or --worktree (creates a sibling <repo>-gnhf-worktrees/<slug>/ checkout). New branch and worktree runs probe numeric suffixes such as gnhf/<slug>-1 and <repo>-gnhf-worktrees/<slug>-1/ on collisions; current-branch runs first resume an exact same-prompt .gnhf/runs/<runId>/ on a clean working tree, otherwise they probe .gnhf/runs/<runId>-1/ metadata collisions without creating a branch; worktree mode also resumes preserved suffixed worktrees before creating a new one. When resuming with a different prompt, it asks whether to update prompt.md and continue the existing run history, start a new branch, or quit; if stdin is piped, that confirmation comes from the controlling terminal before any sleep-prevention re-exec. setupRun/resumeRun in src/core/run.ts create .gnhf/runs/<runId>/ with prompt.md, notes.md, output-schema.json, base-commit, optional stop-when, commit-message, and gnhf.log, and add .gnhf/runs/ to .git/info/exclude so run metadata stays local.
  2. Orchestrator (src/core/orchestrator.ts) is an EventEmitter loop. Each iteration: build prompt via src/templates/iteration-prompt.ts (injects current notes.md), add commit-repair instructions when a prior git commit failed, call agent.run(...), then on success commitAll + append to notes.md and optionally pushCurrentBranch; on failure resetHard unless a pending commit failure is preserving uncommitted work for repair. The user-visible failure/rollback contract lives in the README's "How It Works"; in code, commitAll throws CommitFailedError, logs git:commit:failed, and records the commit output in notes.md so the next iteration can repair the workspace, retryable thrown agent errors increment the backoff streak, RateLimitAgentError rolls back and waits until the provider-reported reset time (bounded escalating fallback when absent) before retrying the same iteration number without counting a failure, an iteration the provider billed to extra usage instead of rejecting (Claude's isUsingOverage, reported out-of-band via onOverage so a terminal path that throws still carries it) keeps its committed work and waits after the post-iteration checks but before any error backoff, failing closed when the reported reset time is unusable - providerResumeWait is the single owner of what a reported reset time is worth, and both waits share waitForUsageWindowReset and the --max-rate-limit-wait budget - and PermanentAgentError aborts after rollback with lastAgentError set for the renderer. The RunLimits object enforces --max-iterations (between iterations), --max-tokens (mid-iteration via AbortController), --max-rate-limit-wait (total usage-limit wait before aborting), --stop-when (post-iteration via the agent's should_fully_stop output, deferred while a commit failure awaits repair), and --push post-success publishing.
  3. Renderer (src/renderer.ts + src/renderer-diff.ts) is a cell-based TUI using the alt screen buffer. cli.ts enters/exits alt screen around it. The renderer subscribes to orchestrator events, diffs frames to minimize writes, and updates the terminal title live. MockOrchestrator (src/mock-orchestrator.ts) drives the renderer offline via --mock for demos/testing.
  4. Shutdown path: SIGINT routes through orchestrator.handleInterrupt(). The first press requests a graceful stop, letting the current iteration finish or ending backoff early; the second press force-stops via orchestrator.stop(). SIGTERM force-stops immediately. cli.ts only keeps the done screen open for aborted runs; graceful stops exit once shutdown cleanup finishes. The README's How It Works section owns worktree preservation and cleanup behavior. That rule must hold on every exit path, not just the normal cleanup block: the process.on("exit") cleanup fallback re-checks orchestrator state before removing a worktree, and the force-exit timeout prints the preserved path before calling process.exit(). After cleanup, cli.ts collects final branch/diff stats via src/core/git.ts and writes the permanent stdout summary rendered by src/core/exit-summary.ts, including an uncommitted-work warning when a commit failure is still pending.

Read the full file on GitHub · 76 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today Changed · +111 tokens per session 14a46765d262
  2. 3d ago First seen · 76 lines · 3,191 tokens per session scan A 188cd068aa3e

Subscribe to this mod's changes

gnhf AGENTS.md is an instructions file published in the GitHub repository kunchenguid/gnhf (3,880 stars, last pushed yesterday), licensed MIT. It adds 3,302 tokens to every session, about $0.0165 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other instructions, from other repositories

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 6,785 tokens

spec-kit AGENTS.md

AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.

github/spec-kit · 7,104 tokens

codex AGENTS.md

AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.

openai/codex · 5,182 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,345 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).

microsoft/vscode · 5,001 tokens

next.js AGENTS.md

Instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,296 tokens