Getting Started with Code Owners
Learn how to set up Code Owners for your codebase.Code Owners are available on Enterprise plans
To set up Code Owners in your repository, you'll need to do the following:
- Set up Vercel's private npm registry to install the necessary packages
- Install and initialize Code Owners in your repository
- Add your repository to your Vercel dashboard
If you've already set up Conformance, you may have already completed some of these steps.
To enable Code Owners for your Enterprise team, you'll need to request access through your Vercel account administrator.
Note: Code Owners is available for Enterprise teams. To add it to your contract or upgrade to Enterprise, contact us
Vercel distributes packages with the @vercel-private
scope through our private npm registry, and requires that each user using the package authenticates through a Vercel account.
To use the private npm registry, you'll need to follow the documentation to:
- Set up your local environment – This should be completed by the team owner, but each member of your team will need to log in
- Set up Vercel – This should be completed by the team owner
- Set up Code Owners for use with CI – This should be completed by the team owner
A GitHub App enables Code Owners functionality by adding reviewers and enforcing review checks for merging PRs.
The Code Owners CLI is separate to the Vercel CLI, however it uses the Vercel CLI for authentication.
Before continuing, please ensure that the Vercel CLI is installed and that you are logged in.
If you have an existing
CODEOWNERS
file in your repository, you can use the CLI to automatically migrate your repository to use Vercel Code Owners. Otherwise, you can skip this step.Start by running this command in your repository's root:
pnpm --package=@vercel-private/code-owners dlx vercel-code-owners init
yarn dlx
only works with Yarn version 2 or newer, for Yarn v1 use the npx command.After running, check the installation success by executing:
pnpm vercel-code-owners
To install, you must be an organization owner or have the GitHub App Manager permissions.
- Go to https://github.com/apps/vercel/installations/new
- Choose your organization for the app installation.
- Select repositories for the app installation.
- Click
Install
to complete the app installation in the chosen repositories.
After installation, define Code Owners files in your repository. Pull requests with changes in specified directories will automatically have reviewers added.
Start by adding a
.vercel.approvers
file in a directory in your repository. List GitHub usernames or team names in the file, each on a new line:.vercel.approvers@username1 @org/team1
Then, run the
validate
command to check the syntax and merge your changes into your repository:pnpm vercel-code-owners validate
With the
.vercel.approvers
file merged into the main branch, test the flow by modifying any file within the same or child directory. Create a pull request as usual, and the system will automatically add one of the listed users as a reviewer.This step is optional
By default, GitHub checks are optional and won't block merging. To make the Code Owners check mandatory, go to
Settings > Branches > [Edit] > Require status checks to pass before merging
in your repository settings.
Was this helpful?