{"id":2496,"date":"2025-09-17T17:13:37","date_gmt":"2025-09-17T17:13:37","guid":{"rendered":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/2025\/09\/17\/prompt-files-and-instructions-files-explained\/"},"modified":"2025-09-17T17:13:37","modified_gmt":"2025-09-17T17:13:37","slug":"prompt-files-and-instructions-files-explained","status":"publish","type":"post","link":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/2025\/09\/17\/prompt-files-and-instructions-files-explained\/","title":{"rendered":"Prompt Files and Instructions Files Explained"},"content":{"rendered":"<p>GitHub Copilot is transforming the way developers write code by acting as an intelligent coding agent directly in your editor. Whether you\u2019re building ASP.NET web applications, working with C#, or reviewing code with your team, Copilot can help automate repetitive tasks, suggest entire functions, and streamline code reviews. In this guide, we\u2019ll explore productivity tips, practical examples, and best practices for setting up instruction files and prompt files in Visual Studio, VS Code, and GitHub.com\u2014making it easy for .NET developers to harness its full potential.<\/p>\n<h2>Instruction Files<\/h2>\n<p>Do you wish Copilot knew more about your solution and your coding preferences? Instruction Files are here to help.<\/p>\n<h3>What are Instruction Files?<\/h3>\n<p>Instruction files (often named copilot-instructions.md) define the rules, coding standards, or guidelines Copilot should follow when generating code in your repository or workspace.<br \/>\nYou can create a generic custom instructions file that is used for every request (copilot-instructions.md) and you can create instructions specific to certain scenarios (title.instructions.md) that are applied only to applicable requests.<br \/>\nLearn more about custom instructions.<\/p>\n<h3>When to Use Instruction Files<\/h3>\n<p>Use instruction files in team projects to ensure Copilot suggests code that aligns with your organization\u2019s standards and naming conventions.<br \/>\nGreat for open-source repositories where contributors might benefit from automated adherence to project-specific rules.<\/p>\n<h3>How to Use Instruction Files<\/h3>\n<p>Write your instructions file starting with a sample, from scratch, or using Copilot.<br \/>\nPlace your copilot-instructions.md file in the .github folder in your workspace. Place your file type specific instructions that only apply to .cs files or .razor files in your .github\/instructions folder.<br \/>\nCopilot will automatically include the appropriate instructions files with each request sent via the chat.<\/p>\n<h3>What to include in Instruction Files<\/h3>\n<p>Purpose &amp; scope: One sentence saying what this instruction file controls (e.g., \u201cGuides automated assistants on safe repo edits and conventions for the Blazor UI\u201d).<br \/>\nLocation &amp; scope rules: Where the file applies (paths, languages, file globs) and any cases it does NOT apply to.<br \/>\nProject overview: Short intent of the project (audience, main features, runtime\/platform).<br \/>\nTooling &amp; versions: Exact commands and versions (e.g., .NET 8.0, dotnet command examples, Node, Python, SDKs).<br \/>\nBuild \/ run \/ test commands: Minimal, copyable commands for dev and CI (PowerShell-friendly examples on Windows).<br \/>\nCoding conventions &amp; linting: Formatter (e.g., dotnet format, prettier), style rules, naming patterns, Single Source of Truth for style.<br \/>\nAPI &amp; data contracts: JSON shapes, DTO examples, DB schemas or important fields (avoid secrets).<br \/>\nTests &amp; E2E expectations: Which tests must pass before changes are accepted.<br \/>\nCI\/CD &amp; release rules: Branching model, required checks, versioning policy, deployment constraints.<br \/>\nSecurity &amp; secrets policy: What must never be checked in, env var naming, secret storage guidance.<br \/>\nAllowed edits &amp; risk tolerance: What the assistant can change autonomously (typo fixes, formatting, tests) vs what requires reviewer\/PR (schema changes, DB migrations, infra).<br \/>\nOutput format &amp; diffs: How to present code changes (patch format, single-file edits vs multi-file), commit message style, PR description template.<br \/>\nBehavior &amp; tone: Preferred assistant persona (concise, conservative, test-first), verbosity and what to ask the human about.<br \/>\nFailures &amp; rollback: How to handle failing builds or tests, revert instructions, and who to notify.<br \/>\nExamples &amp; snippets: Good examples of small accepted PRs and disallowed changes.<br \/>\nMaintenance notes: Where to update this doc and how often.<\/p>\n<p>For more samples of instruction files, check out the many community-submitted examples at <a href=\"https:\/\/github.com\/github\/awesome-copilot\/tree\/main\/instructions\">awesome-copilot\/instructions<\/a>.<\/p>\n<h2>Prompt Files<\/h2>\n<p>Do you use Copilot to perform similar tasks on your repo? Do you wish Copilot knew better what it was allowed to change and what not? Prompt Files are here to help.<\/p>\n<h3>What are Prompt Files<\/h3>\n<p>Prompt files provide context for Copilot in a specific coding session or for a particular file. They can be added as context or dedicated prompt files to steer the AI\u2019s output for a given task.<\/p>\n<h3>When to Use Prompt Files<\/h3>\n<p>Use prompt files when you need Copilot to generate code following specific requirements, such as for custom algorithms, integrations, or compliance needs.<br \/>\nIdeal for prototyping, documentation, or when onboarding new team members who need explicit guidance.<\/p>\n<h3>How to Use Prompt Files<\/h3>\n<p>Write the prompt starting with a sample, from scratch, or with the help of Copilot.<br \/>\nPlace it in the .github\/prompts folder in your workspace with the filename format [promptname].prompt.md, for example CreateAnalyzer.prompt.md.<br \/>\nIn VS Code, type \/[promptName] in the chat to use it, and in VS, type #[promptName] in the chat to use it. For example, to create an analyzer that checks for weak hashing techniques using my CreateAnalyzer prompt, I would type \u201c\/CreateAnalyzer detect usage of MD5.Create(), SHA1.Create(), RijndaelManaged with insecure modes, new HMACSHA1(), or TripleDES and suggest using SHA256 or RandomNumberGenerator and point to library wrappers\u201d.<\/p>\n<h3>What to include in Prompt Files<\/h3>\n<p>Header \/ Metadata<\/p>\n<p>Name, version, last-updated, author\/maintainer contact.<br \/>\nScope globs (what paths \/ languages \/ components the prompt controls).<\/p>\n<p>Purpose \/ One-line summary<\/p>\n<p>Short statement of intent (what this prompt enables the assistant to do).<\/p>\n<p>Persona &amp; tone<\/p>\n<p>How the assistant should speak (concise, conservative, ask clarifying Qs).<\/p>\n<p>Allowed autonomous actions<\/p>\n<p>Precise list (typo fixes, docs updates, single-file refactors with tests, formatting).<br \/>\nInclude limits (e.g., max files changed, no infra changes).<\/p>\n<p>Disallowed actions \/ require human review<\/p>\n<p>DB schema\/migrations, secrets, production config, large refactors, major dependency upgrades.<\/p>\n<p>Build \/ Run \/ Test commands<\/p>\n<p>Exact commands and environment notes (PowerShell examples for Windows workspaces).<br \/>\nMinimum smoke-check commands the assistant should run locally before proposing a change.<\/p>\n<p>Lint\/format commands<\/p>\n<p>Tools and invocation (e.g., dotnet format, prettier \u2013check).<\/p>\n<p>CI rules &amp; PR acceptance criteria<\/p>\n<p>Must-pass checks, required labels, tests to run, PR title\/body template.<\/p>\n<p>File &amp; path exceptions<\/p>\n<p>List binary, generated, or vendor files that must not be changed.<\/p>\n<p>Output format &amp; patch conventions<\/p>\n<p>Patch\/PR format, commit message style, testing evidence to include.<\/p>\n<p>Error handling &amp; rollback<\/p>\n<p>What to do if tests fail, how to revert, who to notify.<\/p>\n<p>Examples<\/p>\n<p>2\u20133 short \u201cgood\u201d and \u201cbad\u201d examples of edits the assistant might make.<\/p>\n<p>Minimal machine-ready snippet (optional)<\/p>\n<p>YAML or front-matter with apply-to globs, sdk versions so automation can parse it.<\/p>\n<p>Maintenance notes<\/p>\n<p>Who updates this file, and when to bump the version.<\/p>\n<p>For samples of prompt files, check out the many community-submitted examples at <a href=\"https:\/\/github.com\/github\/awesome-copilot\/tree\/main\/prompts\">awesome-copilot\/prompts<\/a>.<\/p>\n<h2>Choosing Between Instruction and Prompt Files<\/h2>\n<p>Instruction Files: Best for repository-wide guidance and long-term standards across multiple contributors and projects.<br \/>\nPrompt Files: Best for local, session-based guidance or for specific functionality in a single file or segment.<br \/>\nCombine Both: For maximum results, use instruction files for your overall project and supplement with prompt files in areas that need extra clarity or specificity.<\/p>\n<h3>Best Practices: Effective Prompt Writing and Collaboration<\/h3>\n<p>Be specific with prompts and instructions\u2014clarity yields better suggestions.<br \/>\nReview all AI-generated code for accuracy, security, and compliance.<br \/>\nUse instruction files for consistency and prompt files for targeted guidance.<br \/>\nCheck out the documentation at <a href=\"https:\/\/code.visualstudio.com\/docs\/copilot\/customization\/overview\">Customize chat to your workflow<\/a>.<br \/>\nShare Copilot\u2019s outputs in code reviews for collaborative improvement.<\/p>\n<h2>Conclusion: Experiment, Guide, and Collaborate with Copilot<\/h2>\n<p>GitHub Copilot can supercharge your .NET projects when guided with clear instructions and prompts. By exploring Copilot\u2019s many ways of helping you achieve more, you\u2019ll maximize both productivity and code quality. Explore, refine, and share your Copilot experiences with the developer community!<\/p>\n<p>The post <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/prompt-files-and-instructions-files-explained\/\">Prompt Files and Instructions Files Explained<\/a> appeared first on <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\">.NET Blog<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>GitHub Copilot is transforming the way developers write code by acting as an intelligent coding agent directly in your editor. [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[7],"tags":[],"class_list":["post-2496","post","type-post","status-publish","format-standard","hentry","category-dotnet"],"_links":{"self":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts\/2496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/comments?post=2496"}],"version-history":[{"count":0,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts\/2496\/revisions"}],"wp:attachment":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/media?parent=2496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/categories?post=2496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/tags?post=2496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}