Where Your
AI Looks
Five layers that turn a wandering agent into a focused one. The infrastructure that makes Copilot, Claude, and any other coding AI stop guessing and start delivering.
Even with instructions, your AI still wanders
An instructions file is a real upgrade. After a few weeks, the cracks show. One file is loaded into every conversation, so it has to be short. Some rules belong everywhere; some rules belong on one file type; some rules are procedures, not standards. When everything goes in the same place, none of it lands consistently.
Context is a layered budget
Every token your AI reads is a token it cannot spend on your problem. The fix is not to write more rules, it is to put each rule on the right layer so it loads only when it actually applies. Three questions decide the layer.
Five layers, each with a different cost
Stacked from highest cost to lowest. The right rule on the right layer is the entire game. Every layer below the first is essentially free unless the model needs it.
Layers 1 to 3: what the model reads
The first three layers shape what your AI sees before it starts thinking. Identity is the lens. Path rules are the page-margins. Skills are the recipes it can pull off the shelf when asked.
Layers 4 and 5: what the model cannot skip
The last two layers solve different problems. Subagents protect the main conversation from doing too much at once. Hooks remove the model from the loop entirely for rules that must always fire.
First-match wins. Walk down the list.
For any new rule, walk these five questions top to bottom. Stop at the first one that fits. The same rule placed on the wrong layer either burns context every turn or never fires when it should.
-
Is this a universal rule or identity fact the AI must always know?CLAUDE.md
-
Is this a file-type or folder-scoped rule that only applies sometimes?.claude/rules/*.md
-
Is this a multi-step procedure or workflow a user kicks off by name?.claude/skills/*/SKILL.md
-
Is this a restricted role with a limited toolset for one job?.claude/agents/*.md
-
Must this fire deterministically, with no chance of being skipped?settings.json hook
Three traps that quietly waste context
Every project that uses AI long enough drifts into one of these. They are easy to fix once you see them, hard to spot from inside.
Audit your project in 15 minutes
-
1Open your CLAUDE.md or copilot-instructions.md. Read it top to bottom. Note anything longer than three lines.
-
2Walk each rule through the routing questions. Universal, file-scoped, procedure, restricted role, or deterministic? Mark every rule with the layer it actually belongs on.
-
3Move file-type rules to
.claude/rules/. One file per dialect or path: a sql.md for T-SQL conventions, a pq.md for Power Query, a reports.md for everything inside the reports folder. Add aglobs:line to the frontmatter so it auto-loads only when relevant. -
4Move multi-step procedures to
.claude/skills/. One folder per skill (monthly variance, week-over-week refresh, ad-hoc audit), each with aSKILL.md. Put exact trigger phrases in the description so the model knows when to load it. -
5For rules the AI must never skip, write a hook. Add it to
.claude/settings.jsonunderhooks. Hooks run as shell commands on fixed events (when a file is saved, when the AI tries to stop), with the model out of the loop.
Where this comes from
Each layer in this module maps to a documented surface in either the Claude Code or VS Code Copilot ecosystem. The five-layer framing is original synthesis, but every layer is a real, documented configuration mechanism. Verify anything you want to.
-
[1]Anthropic Docs Claude Code overview
Umbrella reference for the Claude Code CLI. Backs the framing that CLAUDE.md, path-scoped rules, skills, subagents, and hooks are all first-class configuration surfaces, not just convention.
docs.claude.com/en/docs/claude-code/overview -
[2]Anthropic Docs Subagents in Claude Code
Documents how subagents are defined in
docs.claude.com/en/docs/claude-code/sub-agents.claude/agents/, how the tools list restricts their capabilities, and how their context is isolated from the main thread. Backs Layer 4 (scene 6). -
[3]Anthropic Docs Hooks in Claude Code
Reference for the hook system: hook events (PreToolUse, PostToolUse, Stop, etc.), how they are configured in
docs.claude.com/en/docs/claude-code/hookssettings.json, and the fact that they run as deterministic shell commands. Backs Layer 5 (scene 6) and the enforcement framing in scene 3. -
[4]VS Code Docs Use custom instructions in VS Code
Documents
code.visualstudio.com/docs/copilot/customization/custom-instructions.github/copilot-instructions.mdas the always-on identity surface plus the.github/instructions/folder for path-scoped instructions. Backs Layers 1 and 2 in the Copilot ecosystem. -
[5]VS Code Docs Customize AI in Visual Studio Code
Umbrella reference for every Copilot customization surface, including chat modes and reusable prompts (Copilot's analog to skills). Backs the cross-ecosystem framing in scenes 4 through 6.
code.visualstudio.com/docs/copilot/customization/overview