Agentic Pattern Libraryby Vikas Goyal
← All patterns
63

Protected Rule Files

Also known as: self-modification lock, governance file protection, rules-are-code-owned

Agents can't commit changes to the files that govern them (review rules, CI, ownership, agent instructions); those changes need extra human approval.

TrackAI-native software delivery FamilyVerify Maturity Emerging ChangesTool/action
01

Problem

Coding agents work under rules kept in the repository: the project memory file, review rules, CI workflows, code-owner lists, approval policies and git hooks. If an agent can edit those files as part of ordinary work, a fix can quietly loosen the checks that were meant to catch it, such as skipping a failing test in CI or deleting a review rule that kept flagging its change. A comment or PR text can also nudge an agent into doing exactly that.

  • Rule files sit in the same repo agents are allowed to change.
  • Some legitimate tasks do require editing CI or agent instructions.
  • Anyone who can merge can edit these files, so the risk isn’t only agents.
  • Checks an agent can turn off are not checks.
02

Solution

Treat the files that govern agents as protected. Unattended agents are blocked in tooling from committing to them: agent instruction files, review rules, approval policy, CI workflows, code-owner lists and git hooks. When a change to them is genuinely needed, a person commits it in its own PR, and the approval policy requires stricter review for those paths, such as two people or a code owner. Enforce required checks in CI and branch rules rather than in local hooks an agent’s commits can skip. Review changes to these files with the same care as CI changes.

03

Diagram

Agentunattended App codesrc · tests Protected agent instructions review rules · policy CI workflows code owners · hooks Checks + reviewenforced in CI Person commitsown PR Strict approval2 people ✕ blocked rules judge the code

Agents can change the code but not the rules that judge the code. Rule changes take a separate, stricter path.

04

When to use

Use it when

  • Agents commit to repos unattended
  • Review rules, CI or agent instructions live in the repo
  • Approval or review policies rely on files in the repo
  • Agents read PR comments that outsiders can write

Avoid it when

  • Repos where agents only suggest changes and never commit
  • When the protection would also block the people who maintain CI; give them a clear path instead
05

Trade-offs

Latency Rule changes need a separate PR and stricter review
Cost Tooling blocks and an approval rule
Complexity List the protected paths; keep the list current
Reliability Checks can't be loosened by the work they check

Gains

  • Agents can't weaken the checks on their own work
  • Rule changes are visible and deliberate
  • Limits injected through comments or PR text have less reach

Costs

  • Slower edits to CI and rule files
  • Protected path lists need upkeep
  • Can frustrate legitimate maintenance if the human path is unclear
06

Worked example

Scenario
A PR steward is fixing a failing integration test on a Linkwatch PR. The test times out in CI.
  1. StewardAfter two attempts, the fastest way to green is raising the CI timeout in the workflow file. The tooling blocks the commit because the workflow file is protected.
  2. EscalateThe steward reports to the author: the test is slow because of a missing index, and raising the timeout would need a person.
  3. AuthorAdds the index instead. The test passes within the original timeout.
  4. LaterA platform engineer does want a longer timeout for a different job. She commits it in its own PR, and the approval policy requires a second person for .github/ paths.
07

Failure modes

FailureSymptomMitigation
Incomplete listAgent edits a hook or policy file that wasn't listedProtect by folder, such as all of `.github/` and agent config folders
Local-only enforcementChecks live in git hooks that agent commits bypassEnforce required checks in CI and branch rules
Human bypassRule changes ride along in a large feature PRApproval policy requires stricter review for rule paths
Blocked maintenanceNobody knows how to change CI legitimatelyDocument the human path for rule changes