<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aleix Riba</title>
    <description>The latest articles on DEV Community by Aleix Riba (@aleixriba).</description>
    <link>https://dev.to/aleixriba</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3656693%2Fe6065219-d429-4075-ad85-7c093cf37271.png</url>
      <title>DEV Community: Aleix Riba</title>
      <link>https://dev.to/aleixriba</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aleixriba"/>
    <language>en</language>
    <item>
      <title>The definitive guide to CODEOWNERS... and why it's not enough for high-performance teams</title>
      <dc:creator>Aleix Riba</dc:creator>
      <pubDate>Thu, 11 Dec 2025 15:28:43 +0000</pubDate>
      <link>https://dev.to/aleixriba/codeowners-4jn3</link>
      <guid>https://dev.to/aleixriba/codeowners-4jn3</guid>
      <description>&lt;p&gt;Modern software development is based on collaboration. As projects grow, the need to maintain code quality, architectural consistency, and clarity in module ownership becomes critical. This is where GitHub's &lt;code&gt;CODEOWNERS&lt;/code&gt; file comes into play.&lt;/p&gt;

&lt;p&gt;This simple but powerful file is the backbone of a more efficient and accountable code review process. In this article, we'll explore what &lt;code&gt;CODEOWNERS&lt;/code&gt; is, how it works, best practices, and why, despite its usefulness, high-performing teams need to evolve beyond its limitations.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the CODEOWNERS file?
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;CODEOWNERS&lt;/code&gt; file is a special file in GitHub repositories that &lt;strong&gt;automatically&lt;/strong&gt; defines the individuals or teams responsible for specific directories, files, or patterns within a repository.&lt;/p&gt;

&lt;p&gt;When a Pull Request modifies code covered by a &lt;code&gt;CODEOWNERS&lt;/code&gt; rule, the specified owners are automatically added as required reviewers for that Pull Request.&lt;/p&gt;

&lt;h3&gt;
  
  
  Location
&lt;/h3&gt;

&lt;p&gt;This file must reside in one of the following locations for GitHub to recognize it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;.github/CODEOWNERS&lt;/code&gt; (the recommended location)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CODEOWNERS&lt;/code&gt; (at the root of the repository)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docs/CODEOWNERS&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Note:&lt;/strong&gt; The location in &lt;code&gt;.github/CODEOWNERS&lt;/code&gt; is preferred as it keeps the repository configuration files centralized.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Syntax and operation
&lt;/h3&gt;

&lt;p&gt;The syntax of the &lt;code&gt;CODEOWNERS&lt;/code&gt; file is very similar to that of a &lt;code&gt;.gitignore&lt;/code&gt; file, using path matching patterns and assigning one or more owners to each pattern.&lt;/p&gt;

&lt;h4&gt;
  
  
  Basic structure
&lt;/h4&gt;

&lt;p&gt;Each line of code contains a route pattern followed by one or more owners separated by spaces.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight codeowners"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Example CODEOWNERS file&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# 1. Default owners for everything&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;@octocat&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;@github/support&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#2. Files in the root directory with the .md extension&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;*.md&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nf"&gt;@docs-team&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# 3. Directory ‘src/frontend/’ and everything it contains&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;src/frontend/&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nf"&gt;@frontend-lead&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#4. Overwriting the property for a specific subdirectory&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;src/backend/users/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;@user-management-team&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Precedence rules
&lt;/h4&gt;

&lt;p&gt;The file is processed from top to bottom, and &lt;strong&gt;the last matching pattern&lt;/strong&gt; for a specific path is the one that applies. More specific rules (usually those at the end of the file or those using full paths) override more general rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integration with protected branches
&lt;/h2&gt;

&lt;p&gt;The true power of &lt;code&gt;CODEOWNERS&lt;/code&gt; is unlocked when integrated with GitHub's &lt;strong&gt;Branch Protection Rules&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When setting up a branch (such as &lt;code&gt;main&lt;/code&gt;) to be protected, you can enable the &lt;strong&gt;“Require review from Code Owners”&lt;/strong&gt; option.&lt;/p&gt;

