GitHub Copilot Cookbook
Learn how to use GitHub Copilot to accomplish specific tasks.
Spotlight

Implementing a feature from a GitHub Issue
Give a GitHub issue to GitHub Copilot CLI, then steer the conversation to implement the feature.

Diagnosing CI test failures
Use Copilot CLI to pull CI logs, correlate failures to local code, and fix issues without leaving the terminal.

Improving code readability and maintainability
Copilot Chat can suggest ways to make your code easier to understand and maintain.
Explore 35 examples
Creating templates
Copilot Chat can help you create templates to streamline your workflow and ensure consistency across your projects.Communicate effectivelyAuthor and optimize with CopilotScale institutional knowledgeChatTriage and summarize repository activity
Copilot can extract key information from repositories you follow to keep you up-to-date on recent activity.Communicate effectivelyAuthor and optimize with CopilotScale institutional knowledgeCLISynthesizing research
Copilot Chat can help you synthesize research findings and insights from multiple sources into a cohesive summary.Communicate effectivelyAuthor and optimize with CopilotScale institutional knowledgeChatCreating diagrams
GitHub Copilot Chat can help you create diagrams to better understand your data and communicate insights.Communicate effectivelyVisualize dataScale institutional knowledgeAuthor and optimize with CopilotChatGenerating tables
Copilot Chat can help you create tables to organize information and present it clearly.Communicate effectivelyAuthor and optimize with CopilotScale institutional knowledgeChatDebugging invalid JSON
Copilot Chat can identify and resolve syntax errors or structural issues in JSON data.Debugging codeAuthor and optimize with CopilotImprove quality and maintainabilityChatHandling API rate limits
Copilot Chat can help handle API rate limits by suggesting code that detects them and implements retry logic.Debugging codeAuthor and optimize with CopilotImprove quality and maintainabilityChatDiagnosing CI test failures
Use Copilot CLI to pull CI logs, correlate failures to local code, and fix issues without leaving the terminal.Debugging codeAuthor and optimize with CopilotImprove quality and maintainabilityCLIExploring potential feature implementations
Copilot Chat can help explore different approaches for implementing a single feature.Functionality analysisAuthor and optimize with CopilotScale institutional knowledgeChatAnalyzing and incorporating user feedback
Copilot Chat can enhance the process of incorporating user feedback into your project.Functionality analysisAuthor and optimize with CopilotScale institutional knowledgeChatImplementing a feature from a GitHub Issue
Give a GitHub issue to GitHub Copilot CLI, then steer the conversation to implement the feature.Author and optimize with CopilotCLIImproving code readability and maintainability
Copilot Chat can suggest ways to make your code easier to understand and maintain.Refactoring codeAuthor and optimize with CopilotImprove quality and maintainabilityChatFixing lint errors
Copilot Chat can suggest ways to fix issues identified by a code linter.Refactoring codeAuthor and optimize with CopilotImprove quality and maintainabilityChatRefactoring for performance optimization
Copilot Chat can suggest ways to speed up slow-running code.Refactoring codeAuthor and optimize with CopilotImprove quality and maintainabilityChatRefactoring for environmental sustainability
Copilot Chat can suggest ways to make code more environmentally friendly.Refactoring codeImprove quality and maintainabilityAuthor and optimize with CopilotChatRefactoring to implement a design pattern
Copilot Chat can suggest design patterns that you can use to improve your code.Refactoring codeAuthor and optimize with CopilotImprove quality and maintainabilityChatRefactoring data access layers
Copilot Chat can suggest ways to decouple your data access code from your business logic, making an application easier to maintain and scale.Refactoring codeAuthor and optimize with CopilotImprove quality and maintainabilityChatDecoupling business logic from UI components
Copilot Chat can help you separate your business logic from your user interface code, making it easier to maintain and scale your application.Refactoring codeAuthor and optimize with CopilotImprove quality and maintainabilityChatHandling cross-cutting concerns
Copilot Chat can help you avoid code that relates to a concern other than the core concern of the method or function in which the code is located.Refactoring codeAuthor and optimize with CopilotImprove quality and maintainabilityChatSimplifying complex inheritance hierarchies
Copilot Chat can help you to refactor code to avoid classes with multiple layers of inheritance.Refactoring codeAuthor and optimize with CopilotImprove quality and maintainabilityChatFixing database deadlocks or data integrity issues
Copilot Chat can help you avoid code that causes slow or blocked database operations, or tables with missing or incorrect data.Refactoring codeAuthor and optimize with CopilotImprove quality and maintainabilityChatTranslating code to a different programming language
Copilot Chat can help you rewrite code to perform the same operations but in a different programming language.Refactoring codeAuthor and optimize with CopilotImprove quality and maintainabilityChatFiling issues without breaking your flow
When something catches your attention mid-task, use Copilot CLI to file a GitHub issue with code context, linked PRs, and labels, then get back to what you were doing.Documenting codeAuthor and optimize with CopilotCLIDocumenting legacy code
Copilot Chat can help with documenting legacy code.Documenting codeAuthor and optimize with CopilotScale institutional knowledgeChatExplaining legacy code
Copilot Chat can help with explaining unfamiliar code.Documenting codeAuthor and optimize with CopilotScale institutional knowledgeChatExplaining complex algorithms or logic
Copilot Chat can help add clear and concise documentation on complex algorithms or logic.Documenting codeAuthor and optimize with CopilotScale institutional knowledgeChatSyncing documentation with code changes
Copilot Chat can help with keeping code documentation up-to-date.Documenting codeAuthor and optimize with CopilotScale institutional knowledgeChatWriting discussions or blog posts
Copilot Chat can help you generate ideas, outline, or draft discussions or blog posts.Documenting codeAuthor and optimize with CopilotScale institutional knowledgeChatGenerating unit tests
Copilot Chat can help with generating unit tests for a function.Testing codeAuthor and optimize with CopilotImprove quality and maintainabilityChatCreating mock objects to abstract layers
Copilot Chat can help with creating mock objects that you can use for unit tests.Testing codeAuthor and optimize with CopilotImprove quality and maintainabilityChatCreating end-to-end tests for a webpage
Copilot Chat can help with generating end-to-end tests.Testing codeAuthor and optimize with CopilotImprove quality and maintainabilityChatUpdating unit tests to match code changes
Copilot Chat can help with updating your tests.Testing codeAuthor and optimize with CopilotImprove quality and maintainabilityChatSecuring your repository
Copilot Chat can help you to secure your repository and your code.Security analysisAuthor and optimize with CopilotImprove quality and maintainabilityChatManaging dependency updates
Copilot Chat can help you get set up with Dependabot to streamline dependency updates.Security analysisAuthor and optimize with CopilotImprove quality and maintainabilityChatFinding existing vulnerabilities in code
Copilot Chat can help find common vulnerabilities in your code and suggest fixes.Security analysisAuthor and optimize with CopilotImprove quality and maintainabilityChat