0% found this document useful (0 votes)
106 views8 pages

VS Code GitHub Copilot Shortcuts Guide

Uploaded by

logeshkannanengr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views8 pages

VS Code GitHub Copilot Shortcuts Guide

Uploaded by

logeshkannanengr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

VS Code GitHub Copilot

Complete Workshop Reference & Command Guide

⌨️ Essential Shortcuts
Action Win/Linux Mac

Open Chat Ctrl+Alt+I ⌃⌘I

Inline Chat Ctrl+I ⌘I

Quick Chat Ctrl+Shift+Alt+L ⇧⌥⌘L

Agent Mode Ctrl+Shift+I ⇧⌘I

Accept Suggestion Tab Tab

Voice Chat Ctrl+I (hold) ⌘I (hold)

New Session Ctrl+N ⌘N

Dismiss Escape Escape

💬 Chat Modes & Models


▶ Ask Mode: Questions & explanations
▶ Edit Mode: Code modifications
▶ Agent Mode: Autonomous tasks
▶ Custom Modes: Specialized workflows

Model Selection
Fast Coding: GPT-4o, Claude Sonnet
Reasoning: o1-preview, Claude Opus
Math Support: KaTeX rendering enabled

Chat Navigation:
Use ↑/↓ arrows to navigate chat history
Edit previous prompts and revert changes
Clear session with /clear
🔧 Context & Variables
#codebase Auto-search workspace

#selection Current editor selection

#changes Git changes list

#problems Workspace errors/warnings

#fetch Web page content

#githubRepo GitHub repo search

#terminalLastCommand Last terminal output


#searchResults Search view results
#testFailure Failed test information

⚡ Slash Commands
/explain Explain code/concepts

/fix Fix errors & issues

/tests Generate test cases

/setupTests Setup test framework

/docs Documentation comments

/new Scaffold projects

/newNotebook Create Jupyter notebook

/search Generate search query

/startDebugging Debug configuration

/clear New chat session

/help Usage help


👥 Chat Participants
@github GitHub integration

@terminal Shell & terminal help

@vscode VS Code features

@workspace Workspace questions

GitHub Examples:
@github What PRs are assigned to me?
@github Show recent merged PRs
@github List issues by milestone

Terminal Examples:
@terminal list largest files
@terminal /explain top command
@terminal how to compress files?

🎯 Customization Setup
Instructions Files:
1 Run: Chat: New Instructions File

2 Choose workspace or user scope

3 Store in .github/instructions/

4 Add applyTo glob patterns

--- applyTo: "**/*.ts,**/*.tsx" description: "TypeScript standards" --- # Project Guidelines - Use interfaces for data structures - Prefer functional components - Always define
TypeScript types

Prompt Files:
1 Run: Chat: New Prompt File

2 Store in .github/prompts/

3 Execute with /prompt-name

4 Share with team via Git


🏆 Best Practices & Prompting Tips
▶ Start General: Begin broad, then add specific requirements
▶ Provide Examples: Show expected input/output formats
▶ Break Down Tasks: Complex requests → smaller sub-tasks
▶ Use Context: Reference files with #filename syntax
▶ Iterate & Refine: Build on previous responses
▶ Be Specific: Include language, framework, version details
▶ Add Constraints: Mention libraries to avoid/prefer
▶ Include Examples: Paste relevant code snippets

Good Prompting Examples:


Instead of: "Create a form"
Try: "Generate a React form component with validation using react-hook-form and yup. Include fields for name, email, phone. TypeScript types required."

Instead of: "Fix this error"


Try: "Fix this TypeScript error in my Express route handler: [paste error]. Using [Link] 18, Express 4.x."

Context Strategy
Use #codebase for automatic discovery • Drag & drop files • Include terminal output • Reference symbols with #SymbolName

🚀 Agent Mode Deep Dive


▶ Autonomous Planning: Breaks down complex tasks
▶ Multi-step Execution: Chains tools and operations
▶ Progress Monitoring: Tracks and iterates on results
▶ Tool Integration: File editing, terminal, search
▶ Error Recovery: Adapts when operations fail
▶ Context Awareness: Maintains task context

Available Tools:
editFiles Create/modify files runCommands Terminal execution

search File/code search runTests Test execution

runTasks VS Code tasks openSimpleBrowser Preview apps

Agent Mode Tips


