Installation
Install repopo with your package manager.
As a development tool
Section titled “As a development tool”To run repopo in a repository, from scripts, Git hooks, or CI, install it as a dev dependency:
npm i -D repopopnpm add -D repopoyarn add -D repopoWith repopo installed, choose one repository convention to check. The walkthrough below uses a required license field.
Your first check
Section titled “Your first check”Run these steps from the root of a Git repository that has a package.json. The commands use pnpm; if you installed with npm, use npx repopo instead of pnpm exec repopo.
Configure one rule
Section titled “Configure one rule”Suppose each package.json must declare an MIT license. Create repopo.config.ts at the repository root:
import { makePolicy, type RepopoConfig } from "repopo/api";import { PackageJsonProperties } from "repopo/policies";
export default { policies: [ makePolicy(PackageJsonProperties, { config: { verbatim: { license: "MIT" } }, }), ],} satisfies RepopoConfig;If you already have a configuration, add this policy to its policies array instead of replacing the file.
This configuration enables only PackageJsonProperties. It checks each package.json in the Git file inventory, including tracked files and untracked files that Git does not ignore.
Find a violation
Section titled “Find a violation”pnpm exec repopo checkIf a package.json has no license field, or its value differs from "MIT", repopo reports Incorrect package.json field value for 'license'. The command exits with a non-zero status. If each matching file has the expected value, the check passes.
Fix it and check again
Section titled “Fix it and check again”Review the violations before you apply fixes. This rule sets the license field to "MIT" in each matching file; use a value that reflects your project’s license.
pnpm exec repopo check --fixpnpm exec repopo checkThe fix adds or updates the license field and preserves the other package fields. Repopo reports the fixed findings. The second check passes with no violations if the files meet the rule.
Keep the rule in CI
Section titled “Keep the rule in CI”After you install development dependencies in CI, run the same read-only command:
pnpm exec repopo checkA violation produces a non-zero exit status, so the CI job can fail the check without changing files. To add more rules or skip selected files, continue with Configuration. See CLI usage for checks on selected files and other commands.
As a library
Section titled “As a library”To run policies from your own program with the programmatic API, or to publish policies for other repositories, install it as a regular dependency:
npm i repopopnpm add repopoyarn add repopoGlobally
Section titled “Globally”You can also install repopo globally to use the repopo command in any repository:
npm install --global repopo# orpnpm add --global repopoEach repository still needs its own repopo.config.ts, and that file must be able to import repopo.
The native engine
Section titled “The native engine”The repopo check-native command uses a Rust binary, repopo-core. When you install repopo, a postinstall script downloads a prebuilt binary for Linux (x64, arm64), macOS (x64, arm64), or Windows (x64). If the download fails, installation still succeeds. Only check-native needs the binary; repopo check doesn’t.
- Set
REPOPO_SKIP_POSTINSTALL=1to skip the download. - Point to your own build with
--binary-pathor theREPOPO_CORE_PATHenvironment variable.