IS4010: AI-Enhanced Application Development

Week 2: Meet Your AI Co-Pilots

Brandon M. Greenwell

Session 1

Meet your AI co-pilot: github copilot

What is github copilot?

  • Think of it as an autocomplete on steroids, running directly inside vs code.
  • It suggests code as you type, from single lines to entire functions.
  • It was trained on billions of lines of public code from github, so it has seen almost every problem before.
  • Our goal is to learn how to use it as an effective partner to write better code, faster.

How does it work?

  • Copilot’s most important input is context.
  • It analyzes the code in your current file and any other files you have open.
  • Most importantly, it reads the comments and function names you write.
  • Key takeaway: writing clear, descriptive comments right before you start coding a function is the best way to get high-quality suggestions.

Best practices: being the pilot

  • You are always in charge. Never blindly accept code that you don’t understand.
  • Tab through suggestions. Copilot often provides multiple options. Use alt + ] (or option + ] on mac) to cycle through them.
  • Read and understand the code. Before accepting a suggestion, read it to ensure it does what you want and that you understand how it works.
  • Use it for boilerplate. Let copilot write repetitive code (e.g., setting up a class, writing a loop) so you can focus on the creative problem-solving parts.

A quick note on docstrings

  • Before our lab, we need to introduce a key concept: the docstring.
  • A docstring is a string literal, enclosed in triple quotes ("""), that occurs as the first statement in a module, function, class, or method definition.
  • Its purpose is to explain what the code does.
  • We are learning about them now because they are the primary way you will communicate your intent to AI assistants. A good docstring leads to good AI-generated code.

Our docstring style: numpy

  • There are several popular styles for writing docstrings. In this course, we will use the numpy style.
  • It is clean, readable, and works very well with automated documentation tools.
  • Here is a quick example of the structure:
def add(num1, num2):
    """
    Add two numbers together.

    Parameters
    ----------
    num1 : int
        The first number.
    num2 : int
        The second number.

    Returns
    -------
    int
        The sum of the two numbers.
    """
    return num1 + num2

Introducing lab 02 (part 1)

  • Your next lab assignment will give you hands-on practice.
  • The first part is the “copilot driving school.”
  • Objective: you will be given a python file with several function definitions and numpy-style docstrings. Your task is to use github copilot to generate the code for each function.

Session 2

Advanced assistance & prompt engineering

Copilot vs. conversational AI

  • It’s important to know which tool to use for which task.
  • Github copilot: is an inline assistant. It lives inside your code file and is best for autocompletion and generating code in the moment.
  • Gemini (and other llms): is a conversational partner. You interact with it through a chat interface. It is best for asking questions, getting explanations, and creative tasks.

What can you ask gemini?

  • “Explain this complex function to me like i’m a beginner.”
  • “Find the bug in this piece of python code.”
  • “Refactor this code to be more clear and ‘pythonic’.”
  • “Write a numpy-style docstring for this python class.”
  • “How would I translate this python function to rust?”
  • …and much more.

The art of the prompt

  • The quality of the ai’s answer depends entirely on the quality of your question. Remember: garbage in, garbage out.
  • A great prompt has four key ingredients:
    1. Context: provide the code you are asking about. “Here is my python function…”
    2. Persona: tell the ai what role to play. “Act as a senior software developer reviewing my code.”
    3. Task: state a clear, specific goal. “Find any potential bugs and suggest improvements.”
    4. Format: define how you want the answer structured. “Provide your answer as a list.”

Terminal-based AI assistants

  • Beyond web interfaces, AI assistants are now available directly in your terminal
  • Gemini CLI: Google’s command-line interface for Gemini AI
  • Claude Code: Anthropic’s premium CLI tool (paid)
    • More advanced features and integrations
    • Popular in professional development environments

Why use terminal-based AI?

  • Stay in your workflow: No need to switch between browser and terminal
  • Code context: Easily paste code snippets and file contents
  • Quick queries: Fast answers to debugging questions
  • Privacy: Some tools offer better data handling than web versions
  • Integration: Can be combined with other command-line tools

Choosing your AI toolkit

  • GitHub Copilot: Best for inline code suggestions (required for this course)
  • Gemini web/CLI: Great for conversational help and explanations (free options available)
  • Claude Code: Professional-grade terminal assistant (paid, but powerful)
  • Recommendation: Start with the free tools, upgrade as your needs grow
  • Remember: The tool doesn’t make you a better programmer - understanding and practice do!

Introducing lab 02 (part 2)

  • The second part of your lab is the “prompt engineering challenge.”
  • Objective: you will be given several buggy or confusing python code snippets. Your task is to use gemini to debug, refactor, and document them by writing high-quality, effective prompts.
  • All instructions will be in labs/lab02/README.md.