Articles

December 1, 2026

Enforcing the Same Constraints Across Claude Code, Copilot, Cursor, and Codex

Claude Code, Copilot, Cursor, and Codex each read different instruction files. Compile one rule set into all of them so every agent follows the same constraints.

Different agents read different instruction surfaces. Claude Code prioritizes CLAUDE.md and conversation history. Copilot Workspace leans on custom instructions and repo-level guidance. Cursor Composer weights .cursorrules and the current composer context. Codex and others pull from system prompts, tool definitions, and whatever was last injected. The result is the same policy expressed five ways, enforced zero ways.

What actually diverges

Instruction precedence
Each agent has its own resolution order. A constraint written only in a Cursor rule is invisible to Claude Code. A Copilot custom instruction that says “never touch migrations/” is ignored by an agent that was started with a different system prompt. Senior engineers discover this when two agents produce contradictory changes in the same PR.

Tool and path permissions
Agents expose different mechanisms for restricting file access. One supports explicit deny lists in its config; another only honors them if they appear in the initial system message; a third treats them as soft suggestions. A rule that “no agent may write to authz/ or *.pem” must be expressed in every surface or it is not a rule.

Check execution
Some agents will run a local command if told. Others require the check to be a GitHub required status. Still others will skip anything that is not already in their tool-calling schema. “Always run the schema diff and fail if it is non-empty” is trivial in one agent and impossible in another unless the requirement lives outside the agent.

Identity and approval binding
Agents open PRs as the invoking user or as a generic bot. None of them natively consult CODEOWNERS or a custom approval graph unless that logic is injected into their instructions and enforced by the platform that accepts the PR.

The practical approach

Stop maintaining per-agent copies of the rules. Maintain one model. Compile it into the artifacts each agent and the platform already consume.

  1. Single source specification
    Declare roles, path permissions, required checks, and human gates once. Example fragment:

    agents:
      - name: claude-code
        paths: ["src/**", "tests/**"]
      - name: cursor
        paths: ["src/**", "apps/**"]
    invariants:
      - path: "migrations/**"
        action: deny_direct_write
      - path: "authz/**"
        action: require_human_approval
    checks:
      - name: schema-diff
        command: "pnpm schema:diff --fail-on-change"
        required: true
    
  2. Compilation targets

    • Agent instruction files (CLAUDE.md, .cursorrules, Copilot instructions, Codex system prompts) generated from the same model.
    • GitHub rulesets and required status checks that fire regardless of which agent opened the PR.
    • CODEOWNERS updates or a parallel ownership map that the flow references.
    • A small validation script that agents are instructed to run (and that CI also runs) so the check is not optional.
  3. Enforcement points that do not rely on the agent

    • Branch protection and rulesets block merge if required checks are missing.
    • A pre-receive or CI gate rejects direct pushes that violate path rules.
    • Approval gates are implemented as required reviewers or status checks that only a human (or a designated service account) can satisfy.
      Agents can be told about these gates; they cannot bypass them.
  4. Version and drift detection
    The compiled artifacts carry a hash or version of the source model. A lightweight repo scan or CI step fails if any agent instruction file has drifted from the last compile. This catches the case where someone hand-edits .cursorrules and forgets the others.

Once the model is compiled, every agent is held to the same constraints by construction. Changing a rule means updating the model and recompiling; the instruction files, rulesets, and checks update together. The alternative is maintaining parallel policy documents that drift the moment a second agent is introduced.

Model your agent flow once and compile it into GitHub. See how Canon works