Supercharge Your Prompts with .prompt.md
Randy Pagels shows how to supercharge developer workflows by using .prompt.md files with GitHub Copilot, making prompts reusable and coding more efficient.
Supercharge Your Prompts with .prompt.md
Posted by Randy Pagels
Overview
The .prompt.md
file allows developers to store reusable prompts that guide GitHub Copilot’s behavior throughout a code repository. Instead of rewriting guidance or style rules for every session, you can centralize key instructions to maintain consistency and efficiency.
Why Use .prompt.md?
- Reusable Prompts: Define rich, detailed prompts specific to your project or workflow, avoiding repeated manual entry.
- Consistency: Keeps documentation, testing, and refactoring processes uniform across teams and contributors.
Example Use Cases
1. Project-Specific Prompts
# .prompt.md
## Generate API Docs
Generate documentation for every public function in this repo. Use a markdown format with clear examples.
Copilot can access this to speed up API documentation generation.
2. Automated Testing Prompts
# .prompt.md
## Write Unit Tests
For each service, generate Jest tests that cover success and failure paths.
Use this prompt to build solid, consistent unit test coverage across the codebase.
3. Refactoring Prompts
# .prompt.md
## Refactor for Clarity
Simplify code without changing functionality. Add inline comments to explain the final version.
Helps maintain code readability and assist teammates taking over sections of code.
How to Use Saved Prompts in GitHub Copilot Chat
- Once
.prompt.md
is committed, you can reference prompts directly in Copilot Chat:- Use the
#
command to insert a prompt by name (e.g.,#Write Unit Tests
). - Browse prompts interactively using the
/
command (e.g.,/Generate API Docs
).
- Use the
- No need to copy and paste—your best instructions are always accessible.
Extra Ideas for Prompt Sections
- Commit Messages: Guide contributors to write clear, Conventional Commit messages.
- Security Reviews: Instruct Copilot to check files for secrets or unsafe dependencies.
- UI Components: Prompt Copilot to generate React components using hooks and TypeScript.
Key Takeaway
Treat .prompt.md
as a recipe box for your favorite Copilot prompts. Keep them with your code, call them quickly via #
or /
, and maintain a streamlined, repeatable workflow.
This post appeared first on “Randy Pagels’s Blog”. Read the entire article here