&lt;p&gt;This ensures that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Owners are automatically added.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Pull Request &lt;strong&gt;cannot be merged&lt;/strong&gt; until at least one member of each owner team has approved the changes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Best practices
&lt;/h2&gt;

&lt;p&gt;To ensure that &lt;code&gt;CODEOWNERS&lt;/code&gt; is a tool for improvement rather than a bottleneck, it is vital to follow these guidelines:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use teams, not individuals:&lt;/strong&gt; assigning ownership to teams (&lt;code&gt;@org/team-name&lt;/code&gt;) ensures that review does not stop if an individual is absent and promotes distributed knowledge.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Define a fallback rule:&lt;/strong&gt; include a broad rule (&lt;code&gt;* @core-team&lt;/code&gt;) to ensure that no changes go unreviewed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keep the file up to date:&lt;/strong&gt; the &lt;code&gt;CODEOWNERS&lt;/code&gt; file should evolve along with your team and code structure.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Limitations of CODEOWNERS: path-based rigidity
&lt;/h2&gt;

&lt;p&gt;GitHub's native &lt;code&gt;CODEOWNERS&lt;/code&gt; system is fundamentally limited in scope. It is designed solely to answer the question: &lt;strong&gt;“Which file was modified?”&lt;/strong&gt; This imposes a critical limitation: &lt;strong&gt;the complete absence of advanced conditional or contextual logic.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CODEOWNERS&lt;/code&gt; &lt;strong&gt;only works with file path&lt;/strong&gt; criteria, which creates three insurmountable challenges for professional teams:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Lack of merge context
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;CODEOWNERS&lt;/code&gt; is blind to the destination of the change. You cannot require a more rigorous review if the pull request goes to the production branch (&lt;code&gt;main&lt;/code&gt;) than if it goes to the development branch (&lt;code&gt;develop&lt;/code&gt;).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The problem:&lt;/strong&gt; you cannot assign reviewers based on the destination branch, which prevents you from implementing differentiated quality policies depending on the environment.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Impossibility of cross-requirements (AND/OR conditions)
&lt;/h3&gt;

&lt;p&gt;The native system cannot combine criteria to make a complex decision. A rule only applies if a path is met. This prevents sophisticated rules such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AND logic (all must be met):&lt;/strong&gt; it is impossible to say: "Assign to team A &lt;strong&gt;ONLY IF&lt;/strong&gt; the Pull Request touches path X &lt;strong&gt;AND&lt;/strong&gt; also carries the Y label.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;“OR logic (any is sufficient):&lt;/strong&gt; you cannot say: ”Assign to the expert if the author is new &lt;strong&gt;OR&lt;/strong&gt; if a critical file Z is modified."&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;CODEOWNERS&lt;/code&gt; operates in path silos, without the ability to use Boolean logic (&lt;code&gt;all&lt;/code&gt; or &lt;code&gt;any&lt;/code&gt;) on multiple Pull Request attributes.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3. Blind assignment criteria&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Beyond the path, &lt;code&gt;CODEOWNERS&lt;/code&gt; cannot inspect any other properties of the pull request to determine reviewers. This prevents the use of valuable criteria such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pull request size:&lt;/strong&gt; You cannot force additional reviewers if the pull request has, for example, more than 500 lines.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code authorship:&lt;/strong&gt; You cannot apply special rules if the author is a new developer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tags:&lt;/strong&gt; You cannot condition assignment on the presence of a specific tag.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This limitation makes &lt;code&gt;CODEOWNERS&lt;/code&gt; a rudimentary tool that cannot adapt to the complexity and context that a modern CI/CD process demands.&lt;/p&gt;

&lt;h2&gt;
  
  
  Goodbye rigidity: total control
&lt;/h2&gt;

&lt;p&gt;For teams looking to optimize the quality, speed, and intelligence of their code reviews, it's necessary to make the leap to a configurable and flexible solution.&lt;/p&gt;

