Skip to content

Gleam policies

These policies check gleam.toml manifests and the layout of Gleam projects. Unless noted, a policy checks every gleam.toml in the repository. Policies marked root only check only the gleam.toml at the repository root.

repopo.config.ts
import { makePolicy, type RepopoConfig } from "repopo";
import { GleamTomlRequired, GleamTomlSorted } from "repopo/policies";
export default {
policies: [
makePolicy(GleamTomlRequired, { config: { requireGleamVersion: true } }),
makePolicy(GleamTomlSorted),
],
} satisfies RepopoConfig;

Checks that top-level fields exist in gleam.toml.

OptionTypeDefaultDescription
requiredstring[]["name", "version"]Fields that must exist.
requireGleamVersionbooleanfalseRequire the gleam compiler version constraint.
requireRepositorybooleanfalseRequire a [repository] section.

Auto-fixable: No.

Checks that the gleam compiler version constraint is set.

OptionTypeDescription
minimumVersionstringThe constraint must allow at least this version, such as "1.0.0".

Auto-fixable: No.

Checks that licences is set in gleam.toml.

OptionTypeDefaultDescription
allowedLicencesstring[]Only these SPDX identifiers are accepted.
validateSpdxbooleanfalseValidate against SPDX with spdx-correct.

SPDX validation needs the optional peer dependency spdx-correct.

Auto-fixable: Yes, when validateSpdx is enabled. --fix replaces correctable identifiers with the canonical ones.

Checks the package name against naming rules.

OptionTypeDefaultDescription
denyPrefixesstring[]["gleam_"]Prefixes that names can’t use.
requireSnakeCasebooleantrueRequire snake_case names.

Auto-fixable: No.

Checks that internal_modules is set, so implementation modules are hidden from generated documentation.

OptionTypeDefaultDescription
suggestPatternsbooleantrueSuggest common patterns in the error message.

Auto-fixable: No.

Checks that keys in gleam.toml dependency sections are in alphabetical order.

OptionTypeDefaultDescription
sectionsstring[]["dependencies", "dev-dependencies"]Sections to check.

Auto-fixable: Yes. --fix sorts the sections and keeps comments.

Checks dependency version constraints in dependencies and dev-dependencies.

OptionTypeDefaultDescription
requireVersionsbooleantrueEvery dependency needs a version constraint.
warnUnboundedbooleanfalseWarn about ranges with no upper bound, such as ">= 1.0.0".

Auto-fixable: No.

Checks that each path dependency points to a directory that contains a gleam.toml.

Auto-fixable: No.

Reports path dependencies in packages intended for publishing. Hex can’t resolve them.

OptionTypeDefaultDescription
onlyPublishablebooleanfalseSkip packages without a description. Gleam has no private field, so a missing description serves as the signal.

Auto-fixable: No.

Root only. Checks that metadata matches across the Gleam packages in a monorepo.

OptionTypeDefaultDescription
packagesstring[]Required. Repo-relative paths of the gleam.toml files to compare. With fewer than two paths, the policy checks nothing.
syncFieldsstring[]["licences"]Top-level fields that must match.
syncGleamVersionbooleantrueThe gleam version constraint must match.

Configuration: Required. This policy has no default configuration.

Auto-fixable: No.

Root only. Reports dependencies with different versions in different Gleam packages.

OptionTypeDefaultDescription
packagesstring[]Required. Repo-relative paths of the gleam.toml files to compare. With fewer than two paths, the policy checks nothing.
detectMismatchesbooleantrueReport version mismatches.
includeDevbooleanfalseAlso compare dev-dependencies.

Configuration: Required. This policy has no default configuration.

Auto-fixable: No.

Checks that each Gleam project has the standard directories.

OptionTypeDefaultDescription
requireSrcDirbooleantrueRequire src/.
requireTestDirbooleanfalseRequire test/.

Auto-fixable: No.

Checks that manifest.toml is committed next to each gleam.toml so builds are reproducible. Run gleam build to create it.

Auto-fixable: No.

Checks that documentation files exist next to each gleam.toml.

OptionTypeDefaultDescription
requiredstring[]["README.md"]Files that must exist.
recommendedstring[]Files that produce a warning when missing.

Auto-fixable: No.

Reports committed files inside a build/ directory, Gleam’s build output.

Auto-fixable: No. Remove the files from Git and add build/ to .gitignore.