iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

GitHub Copilot

GitHub Copilot lives inside VS Code as a pair of features: inline suggestions (ghost text as you type) and Copilot Chat (a side panel and inline chat). Used well it accelerates boilerplate, helps explore unfamiliar APIs, writes test scaffolds, and refactors small blocks. Used badly it hallucinates plausible-but-wrong code.

Configure, prompt, and stay productive with Copilot

EXAMPLE
// ===== 1. Install + minimum settings =====
// Extensions: GitHub.copilot, GitHub.copilot-chat
// Sign in: Command Palette -> 'GitHub Copilot: Sign in'

// settings.json — sensible defaults
{
  "github.copilot.enable": {
    "*": true,
    "plaintext": false,
    "markdown": true,
    "yaml": true,
    "scminput": false                  // do not autocomplete commit messages
  },
  "github.copilot.editor.enableAutoCompletions": true,
  "github.copilot.chat.localeOverride": "en",
  "editor.inlineSuggest.suppressSuggestions": false,

  // Per-language tuning (treat tests/SQL as places where you write more)
  "[sql]":         { "editor.inlineSuggest.enabled": false },
  "[plaintext]":   { "editor.inlineSuggest.enabled": false }
}

// ===== 2. Keyboard shortcuts you actually use =====
// Tab          accept suggestion
// Esc          dismiss
// Alt+]        next suggestion
// Alt+[        previous suggestion
// Ctrl+Enter   open the suggestion list (multiple proposals)
// Ctrl+I       inline chat in the editor (refactor selection, add tests, etc.)

// ===== 3. Make suggestions useful — context is everything =====
// Copilot reads:
//  - open tabs (related files)
//  - the function above the cursor
//  - imports
//  - leading comments
// Trick: write a clear leading comment with intent + constraints.
//
// Example: turn vague intent into precise spec, then accept.
// '// returns the SHA-256 of the file at filePath using a streaming hash,
// // throws if the file is missing, never loads more than 64KB into memory'
// function hashFile(filePath: string): Promise<string> { /* accept Copilot */ }

// ===== 4. Copilot Chat tasks that pay off =====
// /tests                   - generate Jest/Vitest/Pytest scaffolds for selection
// /fix                     - propose a fix for highlighted error
// /explain                 - paste a gnarly regex or SQL, get a plain-English read
// /doc                     - JSDoc / TSDoc / docstring for function under cursor
// 'refactor to use map/filter instead of for loop'
// 'add a 3-second timeout to this fetch call'
// 'translate this jQuery to vanilla DOM'

// ===== 5. Guardrails =====
// - Disable in repos that require strict licensing review.
// - Treat output as a junior PR: review it before commit.
// - Never accept code that you cannot explain line by line.
// - Pair it with type checking + tests — Copilot's confidence is uncorrelated with correctness.

// ===== 6. Privacy & exclusions =====
// .copilot/exclude  or org-level 'Content Exclusion' to keep secrets out of suggestions.
// settings.json -> 'github.copilot.advanced': { ... } for fine-grained controls.

Why it matters

Copilot is best when you write the comment first. A two-line preamble with intent, edge cases, and constraints gets a near-correct suggestion that is worth tab-accepting; a bare function name gets a plausibly-named-but-wrong body. The prompt is the function signature in disguise.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
// AI pair-programming.
//   Tab    — accept suggestion
//   Alt+]  — next suggestion
//   Ctrl+I — Copilot inline chat
Try it Yourself »

Discussion

Loading…