Exercise 2¶
What is this exercise about¶
The goal of this homework is not to "fix code as fast as possible." Instead, you will practice:
- measured and reflective use of AI
- professional workflow with AI agents
- understanding an unfamiliar codebase
- comparing vague vs detailed prompts to AI
- AI productivity gains vs limitations
- using Git to clearly separate AI-generated code from human fixes
- thorough documentation of your interactions with AI
Please use the course materials, including sessions and the wiki, to help you complete this exercise.
General Instructions¶
All submitted work must be stored in your GitLab repository. Below it will be explained how to do that. For the repository it is important that:
- one exercise = one GitLab repository → each exercise gets its own GitLab repository
- your repository must be private
- your repository must be named exactly as specified (in the setup below); do not change the name or the upper-case/lower-case letters
- create commits frequently, at least one commit per question
- push your work frequently (this also is your backup if your laptop breaks)
- your repository must be up-to-date before the deadline
- you must double-check your repository in the web browser to make sure all your work is uploaded to the code.vt.edu server
- you must provide screenshots as proof when they are requested; screenshots are also committed to the repository
⚠️ Any screenshots must be taken by you on your laptop! Not following this is an Honor Code violation.
⚠️ You must run your code yourself! Not following this is an Honor Code violation.
0. Setup: Git and GitLab (10 points)¶
-
Create a new repository on GitLab at code.vt.edu:
-
in the top-left corner, click the "+" icon
- in the new menu that pops up, click "New project/repository"; a new page loads
-
in the new page, click the "Create black project" button; a new page loads:
- enter the "Project name":
cmda3634-ex2 - in the drop-down field "Pick a group or namespace", select your username
- the "Project slug" field should populate automatically after entering a project name; do not change the slug
- for the "Visibility level", select "private" (very important!)
- for the "Project configuration", select only "Initialize repository with README"
- enter the "Project name":
-
Add the instructor and TA to your repository as a member with Developer access. In the web browser with your new repository open:
-
in the left sidebar, hover the mouse cursor over "Manage"
- in the menu that pops up, click "Members"; a new page loads
- on the new page, click the button "Invite members"
- enter the
jrudi - select maximum role: "Developer"
- click the button "Invite"
- enter the
- repeat to invite a new member:
- enter the
jraind - select maximum role: "Developer"
- click the button "Invite"
- enter the
1. Understanding an existing codebase (AI assistant) (20 points)¶
You can find the source code files for this exercise in the folder exercises/02-code
Setup¶
-
Inside your submission repository:
-
create a new folder called
q1_code - copy the
main.gofile from02-code(course repo) intoq1_code - do not modify the code in this question
Your directory structure should now include:
q1_code/
(file copied from 02-code)
Use an AI assistant to understand the code¶
- Use an AI assistant in a web browser (e.g. ChatGPT, Claude, Gemini, ...).
- Copy-paste the contents of the main source file (
main.go) into the assistant.
Prompt 1: What does the code do?¶
Ask the assistant to:
- explain the purpose of the code
- describe its high-level behavior
- summarize inputs, outputs, and main steps
Create a file called q1_summary.md in which you document document:
- the exact prompt(s) you used
- the full AI response(s)
Prompt 2: Find bugs or issues¶
Follow up with a second prompt asking the assistant to:
- identify bugs, weaknesses, or potential issues
- comment on robustness, error handling, or design problems
Create a file called q1_issues.md and document:
- the exact prompt(s) you used
- the full AI response(s)
Mandatory AI documentation ⚠️¶
Use the following format exactly in all AI documentation files:
## Prompt
(copy your full prompt text here)
## AI Response
(copy the full AI response here)
If you use multiple prompts, repeat the sections in order.
⚠️ Do not summarize, paraphrase, or omit any prompts or AI outputs.
2. Fix issues using an AI agent (vague prompt) (30 points)¶
In this question, you will:
- use Git to track AI vs human changes
- intentionally use a vague prompt
- observe how an AI agent behaves with minimal guidance
You can find the source code files for this exercise in the folder exercises/02-code
You can find files to test the program in the folder exercises/02-code/test_files
Setup¶
- create a new folder
q2_code - copy the
main.gofile from02-code(course repo) intoq1_code - create a new subfolder
q2_code/test_files; then copy all test files from02-code/test_files(course repo) toq2_code/test_files - commit the initial version of the file
q2_code/main.gowith Git
⚠️ You must work only inside q2_code for this question.
Use an AI coding agent¶
- Use an AI coding agent integrated into your editor or terminal (e.g. OpenCode, GitHub Copilot agent mode)
- The agent must be able to:
- read files
- modify files
- run commands
Prompt the agent (vague on purpose)¶
Give the agent one vague instruction to fix some issues in the code.
Do not mention:
- issues found in Question 1
- specific bugs
- desired design choices
The agent should discover issues on its own.
Testing the result¶
- Run the program using the command (inside
q2_codefolder):go run main.go - When the program asks you for input a path, then enter the subfolder
test_files - You are not required to match a specific output
-
Your responsibility is to:
-
ensure the program starts running
- check if the program behaves reasonably
- note any remaining problems
Mandatory Git rules ⚠️¶
You must follow all rules below:
-
Every AI-generated change:
-
must be committed separately
-
must include the prompt text in the commit message
-
Every human modification:
-
must be a separate commit
-
must clearly explain why the change was needed
-
Perform at least 2 AI → human iteration cycles
Example (illustrative only) output from git log:
commit a1f3u9e
AI: attempt to fix issues
Prompt: "Please improve this code."
commit b2r8p11
Human: fix incorrect logic and restore functionality
...
You decide your own commit messages, but the separation must be clear.
Mandatory AI documentation ⚠️¶
Create a file q2_ai_log.md.
For each AI interaction, document:
- the prompt
- the AI's response
Use the same formatting as in Question 1.
3. Fix issues using an AI agent (detailed prompts) (30 points)¶
This question repeats the workflow of Question 2, but with intentional, structured prompting.
You can find the source code files for this exercise in the folder exercises/02-code
You can find files to test the program in the folder exercises/02-code/test_files
Setup¶
- create a new folder
q3_code - copy the
main.gofile from02-code(course repo) intoq1_code - create a new subfolder
q3_code/test_files; then copy all test files from02-code/test_files(course repo) toq3_code/test_files - commit the initial version of the file
q3_code/main.gowith Git
⚠️ You must work only inside q3_code for this question.
Use an AI coding agent with detailed prompts¶
- Use the same type of AI agent as before
- This time, use your findings from Question 1 about issues in the code
Rules for prompting¶
- Fix one issue per prompt
- Fix at least 3 issues
- Each prompt must:
- describe the issue clearly
- state what behavior should improve
- Do not bundle multiple fixes into one request
Testing the result¶
- Run the program using the command (inside
q3_codefolder):go run main.go - When the program asks you for input a path, then enter the subfolder
test_files - You are not required to match a specific output
-
Your responsibility is to:
-
ensure the program starts running
- check if the program behaves reasonably
- note any remaining problems
Mandatory Git rules ⚠️¶
Apply the same mandatory Git rules as in Question 2:
- AI commits and human commits must be separate
- prompts must appear in AI commit messages
- at least 2 AI → human cycles
Mandatory AI documentation ⚠️¶
Create q3_ai_log.md and document all AI interactions using the same format as in
Questions 1 and 2.
4. Final README and reflection (10 points)¶
Update the README.md file in your submission repository. (If no file named
README.md exists in your repository, then create one.)
Requirements¶
-
Remove all template text
-
Add a section listing:
- Question 1, Question 2, Question 3
-
Links to:
- code folders
- AI documentation files
-
At the bottom, write a short reflection (2 paragraphs) focused on:
- your preferred prompt workflow and how you like phrasing your prompts
- cognitive overhead introduced by AI
- how your trust in AI changed during the exercise
README formatting suggestion¶
Example of a README.md file:
# Exercise 2
## Contents
1. Question: Code understanding with AI assistants
- [code](q1_code/)
- [summary](q1_summary.md)
- [issues](q1_issues.md)
2. Question: Vague prompts with AI agents
- [code](q2_code/)
- [AI log](q2_ai_log.md)
3. Question: Detailed prompts with AI agents
- [code](q3_code/)
- [AI log](q3_ai_log.md)
## Reflection
(your reflection text here)
Submission¶
On Canvas¶
In your web browser, go to the page of your GitLab repository for this exercise. Then copy the URL from the address bar of your web browser. Submit this URL to Canvas.
Commit and push all the screenshot files to your repository of this exercise.
Congrats! You're done! 🍪