Questions about using prompts and instructions #181190
-
Select Topic AreaQuestion Copilot Feature AreaGeneral BodyIβm working with prompt files and instructions files in VS Code while using Copilot in Agent mode, and Iβm trying to understand how they interact. Right now, I trigger a prompt by typing something like Do prompt files and instructions run together automatically? If there are recommended usage patterns or best-practice examples on how to combine prompts and instructions in an Agent workflow, Iβd appreciate some guidance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Youβre thinking about it the right way. Basically: Prompt files only run when you explicitly call them, like when you type Instructions files are persistent , they act like global rules or context that the Agent keeps in mind all the time. So every prompt you run will automatically follow the instructions. A good way to think about it is: instructions files = the Agentβs βpersonalityβ or βguidelines,β and prompt files = the specific tasks you want it to do. A common workflow is to keep instructions files for general behaviors and context, then trigger different prompts as needed for specific tasks. That way, you donβt have to repeat context or rules every time, and your workflow stays clean and efficient. |
Beta Was this translation helpful? Give feedback.
-
|
Additional Context: Working with Prompts and Instructions in Copilot Agent Mode Hi @yorkeChen, Great question! @Dinuka-Nonis provided an excellent foundation. Let me expand on this with more technical details and practical examples to help you get the most out of combining prompts and instructions. How They Work Together Instructions Files (.github/copilot-instructions.md)
Prompt Files (.prompt.md)
Execution Flow When you invoke a prompt file, here's what happens:
Think of it as: Best Practice Examples Example 1: Instructions File <!-- .github/copilot-instructions.md -->
# Project Guidelines
## Code Style
- Use TypeScript strict mode
- Follow ESLint rules defined in .eslintrc
- Prefer functional components with hooks
## Naming Conventions
- Use camelCase for variables and functions
- Use PascalCase for components and classes
- Prefix interfaces with 'I'
## Testing Requirements
- Write unit tests for all business logic
- Use Jest and React Testing Library
- Aim for 80% code coverageExample 2: Prompt File <!-- .github/prompts/create-component.prompt.md -->
# Create React Component
Create a new React component with the following structure:
- Functional component with TypeScript
- Props interface definition
- Basic styling with CSS modules
- Unit test file with basic render test
Component name: {user will specify}Example 3: Usage The Agent will:
Recommended Workflow Patterns Pattern 1: Role-Based Instructions <!-- .github/copilot-instructions.md -->
# Role
You are a senior full-stack developer specializing in React and Node.js
# Always
- Consider performance implications
- Include error handling
- Add inline documentationPattern 2: Prompt Library Organization Pattern 3: Contextual Prompts <!-- create-feature.prompt.md -->
# Create Feature Module
Following the project guidelines in copilot-instructions.md:
1. Create component structure
2. Add TypeScript interfaces
3. Implement business logic
4. Write comprehensive tests
5. Update documentationAdvanced Tips
Common Pitfalls to Avoid β Don't duplicate rules between instructions and prompts β Don't make instructions too verbose β Don't create too many prompts Resources Hope this provides a more complete picture of how to architect your Copilot workflow! Let me know if you need clarification on any specific pattern. Best regards, |
Beta Was this translation helpful? Give feedback.
Additional Context: Working with Prompts and Instructions in Copilot Agent Mode
Hi @yorkeChen,
Great question! @Dinuka-Nonis provided an excellent foundation. Let me expand on this with more technical details and practical examples to help you get the most out of combining prompts and instructions.
How They Work Together
Instructions Files (.github/copilot-instructions.md)
Prompt Files (.prompt.md)