Hof & CUE Modules

Every hof generator is also a CUE module, and in fact, many of hof’s other features can be used from the module system.

hof mod” is the subcommand based on Go modules for working with CUE modules and managing dependencies. The logic and format is the same, with much code shared between the implementations. Currently, while CUE is module aware and supports imports, it does not yet have dependency management, but it will work the same as well. This page has a brief overview. The commands will be repeated when you need to run them on other pages.

hof mod subcommands:

  • hof mod init cue initializes a new module
  • hof mod vendor cue fetches dependencies into cue.mod/pkg/...

The name of a module must be the same the git repository. hof talks directly to git repositiories and many of hof’s commands will accept repositories as input too.

The files and directories that make up a module:

  • cue.mods is where dependencies and versions are set, you write this file.
  • cue.sums contains the checksums for all dependencies and is managed by hof mod
  • cue.mod/module.cue denotes a CUE module and has a sinlge line
  • cue.mod/pkg/... is where the code for dependencies is located after fetching


// indicates a CUE module, only one line
module: ""


// indicates a Hof module, dependencies go here

cue v0.4.3

require ( v0.6.7

Replace for local development

You can use hof mod for generally managing CUE or Hof modules and dependencies. In addition to setting, fetching, and validating dependencies, you can use hof mod to setup local development when working with multiple CUE or Hof modules.

In your cue.mods file, use the replace directive just like you would in Go.

cue.mods with replace


cue v0.4.3

require ( v0.1.2

// local replace with relative path
replace => ../repo

> terminal

$ hof mod vendor cue

This will symlink any local replaces to point from the CUE vendor directory to the replacement directory. You can then develop CUE or hof code without having to copy or vendor upstream dependencies.

2023 Hofstadter, Inc