TL;DR — I added copilot-instructions.md and copilot-prompts.md to my solution root, configured Visual Studio to use them as persistent workspace context, and Copilot went from 'sometimes helpful' to 'consistently reliable teammate.'
The Problem: Copilot Without Guardrails
In real-world enterprise codebases, you often have a mix of legacy and modern applications, backend APIs, frontend SPAs, background services, strict conventions, and CI/CD constraints.
Without persistent context, Copilot can guess API shapes, place interfaces in the wrong files, mix architectural patterns, remove code unintentionally, or ignore naming conventions.
In large, long-lived systems, that creates friction and architectural drift.
The Fix: Persistent Workspace Context
Instead of rewriting instructions in every chat session, I created two files at the solution root:
• copilot-instructions.md
• copilot-prompts.md
These files act as architectural guardrails, a style guide, a repeatable workflow engine, and a living AI contract — all version-controlled with the repository.
File #1 — copilot-instructions.md
This file defines standing directives and architectural rules. It serves as onboarding documentation for your AI teammate.
Example directives:
• Ask questions before writing code if anything is unclear
• Do not remove existing code unless explicitly asked
• Do not guess API shapes or endpoints
• Place TypeScript interfaces one per file in /models
• Put all HTTP logic in service files
• Follow feature-based folder organization
• Use consistent styling conventions
You can also include high-level project structure, technology constraints, naming conventions, build pipeline rules, and legacy vs modern boundaries
Visual Studio will look for this file as configured under Tools>Options>Github
I added this directive as well:
- look for a file copilot-prompts.md in the same folder as the solution for additional context. A prompt in the chat window of "Go" means look at the context files and do the actions described there
File #2 — copilot-prompts.md
This file stores repeatable workflow prompts for common development tasks.
Examples:
• Add new feature module (create models, services, components properly)
• Compare legacy page to modern SPA implementation
• Refactor safely without removing existing code
• Scaffold dialogs following existing patterns
Instead of rewriting long prompts in chat, you can trigger workflows with a simple keyword like 'Go' while referencing workspace context.
This file is not in source control, individual users can edit it on the fly during sessions.
How to Configure Visual Studio
- Place both Markdown files at the solution root.
- Enable workspace context for Copilot.
- Use workspace references when prompting.
- Standardize trigger words for repeatable flows. Because copilot-instructions.md lives in the repository, it applies across machines and developers, evolve with the codebase, and reduce architectural entropy.
Real Improvements
• Fewer hallucinated APIs
• Cleaner frontend structure
• Safer legacy modifications
• Less prompt rewriting
• Architecture enforced as code
The Bigger Insight
AI productivity does not come from clever prompts alone. It comes from persistent context, explicit constraints, clear boundaries, and repeatable workflows.
Treat Copilot like a junior developer: give it structure and guardrails, and it becomes dramatically more effective.
If You Want to Try This
Create:
• copilot-instructions.md
• copilot-prompts.md
Define your architecture rules, naming conventions, workflow patterns, and non-negotiables. Keep it high-level, clear, and safe.
Your AI pair programmer — and your future self — will thank you.

Top comments (0)