Project Autonomy #1: The Spark of Intelligence - A Personalized Boxing Workout Generator
Posted by Ray Thurman on 08/14/2025

Generic workout apps are boring. They give you cookie-cutter plans that don't know your skill level, your goals, or how much time you have. They lack intensity and intelligence. Today, we're going to fix that. We're going to build our own AI coach.
Welcome to Project Autonomy, our 5-part series on building a personal AI agent from the ground up. In this first round, we're stepping into the ring and forging a real tool: an AI-Powered Boxing Workout Generator. By the end of this tutorial, you will have a Python script that asks for your skill level, workout duration, and focus area, then generates a unique, structured boxing workout, saving it as a clean Markdown file.
This is the first bell. Let's get to work.
Your Corner: Setup and Configuration π οΈ
Every fighter needs a solid corner. For us, that means setting up our development environment correctly from the start.
1. Prerequisites
- Python 3.12+: Make sure Python is installed on your system.
- Google Gemini API Key: You'll need an API key to access the AI's intelligence. Get your free key from Google AI Studio.
2. Install Your Gear (Libraries)
We need two Python libraries. Open your terminal and run this command:
uv add google-generativeai python-dotenv
- google-generativeai: The official library to connect with the Google Gemini API.
- python-dotenv: A pro utility for managing secret API keys without hardcoding them into your script.
3. Prepare Your Workspace
In a new project folder, create two files:
- main.py: This is where our script's logic will live.
- .env: This file will securely store our API key.
Open the .env file and add your key. Replace the placeholder with your actual key from Google AI Studio.
GOOGLE_API_KEY="YOUR_GEMINI_API_KEY_HERE"
The Game Plan: Designing the Prompt π§
For this agent, the prompt is the entire game plan. Itβs how we coach the AI to give us exactly what we need. A powerful prompt is the difference between a sloppy combo and a technical knockout.
Here's the blueprint for our workout prompt:
- Persona: We'll tell the AI who it is. "You are an elite, world-class boxing coach..."
- Task: Define the mission clearly. "...create a unique, structured, and challenging boxing workout."
- Variables for Personalization: We'll use placeholders that our script will fill with user input:
- {skill_level}: (Beginner, Intermediate, Advanced)
- {duration_minutes}: (e.g., 30, 45, 60)
- {focus}: (e.g., Footwork, Power Punching, Endurance, Defensive Drills)
- Formatting Rules: This ensures a clean, readable output. We'll command the AI to use Markdown for structure.
- Use an H1 heading for the workout title.
- Use H2 headings for each section: Warm-Up, Shadow Boxing, Heavy Bag Drills, Conditioning, and Cool-Down.
- Use bullet points for specific drills, including rounds, times, and rest periods.
- Include a final "Coach's Tip" section for extra motivation or technique advice.
The Code: Unleash Your AI Coach
Now, let's write the script in main.py. The flow is direct and powerful: get the fighter's stats, build the game plan (prompt), send it to the AI, and save the result to a file.
Here is the complete, commented script.
import os
from datetime import datetime
import google.generativeai as genai
from dotenv import load_dotenv
def main():
"""
Main function to run the AI Boxing Workout Generator.
"""
# --- 1. Configuration ---
# Load the secret API key from the .env file
load_dotenv()
try:
# Configure the Gemini API with the loaded key
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
except TypeError:
print(
"β ERROR: GOOGLE_API_KEY not found. Make sure you have a .env file with your key."
)
return
# --- 2. User Input ---
print("π₯ Welcome to the AI Boxing Workout Generator! π₯")
skill_level = input("Enter your skill level (Beginner, Intermediate, Advanced): ")
duration_minutes = input("Enter workout duration in minutes (e.g., 30, 45, 60): ")
focus = input(
"Enter your focus for today (e.g., Footwork, Power Punching, Endurance): "
)
if not all([skill_level, duration_minutes, focus]):
print("β ERROR: All fields are required. Please try again.")
return
print(
f"\nπ₯ Generating a {skill_level} workout for {duration_minutes} minutes focused on {focus}... Stand by."
)
# --- 3. Prompt Engineering ---
# This is the blueprint for the AI's response.
prompt = f"""
You are an elite, world-class boxing coach. Your task is to create a unique, structured, and challenging boxing workout based on my specifications.
Do not use the web, generate this based on your expert internal knowledge.
**Fighter Profile:**
- Skill Level: {skill_level}
- Workout Duration: {duration_minutes} minutes
- Primary Focus: {focus}
**Workout Structure Requirements:**
- Output must be in Markdown format.
- Start with a motivating H1 title for the workout.
- Create sections using H2 headings for: Warm-Up, Shadow Boxing, Heavy Bag Drills (or Bodyweight Drills if no bag is needed), Conditioning, and Cool-Down.
- Under each section, list specific exercises or drills as bullet points.
- For each drill, specify the number of rounds, round duration, and rest period (e.g., "* Jab-Cross-Hook (3 rounds x 3 minutes, 1 minute rest)").
- Conclude with an H2 heading for "Coach's Tip" with a piece of motivational or technical advice.
"""
# --- 4. AI Model Interaction ---
# Initialize the generative model
model = genai.GenerativeModel("gemini-2.5-flash")
# Generate the workout plan from the prompt
try:
response = model.generate_content(prompt)
workout_text = response.text
except Exception as e:
print(f"β ERROR: Failed to generate content. Details: {e}")
return
# --- 5. File Output ---
# Create a clean filename
filename = f"boxing_workout_{focus.replace(' ', '_').lower()}_{datetime.now().strftime('%Y%m%d')}.md"
try:
with open(filename, "w", encoding="utf-8") as f:
f.write(workout_text)
print(f"\nβ
SUCCESS! Your personalized workout plan is saved as '{filename}'")
print("Now go get to work!")
except OSError as e:
print(f"β ERROR: Failed to save the file. Details: {e}")
if __name__ == "__main__":
main()
The Result: Your Personalized Game Plan π
Run the script from your terminal (python main.py). Answer the questions, and watch your AI coach get to work.
Terminal Output:
π₯ Welcome to the AI Boxing Workout Generator! π₯
Enter your skill level (Beginner, Intermediate, Advanced): Intermediate
Enter workout duration in minutes (e.g., 30, 45, 60): 45
Enter your focus for today (e.g., Footwork, Power Punching, Endurance): Power Punching
π₯ Generating a Intermediate workout for 45 minutes focused on Power Punching... Stand by.
β
SUCCESS! Your personalized workout plan is saved as 'boxing_workout_power_punching_20250814.md'
Now go get to work!
Check your project folder. You'll find the Markdown file waiting for you. Open it in a compatible viewer (like VS Code or Obsidian) to see your structured, professional-grade workout plan, ready for the gym.
End of the Round: What's Next
That's the bell. You just forged a real-world AI tool that's more personal and intelligent than most generic apps. You've learned to command an AI with a precise prompt and generate a polished, useful result. This is the core skill we will build on for the rest of the series.
But a great fighter (and a great AI agent) needs to learn from the past. Our AI coach is powerful, but it has no memory of the workouts it gives you. What if you wanted it to remember last week's focus and give you something new to avoid plateaus?
In our next post, we'll give our agent the gift of memory. Weβll teach it to remember, making it an even smarter coach.
See you for Round 2.
Check out these great products!
If you find my content valuable, please consider supporting me by buying me a coffee or checking out one of my recommended books on software development. Your support is greatly appreciated!
Copyright Β© 2025 Ravenwood Creations