Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use three layers to keep coding agents aligned with a codebase: give the agent clear architecture guidance in the instruction format its harness reads, turn critical structural rules into automated checks, and verify those instructions and checks in the actual harness. Prose explains intent; tests and linters catch repeatable violations.

1. Put the architecture where the agent can find it

Start with the instruction mechanism supported by the harness you use. A rule in a file the agent does not discover cannot guide its work. VS Code’s codebase customization guide recommends documenting architecture, important directories, conventions, build and test commands, and what a completed change must satisfy.

Write down the repository decisions an agent cannot safely infer from nearby code: important boundaries, allowed dependency directions, established patterns, and the checks required for a change. Explain why a boundary exists when that context helps an agent choose among plausible implementations. Keep repository guidance focused on rules that matter rather than an unprioritized catalogue of preferences.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Scope rules to the code that needs them

Keep genuinely global rules in project-wide instructions. If different directories have different constraints, use a mechanism that targets those paths instead of making every instruction apply everywhere. The exact filenames and discovery behavior depend on the harness, so confirm them in its current documentation.

Harness or use case Documented instruction location or mechanism Scope
OpenAI Codex in VS Code AGENTS.md Project context; nested files can provide directory-specific instructions discovered from the repository root down to the working directory. See VS Code’s custom instructions guide.
GitHub Copilot in VS Code .github/instructions/**/*.instructions.md with applyTo patterns Path-targeted instructions; VS Code also documents project-wide instruction formats. See VS Code’s codebase customization guide.
Claude in VS Code Path metadata in .claude/rules Path-targeted rules, as documented in the VS Code guide above.
GitHub Copilot code review .github/copilot-instructions.md; root AGENTS.md; .github/instructions/**/*.instructions.md GitHub documents these for repository-wide review guidance, project context, and path-specific review guidance, respectively. See GitHub’s code review documentation.

These are documented examples, not interchangeable filenames. Use the format for the agent and task at hand; a code-review configuration, for example, is not automatically a substitute for instructions used during implementation.

3. Turn critical boundaries into checks

Instructions can explain an architectural rule, but a deterministic check is more reliable for catching a repeatable structural violation. OpenAI describes using custom linters and structural tests to enforce architecture in an agent-first repository, alongside a small set of “taste invariants” in its article on harness engineering.

  1. State the rule and its rationale in the repository guidance, including what code is allowed to depend on what.
  2. Automate the checkable part with a lint rule or structural test—for example, a repository-specific check that prevents a restricted layer from importing a disallowed module.
  3. Make violations actionable. Include a remediation path in the check’s failure message so the agent can understand how to correct the change. OpenAI notes that custom lint messages can inject remediation instructions into agent context.
  4. Leave contextual judgments to review. Not every architectural choice can be reduced to a mechanical rule; use human review where a decision depends on trade-offs or product context.

Do not treat a passing structural test as proof that every design decision is sound. It establishes that the conditions encoded in that test passed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Test discovery and behavior in the intended harness

Check both that the agent finds the right instructions and that its proposed change respects them. VS Code recommends reviewing an instruction pattern and testing it in a new chat by asking for a small change to a file matched by the rule. Its guide also advises opening the relevant subdirectory as the working folder when testing nested Codex instructions.

  1. Choose a small, low-risk change in a file that should match the instruction.
  2. Start a fresh chat with the same harness and working-folder context you expect developers to use.
  3. Ask for the change, then inspect whether the agent follows the relevant boundary and conventions.
  4. Run the repository’s actual lint and structural checks on the resulting change.

If the agent misses a rule, investigate whether the file was discovered, whether its scope matched the target file, and whether the instruction was clear. Adding more prose will not fix a discovery or scope problem.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

5. Use prose and automation for different jobs

Prose is best for intent, rationale, and decisions that require context. Automated checks are best for constraints that can be stated and verified consistently. A practical setup uses both: explain the architecture where the agent reads project context, encode the most important mechanically testable boundaries, and exercise the configuration in the actual harness.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.