Harness Intelligence Wiki
HarnessValidation and Tools

Hooks

Installed guardrails that keep the Baseline check and edit formatting close to the work

Hooks keep routine feedback close to edits.

The Baseline installs exactly two hooks. The session hook reports whether the installed Baseline is current. The edit hook formats and lints each file the agent edits. They sit below the skill workflow: a hook keeps repeated checks moving, while requirements clarity, browser behavior, runtime evidence, docs ingest, and review judgment still belong to the relevant skills.

Install And Registration

The hooks Registry Item belongs to pack-core, so every repository gets it, whatever Packs it selects. hi init and hi update copy three files into .agents/hooks/ and record them in .devpunks/installed.json:

  • scaffold-update-check.mjs: the session hook
  • format-edited-file.mjs: the edit hook
  • format-edited-file-core.mjs: helpers of the edit hook. It is never linked, because OpenCode would load it as a plugin.

Each harness reaches the two hooks through symlinks and its own registration:

HarnessLinksRegistration
Claude.claude/hooks/*.mjsJSON merge into .claude/settings.json: SessionStart (60 s) and PostToolUse on Edit|Write|MultiEdit (30 s)
Codex.codex/hooks/*.mjsAuthored .codex/config.toml: SessionStart on startup|resume and PostToolUse on Bash, apply_patch, edit, and write
Cursor.cursor/hooks/*.mjsJSON merge into .cursor/hooks.json: sessionStart and afterFileEdit
OpenCode.opencode/plugins/*.jsPlugin auto-load; no registration file

The JSON merge keeps every repository key. Objects merge deeply, scalars are overwritten, and an array gets only the entries it does not already hold, so a repeated merge changes nothing. .codex/config.toml is Authored: hi writes it once, and later edits stay with the project.

Session Hook

The session hook runs hi check --json (then hint if hi is absent) with a 45-second timeout. It keys only on the status field:

ResultSession message
No installed.jsonHarness Baseline not installed in worktree; run hi update (or hi init).
currentHarness Baseline <installed> current.
update-availableHarness Baseline update available: <installed> -> <latest>. Run hi update.
unavailableHarness Registry unavailable. Installed Baseline: <installed>. Drift was not checked.
No statushi check did not return status. Drift was not checked.

hi check is a version check, not a drift check. It fetches only the root registry.json, compares the installed Baseline with latest, checks the CLI compatibility range, and lists missing required tools. It never reads managed files. The hook never claims that drift is absent, and it only prints a message: the operator or agent decides what to run next. To see per-path drift, run hi diff; to apply the latest Baseline, run hi update. When cliCompatible is false, run hi upgrade first.

Edit Hook

The edit hook runs after each edit. It formats the edited file, then lints it:

  • JavaScript, TypeScript, and JSON files format with the repository-local Oxfmt from node_modules. JavaScript and TypeScript files then lint through the managed lint route of their owning Software Scope.
  • Python .py files format and lint with uv run --project <python-project> ruff. The nearest pyproject.toml decides the project.
  • The hook resolves tools from repository-local node_modules or uv. It does not infer a package manager.

Before it formats, the hook reads .devpunks/installed.json and skips every Copied or Built path, so it never rewrites a managed file. When the record is missing, unreadable, or invalid, the hook treats nothing as managed: formatting continues for every eligible file. In every case the hook keeps formatting and never blocks an edit.

Formatted output goes to a private stage in the same directory and replaces the file atomically. Lint findings go back to the agent as feedback after the edit has landed. After three unchanged repair attempts, the hook stops asking for another repair.

The edit hook does not rebuild harness agent files. Only hi update does that.

Managed Lint

Managed lint is the managed-lint Registry Item in pack-core, plus the lint-* assets that selected Packs carry:

  • Copied runners: .agents/scripts/managed-lint.mjs and .agents/scripts/managed-lint-runner.mjs
  • Built runner input: .devpunks/specs/lint/selection.json and its README.md
  • Built <scope>/oxlint.config.ts, one per Software Scope in the settings lint.scopes
  • Authored <scope>/oxlint.local.ts for the project's own rules, applied last
  • A JSON merge of scripts.lint into each scope's package.json, plus a root dispatcher

Lint assets, such as typescript-anti-slop, react-core, react-frontend-layers, or effect-no-barrel-imports, are Copied JSON files under .devpunks/specs/lint/assets/. The wiki root is always excluded; lint.exclude adds more globs. hi update runs managed lint after the install, and findings never change its exit code. The installer seeds the Oxlint, Oxfmt, and Ultracite versions once; after that the versions are project-owned and hi update never rewrites them.

An asset can also carry a local JS plugin. Its source files are Copied to <scope>/tools/oxlint/<plugin>/ in each Software Scope where the asset applies. When a language Pack selects the asset, the files go only to scopes of that language. When a detected Pack selects it, the files go only to scopes where that Pack applies: for react-frontend-layers in the react Pack, a scope whose own manifest declares react or react-dom. A formatter would rewrite these copies and hi update would then see local edits, so hi update adds **/tools/oxlint/** to the ignorePatterns of an existing .oxfmtrc.json, in place, and formats it with the repository's own oxfmt. Without a usable .oxfmtrc.json it writes nothing and reports the pattern as merge-reported.

react-frontend-layers loads the frontend-layers plugin. The plugin checks the entities layer model of frontend-domain-structure, and each violation is an error. To turn one rule off, set frontend-layers/<rule> to off in oxlint.local.ts. In a Software Scope other than the repository root, the plugin alias carries the scope path, so the key is frontend-layers-<scope>/<rule> (apps/web gives frontend-layers-apps-web). The rules and the layer model are in the frontend-domain-structure skill, references/structure.md; the alias mapping is in the hi-cli skill, references/managed-lint.md.

next-leafmost-suspense loads the punks-next plugin from the published @punks/lints/next package, so it copies no source files; it adds the @punks/lints devDependency to each scope where the nextjs Pack applies. Its one rule, punks-next/leafmost-suspense, runs only when next.config sets cacheComponents: true. A project component that renders <Suspense> around its children counts as a boundary when oxlint.local.ts names it in the rule's boundaryComponents option. The rule finds route segments by path, under app/. When a route file only re-exports its layout or page from another module, as frontend-layers/route-imports requires (export { PortalLayout as default } from "@/composition/routing";), list those modules in the rule's routeModules option in oxlint.local.ts, each as { files: <path glob>, kind: "layout" | "page" | "template" }; the generated config sets no routeModules, because the layer model does not fix the Shell and Page Template file names. For the layer model, that is usually { files: "src/composition/routing/shells/*/layout.tsx", kind: "layout" } and { files: "src/composition/routing/pages/*/*.tsx", kind: "page" }, plus any page wrapper module. Every component a listed module exports is a segment, so a glob that also matches leaf modules beside the page (pages/kpi/kpi-grid.tsx) reports their awaits as outer awaits; add exports: [<export names>] to the entry to name only the segment components and page wrappers. A boundary is page-level when it holds the whole segment: around {children}, around a component that renders {children}, or as a page's whole output around one component with children. routeModules needs @punks/lints 0.3.0 or later; an older version refuses the option and Oxlint stops.

effect-edge loads the punks-effect plugin from the published @punks/lints/effect package and adds the @punks/lints devDependency to each scope where the effect Pack applies. Its five rules keep Effect code running Effect code with yield*: run-only-at-edges, no-promise-round-trip, no-empty-context-run, no-unowned-fork and suppression-reason. An Effect edge is a site marked // Effect edge: <reason>, a main.* entry, an if (import.meta.main) block or a test; list the modules that run Effects (an Edge bridge, a public SDK facade run module) in run-only-at-edges allowedModules in oxlint.local.ts. A repository that is not ready lists effect-edge in lint.disabledAssets.

ci-solution loads the ci-solution plugin from the published @collective-intelligence/lint package and enables one rule, ci-solution/package-entrypoint: an import into another package must target an entrypoint that its package.json exports declares. The ci-solutions Pack has no detection technology, so the asset applies to every Software Scope of the repository and adds the @collective-intelligence/lint devDependency to each one, at the version that apps/cli/src/data/catalog/package-skills.ts pins. The asset enables no other rule: each solution package and each app extends recommended from @collective-intelligence/lint in its oxlint.local.ts, which adds the solution-layout rule workspace-layout (every workspace sits at apps/<name>, packages/features/<domain>/<part>, packages/products/<product>/<domain>/<part>, packages/ui/<name>, packages/modules/<name> or packages/tooling/<name>) and the Effect rules (effect-subpath, no-run-in-view, effect-actors, effect-writes). The pinned version is 0.9.3; the ci-solution-structure skill is copied from the same tarball, so it describes the layout that workspace-layout enforces. Declaring the plugin again there is safe: Oxlint reports each finding once.

To change lint rules, edit <scope>/oxlint.local.ts. Never edit oxlint.config.ts: it is Built, and hi diff reports a hand edit as local-edit.

Drift And Updates

hi diff and hi update compare managed bytes; they never run repository formatters. A manual repository-wide format can therefore create legitimate local-edit rows. hi diff previews and writes nothing. hi update applies the latest Baseline; it keeps a locally edited Copied file unless you pass --yes.

Alignment Rule

When an agent adopts or replaces lint and format tooling, it must update the whole workflow together: package scripts, Turborepo task definitions, CI, editor and wiki references, managed lint scopes, and hooks. Partial adoption creates contradictory gates.

Done Signal

Hook-related work is complete when hi diff shows no local-edit, conflict, missing, or link-failed row for the hook files, the harness registrations exist, and any lint or format tool migration has no stale entrypoints left behind.

On this page