Best Practices for AI Coding Assistants

Chapter 1 · Practice 4 of 4

Use nested or path-specific instructions for different parts of a repo

From Project instruction files

Why it matters

Large repositories have parts with different rules: a frontend app, a data pipeline, infrastructure code. Put those rules where they apply.

  • AGENTS.md: place a file in each subproject. Agents read the nearest file in the directory tree, so the closest one takes precedence, and explicit instructions in the chat prompt override everything.
  • GitHub Copilot: path-specific .instructions.md files use an applyTo glob in front matter. When both repository-wide and path-specific files apply, Copilot uses both.
  • Claude Code: move knowledge that is only needed sometimes into skills, which load on demand instead of filling every session.

This keeps the root file short and gives each area rules that are actually relevant to it.