← Back to AI Resources
🚀

GitHub Copilot Cheat Sheet

Shortcuts, tips, and best practices

Essential Shortcuts (VS Code)

Accept suggestion
Tab
Reject suggestion
Esc
Next suggestion
Alt]
Previous suggestion
Alt[
Show all suggestions
CtrlEnter
Accept word
Ctrl
Open Copilot Chat
CtrlI
Trigger suggestion
Alt\

Tips for Better Suggestions

1. Write Descriptive Comments First

Copilot reads your comments. The more specific, the better the code it generates.

// Function that takes an array of numbers and returns
// the sum of all even numbers greater than 10
function sumLargeEvens(numbers) {

2. Name Your Functions Well

Good function names give Copilot context about what you want.

// Bad: vague name
function process(data) {

// Good: specific name
function validateEmailAndSendWelcome(user) {

3. Provide Examples in Comments

Show Copilot what you expect with input/output examples.

// formatPrice(1234.5) → "$1,234.50"
// formatPrice(99) → "$99.00"
function formatPrice(amount) {

4. Set the Pattern, Let It Continue

Write the first item in a series, Copilot will continue the pattern.

const routes = [
{ path: '/home', component: Home },
// Copilot will suggest more routes...

5. Open Related Files

Copilot uses open tabs for context. Keep relevant files open.

⚠️ Always Review Copilot's Code

Copilot can generate code that looks right but has bugs, security issues, or uses outdated patterns. Never blindly accept suggestions—especially for authentication, database queries, or anything handling user input.

Copilot Chat Commands

/explain Explain selected code
/fix Fix bugs in selection
/tests Generate unit tests
/doc Add documentation
/simplify Simplify code
@workspace Ask about project

When Copilot Struggles

Complex Business Logic

Copilot doesn't know your specific requirements. Break complex logic into smaller, well-named functions.

Recent APIs or Libraries

Copilot's training data has a cutoff. It may suggest outdated patterns for newer tools. Check docs.

Custom/Internal Code

It can't know your internal APIs. Provide type hints or examples in comments.