> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo Developer Workflow Standards Codeowners

> Guide to adding and configuring a CODEOWNERS file to automatically request reviewers, explain patterns, ownership requirements, common errors, and fixes for GitHub repositories

In this lesson we'll add a CODEOWNERS file to automatically require reviewers for changes to specific files. This is useful when you want pull requests to request review from the responsible teams or individuals—without manually adding reviewers each time.

Context

* Repository: my GHAS schedules demo repo (public).
* Current behavior: when I push a branch and open a pull request, GitHub shows no requested reviewers because there are no repo-level rules or CODEOWNERS configured.

Create and push a branch locally:

```bash theme={null}
git checkout -b edit-1
git push -u origin edit-1
```

When opening a pull request, the default PR template in this repo looks like:

```markdown theme={null}
## Description
<!-- Summary of changes, problem solved, and motivation -->
Fixes # (issue number)

## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Chore / Refactoring
- [ ] Documentation update

## How Has This Been Tested?
<!-- Describe tests, environment, or steps to reproduce -->

## Checklist
- [ ] My code follows project style guidelines.
```

Because no CODEOWNERS are configured, the PR does not auto-request reviewers. To require reviewers automatically when certain files change, add a CODEOWNERS file. Best practice is to place it under the `.github/` directory:

* Path: `.github/CODEOWNERS`

CODEOWNERS basics

* Each line maps a file pattern to one or more owners (users or teams).
* Owner formats:
  * Individual user: `@username`
  * Organization team: `@org/team-name`
* Patterns follow GitHub filename globbing (similar to `.gitignore`).

Example: assign ownership of all JavaScript files to an organization team

```text theme={null}
*.js @game-devstudio/pc-devs
```

Key requirements for owner entries to be valid

* The referenced user or team must exist.
* Organization teams must be visible (not secret).
* The team must have at least Write access to the repository.

If any requirement is missing, GitHub will mark the owner as unknown and the CODEOWNERS file will be invalid.

Common CODEOWNERS patterns and examples

| Pattern | Meaning | Example owner format |
| - | - | - |
| `*.js` | All JavaScript files | `*.js @org/team` |
| `docs/**` | Anything under `docs/` directory | `docs/** @org/docs-team` |
| `/README.md` | Specific file at repo root | `/README.md @doc-writers` |
| `src/*.py` | Python files directly under `src/` | `src/*.py @org/python-devs` |
| `*.{js,ts}` | Multiple extensions (glob) | `*.{js,ts} @org/frontend` |

Error example
If the referenced team is not visible or lacks write permission, you may see an error like:

```text theme={null}
CODEOWNERS errors

Unknown owner on line 1: make sure the team @game-devstudio/pc-devs exists, is publicly visible, and has write access to the repository

*.js @game-devstudio/pc-devs
```

How to fix the error

1. Confirm the team exists in the organization.
2. Ensure the team visibility is public (not a secret team).
3. Grant the team at least Write access to the repository:
   * Repository Settings → Collaborators & teams, or
   * Organization → Teams → select team → Repositories → Add repository with Write access.

![A dark-themed GitHub screenshot of an organization's "PC-Devs" team Repositories page showing a single listed repo "game-devstudio/app-backend" (Private) with an "Add repository" button. A banner about a 30-day Enterprise trial and the repo role set to "Write" are also visible.](https://mintcdn.com/kodekloud-c4ac6d9a/Ae2SeWV4btujbkSt/images/GitHub-Administration-Certification/Governance-and-Roles/Demo-Developer-Workflow-Standards-Codeowners/github-pc-devs-game-devstudio-backend.jpg?fit=max\&auto=format\&n=Ae2SeWV4btujbkSt\&q=85\&s=9eb31ae448044bf47e7e622181f4285d)

Once the team is visible and has the required access, the CODEOWNERS entry will be valid:

```text theme={null}
*.js @game-devstudio/pc-devs
```

Make sure teams referenced in CODEOWNERS are organization teams (use the `@org/team` format), are publicly visible, and have at least Write access to the target repository. Otherwise GitHub will flag the owner as unknown and the CODEOWNERS file will be invalid.

After adding a valid CODEOWNERS file, GitHub will automatically request review from the specified owners when a pull request modifies files matching the patterns. This ensures code changes are reviewed by the right people and helps enforce your team’s review standards.

Further reading

* [GitHub CODEOWNERS documentation](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners)
* [Managing teams in GitHub Organizations](https://docs.github.com/en/organizations/organizing-members-into-teams)

> [card] [Watch Video](https://learn.kodekloud.com/user/courses/github-administration-certification/module/e4b7bd78-3fb5-4c1c-94d8-e528b0b60484/lesson/c30da2b8-d33d-4a03-b23a-0a457627b459)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.