&lt;p&gt;Introducing &lt;strong&gt;Pull Reviewer&lt;/strong&gt;, an application that integrates directly with GitHub and transforms reviewer assignment, solving the limitations of the native system's rigidity through logical rules.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pull Reviewer: contextual control for your Pull Requests
&lt;/h3&gt;

&lt;p&gt;Pull Reviewer is a comprehensive solution designed to extend the concept of code ownership, allowing you to define &lt;strong&gt;who reviews what, under what conditions, and with what logic&lt;/strong&gt;, through a declarative configuration file: &lt;code&gt;reviewers.yml&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advanced conditional logic
&lt;/h3&gt;

&lt;p&gt;Forget about static routing rules. With Pull Reviewer, your assignment rules respond to the &lt;strong&gt;entire context&lt;/strong&gt; of the pull request, not just the modified files.&lt;/p&gt;

&lt;p&gt;Using the &lt;code&gt;when&lt;/code&gt; block, you can combine different criteria to trigger a specific assignment. Look at the level of control you gain:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Condition&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Advantage over CODEOWNERS&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;paths&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;File paths.&lt;/td&gt;
&lt;td&gt;Direct complement to CODEOWNERS.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;targets&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Target branch (e.g., &lt;code&gt;main&lt;/code&gt;, &lt;code&gt;staging&lt;/code&gt;).&lt;/td&gt;
&lt;td&gt;Imposes stricter reviews for production merges.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;labels&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Labels applied to the PR (e.g., &lt;code&gt;hotfix&lt;/code&gt;, &lt;code&gt;documentation&lt;/code&gt;).&lt;/td&gt;
&lt;td&gt;Assigns specific experts only when the label requires it.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;authors&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Author of the Pull Request.&lt;/td&gt;
&lt;td&gt;Applies specialized review rules for certain users.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;size&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Size of the change (modified lines).&lt;/td&gt;
&lt;td&gt;Automatically assigns more reviewers to large Pull Requests.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;all&lt;/code&gt;/&lt;code&gt;any&lt;/code&gt; logic&lt;/td&gt;
&lt;td&gt;Combines conditions with AND/OR.&lt;/td&gt;
&lt;td&gt;Creates complex workflows (e.g., “if it's large &lt;strong&gt;AND&lt;/strong&gt; goes to &lt;code&gt;main&lt;/code&gt;”).&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Example of a complex rule in reviewers.yml:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Critical&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;production"&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;prod_critical&lt;/span&gt;
    &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Requires&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;approval&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;if&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;it&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;goes&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;into&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;production&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;touches&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;the&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;API."&lt;/span&gt;
    &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;all&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;src/api/**"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
        &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;main"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;reviewers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;users&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;seniorDev&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;techLead&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Clear and declarative configuration
&lt;/h3&gt;

&lt;p&gt;Pull Reviewer externalizes all this logic into a single &lt;code&gt;reviewers.yml&lt;/code&gt; file, which is reviewed and validated on every Pull Request. This provides immediate &lt;strong&gt;transparency&lt;/strong&gt; and &lt;strong&gt;error validation&lt;/strong&gt;, notifying issues before they impact the workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Take a leap into the future of code review!
&lt;/h3&gt;

&lt;p&gt;If the rigidity of &lt;code&gt;CODEOWNERS&lt;/code&gt; is hindering the automation of your review policies, it's time for a change. Pull Reviewer gives you the flexibility to model the reality of your teams and the criticality of your projects.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🚀 &lt;strong&gt;Discover the power of contextual review and get started today: &lt;a href="https://pullreviewer.com/" rel="noopener noreferrer"&gt;https://pullreviewer.com/&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;CODEOWNERS&lt;/code&gt; file is a fundamental pillar in modern code ownership architecture on GitHub. By clearly defining who is responsible for what, it facilitates a faster, more accountable, and more secure code review process.&lt;/p&gt;

&lt;p&gt;However, for teams seeking maximum efficiency and granular control over the assignment process, tools such as &lt;strong&gt;Pull Reviewer&lt;/strong&gt; offer the logical evolution, ensuring that the right expert is assigned based on the exact context of the change.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
