Hygen is a code generator CLI and interactive template engine that scaffolds new files and injects code into existing ones using project-local templates. It operates as a Node.js code generator library that can be embedded inside custom binaries for tailored workflows, and also functions as a project scaffolding tool for bootstrapping new projects or folders from remote template repositories.
The tool discovers templates by scanning a project's _templates directory at runtime, mapping folder and file names directly to generator commands and actions. It collects user input through interactive prompts before rendering, then passes answers as template variables using EJS templating. Each generator runs as a sequence of discrete file operations—add, inject, append—with independent template rendering, and a duplicate-injection guard prevents repeated code insertion by tracking injection markers within target files.
Hygen supports injecting template content into existing files at specified locations while preventing duplicate injections, and can clone a Git repository into a temporary directory to copy its template structure into the local _templates folder. The core generation logic is exposed as a library that can be required and invoked programmatically from custom scripts.