Instruction System Reference

This page explains how instruction sources are prioritized, interpreted, and executed, including conflict resolution, scope behavior, workflow sequencing, and fallback handling.

Quick Start (TL;DR)

1) Instruction Sources and Priority

Priority Source What it controls Override behavior
1 (highest) System instructions Global policy, safety rules, core behavior, policy limitations. Overrides all lower-priority sources.
2 Developer instructions Task workflow, tool usage requirements, output formatting requirements. Overrides user and repository-local guidance.
3 User instructions Requested deliverable, target files, desired outcome. Overrides repo-local conventions when no higher-level conflict exists.
4 Repository-local instructions (for example, AGENTS.md) Code style, folder-level rules, testing notes, PR conventions. Overrides lower conventions within its scope; cannot override higher layers.
5 (lowest) Defaults and conventions General style assumptions when no explicit instruction exists. Always yields to explicit instructions.

2) Scope Rules for Path-Based Instruction Files

Example Scope Tree

repo/ ├── AGENTS.md # applies to everything in repo/ ├── frontend/ │ ├── AGENTS.md # overrides repo AGENTS for frontend/** │ └── src/app.js └── backend/ └── api/server.js

In this example, edits to frontend/src/app.js follow frontend/AGENTS.md first, then fall back to repo-level guidance only where non-conflicting.

3) Instruction Types and How to Interpret Them

A) Hard constraints

Terms like must, do not, never, and strictly forbidden are mandatory.

B) Conditional constraints

Rules in the form "if X, then Y" only apply when condition X is true. Document both trigger and required action.

C) Preference guidance

Terms like prefer and use judgment are advisory and should be followed unless they conflict with stronger rules.

D) Output formatting rules

Required output templates, headings, and symbols are compliance requirements and should be followed exactly.

4) Conflict Resolution Algorithm

  1. Collect all active instructions from all sources.
  2. Sort by precedence (system → developer → user → scoped repo files → defaults).
  3. Apply hard constraints first.
  4. Filter scoped instructions by touched file path.
  5. Resolve direct conflicts by higher source priority, then by narrower scope specificity.
  6. If ambiguity remains, choose the safest compliant interpretation and state assumptions in the response.

5) Worked Conflict Examples

Example A: User preference vs developer requirement

Input: User asks for plain text. Developer requires markdown template output.

Resolution: Use markdown template output (developer instruction has higher priority).

Example B: Nested scoped files

Input: Root AGENTS says "2-space indent"; nested AGENTS says "4-space indent".

Resolution: Files in nested subtree use 4 spaces; files outside use 2 spaces.

Example C: Preference vs hard rule

Input: "Prefer command A" and "Never run command A with flag --unsafe".

Resolution: Hard prohibition wins; use safe variant or fallback.

6) Execution Workflow

  1. Read request and identify deliverable.
  2. Locate applicable instruction sources and scoped files.
  3. Build a short execution plan.
  4. Implement edits with scope-compliant style and structure.
  5. Run checks/tests aligned with instructions.
  6. Prepare final response in required template.
  7. Verify no forbidden actions or missing required steps remain.

7) Output Template Requirements

8) Tooling and Environment Constraints

9) Skill Usage Rules

10) Failure Handling and Fallbacks

11) End-of-Task Compliance Checklist