Configure auto-approval for terminal commands • Use custom chat modes for specialized workflows • Enable MCP servers for extended capabilities
⚙️ Advanced Configuration
Key Settings:
Instructions:
[Link]
[Link]

Prompt Files:
[Link]
[Link]

Agent Mode:
[Link]
[Link]

"[Link]": { "src/frontend/instructions": true, "src/backend/instructions": false } "[Link]": { ".github/prompts": true,


"setup/**/prompts": true }

🔍 Debugging & Testing


▶ Debug Config: Auto-generate [Link]
▶ Test Generation: Unit & integration tests
▶ Error Analysis: Fix compilation errors
▶ Code Review: Automated suggestions
▶ Performance: Optimization recommendations

Terminal Commands:
copilot-debug python [Link]
copilot-debug node [Link]
copilot-debug --help

Test Coverage:
Use /tests on function selections
Generate tests for uncovered code
Set up frameworks with /setupTests
🔗 Workspace Integration
▶ Remote Indexing: GitHub-based search
▶ Local Indexing: Machine-stored cache
▶ Semantic Search: AI-powered file search
▶ Git Integration: Commit messages & PR descriptions
▶ Extension Support: Third-party tool integration

Source Control:
Auto-generate commit messages
Create PR titles and descriptions
Review uncommitted changes
Add commits as chat context

Performance Tip
Enable workspace indexing for faster, more accurate code search in large repositories

📋 Workshop Hands-on Activities


1 Setup: Install Copilot extension and sign in

2 Shortcuts: Practice Ctrl+Alt+I , Ctrl+I commands

3 Instructions: Create workspace instructions file

4 Prompting: Try different prompting techniques


5 Context: Use #codebase, #selection variables
6 Participants: Test @github, @terminal, @workspace
7 Agent Mode: Enable and configure tools
8 Customization: Create reusable prompt files
9 Integration: Enable workspace indexing
10 Testing: Generate tests with /tests command
🎓 Common Use Cases & Examples
Code Generation:
"Create a REST API endpoint for user authentication using [Link] and JWT. Include validation middleware and error handling."

Refactoring:
"Refactor this class-based React component to use hooks. Maintain the same functionality but improve performance."

Documentation:
"Generate comprehensive JSDoc comments for this TypeScript interface including parameter descriptions and examples."

Testing:
"Create unit tests for this utility function using Jest. Include edge cases and error scenarios."

Debugging:
"This async function is causing memory leaks. Help identify the issue and suggest fixes."
📚 Quick Reference Commands & Resources
File Management
▶ Chat: New Instructions File
▶ Chat: New Prompt File
▶ Chat: Configure Instructions
▶ Chat: Configure Prompt Files
▶ Chat: Attach Instructions
▶ Chat: Run Prompt

Navigation & Control


▶ Switch between chat modes
▶ Configure available tools
▶ Edit previous chat prompts
▶ Clear chat session
▶ Export chat history
▶ Sync settings across devices

Documentation Links
▶ Main: [Link]/docs/copilot
▶ Support: [Link]
▶ GitHub: [Link]/copilot
▶ Prompting: [Link]/prompt-engineering
▶ API: [Link]
▶ Community: [Link]/github/copilot-docs

VS Code GitHub Copilot Workshop Reference • A3 Format • 2025 Edition


Print this page as PDF using Ctrl+P → Save as PDF → A3 Landscape → Scale 85%

Common questions

Powered by AI

GitHub Copilot can suggest refactoring strategies that involve converting lifecycle methods of a class-based React component into hooks. A typical prompt could be "Refactor this class-based React component to use hooks. Maintain the same functionality but improve performance." This approach involves identifying lifecycle methods such as componentDidMount or componentDidUpdate and replacing them with equivalent hooks like useEffect. Hooks like useState replace the need for component-based state management. Ensuring performance improvements could involve employing useCallback or useMemo to prevent unnecessary re-renders. Copilot leverages the context provided by these detailed prompts to automate part of the transformation process, ensuring that functionality is preserved while performance is optimized .

GitHub Copilot's customization features enhance workflow efficiency by allowing developers to create reusable prompt files and instructions tailored to recurring programming tasks. Developers can store these prompts in designated directories and execute them with specific command triggers, reducing the need for repetitive input. For instance, by setting up reusable prompts like "Generate a React form component with validation," developers streamline the process of complex form creation across multiple projects. This approach is supported by file-specific instructions and the ability to attach or configure prompts as needed, ensuring that best practices and project standards are consistently applied .

