GitHub Copilot: AI as Your Pair Programmer

ai dev productivity

GitHub Copilot launched as a technical preview, and it’s changing how developers write code. Trained on public code, it autocompletes functions, generates boilerplate, and sometimes surprises you. Here’s what you need to know.

What is Copilot?

Copilot is an AI pair programmer that suggests code as you type:

# Type a comment...
# Function to calculate fibonacci sequence

# Copilot suggests:
def fibonacci(n):
    if n <= 1:
        return n
    return fibonacci(n-1) + fibonacci(n-2)

It’s powered by OpenAI Codex, a GPT model trained on code.

How It Works

Your code + comments + context

    OpenAI Codex

    Code suggestions (ghost text)

    Tab to accept

Context Matters

Copilot uses your current file and open files as context:

# If you have User model defined elsewhere...
class User:
    def __init__(self, name, email):
        self.name = name
        self.email = email

# And you type:
def send_welcome_email(user

# Copilot knows about User and suggests:
def send_welcome_email(user: User) -> None:
    """Send a welcome email to the user."""
    send_email(
        to=user.email,
        subject="Welcome!",
        body=f"Hello {user.name}, welcome to our platform!"
    )

What It’s Good At

Boilerplate Code

# Type: "Django model for a blog post"
class BlogPost(models.Model):
    title = models.CharField(max_length=200)
    content = models.TextField()
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    published = models.BooleanField(default=False)
    
    def __str__(self):
        return self.title

Common Patterns

# Type: "async function to fetch data from API"
async def fetch_data(url: str) -> dict:
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as response:
            return await response.json()

Tests from Function Signatures

# Given:
def add(a: int, b: int) -> int:
    return a + b

# Type: "test" and Copilot suggests:
def test_add():
    assert add(1, 2) == 3
    assert add(-1, 1) == 0
    assert add(0, 0) == 0

Regex Patterns

# Type: "regex to match email addresses"
email_pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'

Type Conversions

# Type: "convert celsius to fahrenheit"
def celsius_to_fahrenheit(celsius: float) -> float:
    return celsius * 9/5 + 32

What It’s Not Good At

Domain-Specific Logic

# Your business rules
def calculate_premium(policy):
    # Copilot doesn't know your pricing model
    # Suggestions may be generic or wrong

Security-Sensitive Code

# Don't blindly accept auth code
def authenticate_user(request):
    # Review carefully - Copilot may suggest insecure patterns

Novel Algorithms

# If you're inventing something new, Copilot struggles
def my_novel_compression_algorithm(data):
    # Copilot has no training data for this

Using Copilot Effectively

Comments as Prompts

# Function to parse CSV file and return list of dictionaries
# with headers as keys

def parse_csv(filename: str) -> list[dict]:
    # Copilot generates the implementation

Function Signatures First

# Define signature, let Copilot fill in
def merge_sorted_lists(list1: list[int], list2: list[int]) -> list[int]:
    # Tab for suggestion

Iterate on Suggestions

Press Tab to accept
Press Ctrl+] to see next suggestion
Press Ctrl+[ to see previous suggestion
Press Ctrl+Enter to see all suggestions

Reject Bad Suggestions

Not every suggestion is good. Review before accepting:

# Copilot suggested:
def connect_to_database():
    return psycopg2.connect(
        host="localhost",
        password="admin123"  # NEVER accept hardcoded passwords
    )

Privacy and Licensing

What Data Goes to OpenAI?

Licensing Concerns

Copilot was trained on public GitHub code. Questions arise:

Telemetry

GitHub collects:

Review your settings for telemetry preferences.

Setup

VS Code

  1. Install the GitHub Copilot extension
  2. Sign in with GitHub
  3. Join the waitlist (technical preview)
// settings.json
{
    "github.copilot.enable": {
        "*": true,
        "yaml": false,
        "plaintext": false
    }
}

JetBrains IDEs

Plugin available for IntelliJ, PyCharm, WebStorm.

Neovim

-- Using copilot.vim
Plug 'github/copilot.vim'

The Productivity Question

When Copilot Helps

TaskSpeedup
Boilerplate3-5x faster
Common patterns2-3x faster
Tests2x faster
Docs2x faster

When It Doesn’t

TaskImpact
Novel algorithmsNeutral/Negative
Complex logicNeutral
DebuggingLimited help

Net Effect

Experienced developers report:

The Future

Copilot is version 1.0. Expect:

Final Thoughts

Copilot is a powerful autocomplete, not a replacement for understanding. Use it for:

Always review. Never blindly accept. Especially for security-sensitive code.

AI-assisted coding is here. Learn to use it well.


Your AI pair programmer. Tab to accept.

All posts