Prompts & Rules
How to shape AI behavior without writing code
The Prompt Stack
AI doesn't just see your question -- it sees layers of context that shape its behavior.
Five Layers of Context
Each layer adds more specificity. The AI sees all of them combined:
- System prompt — built into the AI tool (Claude Code / Copilot CLI)
- CLAUDE.md — project instructions at the repo root
- .claude/rules/ — path-scoped conventions (auto-loaded per file type)
- Skill instructions — the SKILL.md being executed
- Your message — what you typed
CLAUDE.md
The project's main instructions file -- like a README for the AI.
What Goes in CLAUDE.md
- Build and deploy commands
- Project structure overview
- Key conventions and patterns
- Branch strategy and CI info
- Links to setup guides
Both Tools Read It
Claude Code reads CLAUDE.md at the repo root. Copilot CLI also reads it
(since v1.0.4). One file, universal context for both tools.
/repo-root/CLAUDE.md
Rules (.claude/rules/)
Path-scoped convention files that auto-load when you edit matching files.
--- paths: ["**/*.js"] applyTo: "**/*.js" --- # JavaScript Conventions - Use CustomComponent custom elements (extends HTMLElement) - Lifecycle: options() -> beforeLoad() -> afterLoad() - No ES modules -- use Gulp concat pipeline - Externalize selectors to component config
Dual Frontmatter
Rules need both paths: (Claude Code) and applyTo: (Copilot CLI)
to work in both tools. Single file, dual format.
When does a rule activate?
Rules are reactive -- they load when the AI's tool calls touch matching files, not when a human opens the file.
The trigger is tool-call path matching
The AI doesn’t know “the user wants JS.” It only sees which files its tools are touching.
The moment a tool call returns or operates on a path matching paths:, the rule is
queued for the next model turn. The first matching tool call does NOT yet
benefit from the rule — turn two onward does.
Simulated loop: “build me a button component”
Given a rule at .claude/rules/fe-javascript.md with paths: [”**/*.js”].
Turn 1 -- Claude plans
Rule NOT loaded yet. Claude calls Glob(“src/components/**/*.js”) to survey existing
components. The harness sees matching paths in the result and queues the rule for injection.
Turn 2 -- rule injected
The fe-javascript.md contents now appear in Claude’s context. Claude reads an
existing component (Card.js) with the rule visible, locking in style expectations
before any code is written.
Turn 3 -- write with rule active
Claude calls Write(“Button.js”, …). Generated code conforms to the rule —
named exports, function declarations, no ES modules — because the rule was in context during
generation.
Turn 4 -- verify
Claude runs tests. The rule stays loaded for the rest of the session — re-injection is idempotent; it doesn’t get re-added on every matching call.
Why exploration-first matters
If Claude’s very first action is Write(“Button.js”, …) with no prior exploration,
the rule is NOT in context when the content is generated. The write itself matches the glob, but
by the time the rule injects on the next turn, the file is already on disk. This is why
“look before you write” workflows (Glob / Read first) produce better rule compliance.
Shared Rules (.ai/rules/)
Cross-tool rules read by both local skills and CI/CD automation agents.
pr-review.md
PR review standards — 80%+ confidence threshold, severity levels, constructive tone.
pr-answer.md
How to reply to PR comments — cite code, be concise, acknowledge valid points.
pragmatism.md
Filter for practical questions — skip theoretical debates, focus on actionable feedback.
Edit Once, Changes Everywhere
Shared rules in .ai/rules/ are read by local interactive sessions AND autonomous
CI/CD agents. Update the rule once and every agent picks up the change.
AGENTS.md
Agent inventory at repo root -- Copilot CLI reads it for context about available agents.
Agent Registry
AGENTS.md at the repo root lists all available agents with their names,
descriptions, and capabilities. Copilot CLI uses this to understand which agents are
available for @AgentName invocation. Claude Code agents are defined in
plugin agents/ directories instead.