GitHub Copilot aids in debugging tasks by providing suggestions and code insights that target common pitfalls such as memory leaks in asynchronous functions. Developers can input a prompt like "This async function is causing memory leaks. Help identify the issue and suggest fixes," which Copilot uses to analyze the function's patterns and suggest optimizations. It can identify incorrect use of asynchronous calls, such as leaving dangling promises or failing to manage resources properly, which often lead to memory leaks. Copilot then suggests code modifications to ensure resources are adequately released and promises are correctly handled, improving code efficiency and preventing memory exhaustion .

GitHub Copilot assists in generating REST API endpoints for user authentication by providing code suggestions directly integrated into development environments like VS Code. Developers can begin by prompting Copilot with a task description such as "Create a REST API endpoint for user authentication using Express.js and JWT. Include validation middleware and error handling." This prompt can guide Copilot to generate an appropriate starting point for the API, ensuring the inclusion of secure practices such as JWT for session handling, validation middleware for user input, and error handling for robustness . Best practices include integrating validation middlewares to check the accuracy and completeness of user inputs, using JWT for secure session management, and incorporating comprehensive error handling to manage exceptions gracefully during authentication processes .

When using GitHub Copilot to generate unit tests with the /tests command, it's important to ensure comprehensive test coverage, particularly for edge cases that may not be immediately apparent. Considerations include identifying potential boundary conditions and error scenarios within the code function, which should be explicitly defined in the testing prompts. By specifying these conditions, Copilot can generate tests that account for unusual or extreme inputs, thereby improving the robustness of the testing suite. Including edge cases in the test coverage ensures that the code will respond correctly under all possible conditions, ultimately maintaining the quality and reliability of the software .

Advanced configuration settings in GitHub Copilot play a pivotal role in optimizing Agent Mode by fine-tuning tool integration and facilitating autonomous planning processes. Settings such as chat.tools.terminal.autoApprove allow for the automated execution of terminal commands, which streamline workflow processes. Managing chat.instructionsFilesLocations and chat.promptFiles enhances operational efficiency by ensuring the right instructions and prompts are always accessible. These configurations allow Agent Mode to automate routine development tasks efficiently, while tool integration supports a seamless transition across different development steps without manual intervention, strengthening the capabilities for complex task planning and execution .

Semantic search within GitHub Copilot enhances code search functionality by using AI-powered techniques to understand the meaning and context of code snippets beyond basic keyword matching. This approach allows developers to find relevant code more efficiently in large repositories, even if the exact search terminology isn't used directly in the code. In terms of performance tips, enabling workspace indexing for semantic search locally ensures faster and more precise retrieval results, leveraging both local machine caching and cloud-based data when searching for complex queries across extensive codebases. This integration ensures that developers spend less time locating specific code, thereby improving overall productivity .

Context variables and slash commands significantly enhance GitHub Copilot's functionality by allowing developers to create highly specific and contextually aware prompts without extensive manual input. For example, using context variables like #codebase for automatic workspace discovery ensures that prompts are grounded in the specific code environments relevant to the task. Slash commands like /explain or /fix enable quick access to complex actions such as error resolution or code explanation, guiding Copilot to focus on immediate developer needs and integrate within their workflow seamlessly. This automation of contextually aware prompt inputs reduces overhead, allowing for faster problem resolution and continuous development momentum .

GitHub Copilot's tool integration and task automation features in Agent Mode are crucial for managing complex software development workflows by orchestrating a series of tool-based interventions. Agent Mode facilitates the chaining of operations such as file editing, terminal command execution, and code search, which aids in developing robust software solutions without manual intervention at every step. It supports multi-step executions that automate common tasks such as testing and debugging, with retry mechanisms and progressive task adjustments allowing for more adaptive development iterations. These aspects not only simplify the management of interrelated steps in software building but also enhance the speed at which these workflows are completed .

Agent Mode in GitHub Copilot enhances error recovery and maintains context awareness by structuring complex tasks into manageable execution steps and tracking their progress. When an operation fails, Agent Mode adapts by identifying the errors and suggesting corrective actions, leveraging integrated tools like file editing and terminal commands. It facilitates this by maintaining detailed context of the ongoing task, thus enabling seamless resume and adjustment of operations without losing historical progress or task context. The use of prompts and context-aware execution ensures that each step integrates and builds on the knowledge of previous actions, thus enhancing the robustness of the recovery process .

You might also like