Codegen is helpful, but there some requirements to make it nice to use:

  1. Generated File Headers

    Generated files should have a header with the command to run to regenerate the file:

    // To regenerate this file, run:
    //   hphp/hack/src/
  2. CI Check

    CI should have a check to ensure the files are up to date.

    The command to generate the file should have an option to pass a flag (--check) to check if the file is up to date.

  3. Readonly in VSCode

    Generated files should be marked readonly in the repo’s VSCode config:

      "files.readonlyInclude": {
        "frontend/src/api/*": true
  4. Generated in GitHub

    Generated files should be marked as generated in the .gitattributes so GitHub collapses them by default in PRs:

    frontend/src/api/* linguist-generated=true