Week 02: AI copilots and comparison workflows
Augment, don’t automate!
Examples: Gemini, ChatGPT, and Claude are general-purpose assistants that can help with programming.
The CPTF framework for great prompts:
"Explain this Python dictionary comprehension step by step:
{word: len(word) for word in text.split() if len(word) > 3}"
"Write a Numpy-style docstring for this function that calculates the area of a circle given its radius."
"Convert this for loop into a more Pythonic equivalent using list comprehension or built-in functions."
"I'm getting a 'TypeError: unsupported operand type(s)' on line 15. Here's my code... What's the likely cause and how do I fix it?"
"I need to store student information (name, ID, grades). Should I use a list of dictionaries or create a Student class? Explain the pros and cons of each approach."
Our challenge: Create a Python function that takes a filename and returns the number of lines in the file, handling potential FileNotFoundError exceptions.
Let’s give the exact same prompt to all three AIs:
“Write a Python function called
count_linesthat takes a filename as a parameter and returns the number of lines in the file. Handle the case where the file doesn’t exist by returning 0. Include a NumPy-style docstring.”
"""), that occurs as the first statement in a module, function, class, or method definitionmake_greeting, is_even, and count_vowelsWhy integration matters
How it works:
Best practices:
Clear comments are key:
# Calculate the factorial of a positive integer
Descriptive function names:
calculate_factorial not calc_fact
Type hints help:
def factorial(n: int) -> int:
Your conversational partner
Common interaction modes (labels can change):
Your conversational partner
When to use each mode:
Building a Python utility with AI assistance:
# A function that calculates compound interestWhy use terminal-based AI?
agy from inside the repository you want it to inspect.copilot from inside the repository you want it to inspect.uv run --directory week02 python -m pytest tests/ -v.git diff before committing.Required working surfaces for this course:
After Lab 02:
AGENTS.mdYou just set up three agents. They can all read the same file.
AGENTS.md is an open format: a README written for coding agents instead of for peopleYou already have one. Your fork of is4010-labs contains an AGENTS.md telling any agent that tests, workflows, and lab instructions are read-only.
Some agents also look for a name of their own:
AGENTS.md, the common format, read by most tools including both CLIs you just installed.github/copilot-instructions.md, GitHub Copilot’s own custom-instructions file in VS CodeCLAUDE.md, read by Claude CodeThe practical rule: write AGENTS.md, then point the others at it.
AGENTS.md too, so the extra file is often unnecessaryAGENTS.md rather than a second copyCLAUDE.md contains @AGENTS.md and nothing elseDaily development:
Code review and submission:
Submission rule: Do not submit code you cannot explain and verify.
count_vowels task, then select, test, and revise an implementationweek02/lab02.py and week02/lab02_prompts.mdgit diff, push your work, and confirm the Lab 02 README badge is greenweek02/lab02.md for step-by-step instructionsIS 4010: App Dev with AI