top of page

Github Copilot - Across Environments

Code Completion with GitHub Copilot


Supported Languages (High Priority):

  • Python

  • JavaScript

  • Java

  • TypeScript

  • Ruby

  • Go

  • C#

  • C++

Note: Also supports many other languages, but above are strongest.


Auto Suggestions (Ghost Text):

  • Real-time suggestions while typing

  • Can:

    • Complete a line

    • Generate full code blocks

  • Actions:

    • Accept → Tab

    • Ignore → keep typing

  • Saves time on:

    • Syntax

    • Logic

    • Repetitive code


Multiple Suggestions Pane:

  • Shows alternative solutions

  • Navigate:

    • Windows/Linux → Alt + ] / Alt + [

    • Mac → Option + ] / Option + [

  • Helps:

    • Compare approaches

    • Choose best implementation quickly


Adaptation to Coding Style:

Copilot learns from your codebase:

  • Naming conventions (variables, functions)

  • Formatting (indentation, brackets)

  • Comment style (inline, block, docstrings)

  • Design patterns used in project

  • Method implementation patterns


Comments → Key for Better Suggestions


Copilot uses comments via:

  • NLP (Natural Language Processing)

  • Contextual analysis


Types of Comments Used:

  • Inline comments

  • Block comments

  • Docstrings

  • TODO comments

  • API documentation


Comment-Driven Code Generation:

  1. Function Implementation

    • Comment → full function generated

  2. Code Completion

    • More accurate suggestions

  3. Variable Naming

    • Suggests meaningful names

  4. Algorithm Selection

    • Follows described logic (e.g., bubble sort)


Exam Summary (Important):

  • Ghost text = real-time AI suggestions

  • Multiple suggestions = compare solutions

  • Copilot adapts to your coding style

  • Comments significantly improve output quality

  • Comments + context = best results

GitHub Copilot Chat


What is Copilot Chat:

  • AI conversational assistant inside IDE

  • Uses natural language to:

    • Generate code

    • Debug

    • Explain code


Main Use Cases:

  1. Code Generation

    • Create:

      • Algorithms

      • SQL queries

      • Data structures

    • Example:

      • “Create bubble sort in Python”

  2. Debugging

    • Analyze errors and suggest fixes

    • Can explain issues step-by-step

    • Works well with inline chat on selected code

  3. Code Explanation

    • Explains complex code

    • Breaks down logic

    • Suggests improvements


Improving Responses (Very Important):


Scope Referencing:

  • #file:filename → focus on specific file

  • @workspace → entire project

Examples:

  • #file:controller.js explain this

  • @workspace where is calculate function


Slash Commands (Must Know):

  • /doc → add documentation

  • /explain → explain code

  • /fix → fix errors

  • /generate → generate code

  • /optimize → improve performance

  • /tests → create tests

Tip: Slash commands = better + faster responses


Model Selection:


Standard Models:

  • Example: GPT-4o

  • Fast, general tasks

  • 1 PRU per request


Premium Models:

  • Example: o1-preview, o1-mini

  • Better for complex reasoning

  • 2 PRUs per request


Exam Tip:

  • Use premium only for complex problems


Copilot Agents:

  • @workspace → full project context

  • @workspace /new → create new project

  • @terminal → terminal help

  • @vscode → IDE help


Feedback System:

  • 👍 Helpful response

  • 👎 Not helpful

  • Improves Copilot over time


Exam Summary (Must Remember):

  • Copilot Chat = interactive AI assistant

  • Key features:

    • Code generation

    • Debugging

    • Code explanation

  • Improve output using:

    • Scope (#file, @workspace)

    • Slash commands

  • Agents = context-specific assistance

  • PRUs = cost per request (1 vs 2+)

GitHub Copilot on GitHub.com


Where Copilot is Used on GitHub.com:

  • Repository pages

  • Issues & Pull Requests

  • Discussions

  • Code review


Key Capabilities:


Repository Exploration:

  • Explain code, files, and structure

  • Generate project summaries

  • Create/improve documentation (README, API docs)


Pull Request Assistance:

  • Generate PR summaries

  • Suggest improvements

  • Help resolve merge conflicts

  • Suggest documentation updates

Exam Tip:

  • PR summaries = 1–2 PRUs


Issue Management:

  • Analyze issues

  • Suggest solutions

  • Create reproduction steps


Code Review & Collaboration:

  • Generate review comments

  • Detect:

    • Security issues

    • Performance problems

  • Improve code quality

Exam Tip:

  • Code review = 1–3 PRUs


GitHub Actions Error Explanation:

  • Analyze failed workflows

  • Identify root cause

  • Suggest fixes

  • Provide best practices


Agent Tasks:

  • Run tasks in background

  • Help automate workflows


Exam Summary (Must Remember):

  • Copilot works directly on GitHub web interface

  • Helps with:

    • Repo understanding

    • PRs

    • Issues

    • Code review

    • Actions errors

  • Key benefits:

    • Faster collaboration

    • Reduced manual work

    • Better code quality

  • PRUs used for advanced tasks (PRs, reviews, etc.)

GitHub Copilot CLI


What is Copilot CLI:

  • AI assistant in the terminal (command line)

  • Helps:

    • Explain commands

    • Suggest shell commands

    • Interact with files/projects

  • Uses GitHub authentication

  • Works independently from GitHub CLI


Installation & Launch:


Install:

  • brew install copilot-cli

  • or install script

Run:

  • copilot → interactive mode

  • copilot -i "prompt" → one-shot mode

Interactive Mode:

  • Chat-like experience in terminal

  • Can:

    • Ask questions

    • Generate commands

    • Revise suggestions

  • Must trust directory (security check)


Key Features:


Natural Language:

  • Ask tasks in plain English

  • Example: “find large files and delete them”

Context:

  • Use @file to select file context

Important Slash Commands:

  • /help → show commands

  • /explain → explain command

  • /suggest → suggest command

  • /revise → improve suggestion

  • /feedback → send feedback

  • /exit → exit session

  • /model → choose AI model

Note:

  • Slash commands = required for control/config


Example Workflows:

  • Explain command → /explain git reset

  • Suggest command → “find .log files”

  • Revise → refine previous output


Configuration:


Controlled by:

  • Slash commands

  • Permissions

Key Controls:

  • Trusted directories

  • Tool permissions (run/edit commands)

  • Path & URL access

Best Practices:

  • Use interactive mode for exploration

  • Use one-shot mode for quick tasks

  • Always review commands before running

  • Combine with GitHub CLI (gh)

  • Use slash commands for structured control


Exam Summary (Must Know):

  • Copilot CLI = AI in terminal

  • Two modes:

    • Interactive (copilot)

    • One-shot (copilot -i)

  • Slash commands = control system

  • Natural language → command generation

  • Security = trust directories + permissions

 
 
bottom of page