📖 Chapter 9: The AI Workflow – Coding with a Robotic Sidekick

“You’re not just coding. You’re conducting a duet. And your partner is an autocomplete ghost with an encyclopedic memory and a flair for drama.”

🤝 Working with AI, Not for It

Using Cursor AI is like pair-programming with:

Cursor doesn’t just finish your code—it:

You need a workflow that’s both structured and flexible—like jazz in a helmet store.


🧠 Step 1: Write the Comment First (aka Prompt Engineering for Code)

Cursor loves clear instructions:

# Create a function that checks if a number is prime

Then try a more detailed version:

# Write a function that:
# - checks if a number is prime
# - returns True or False
# - handles edge cases
# - uses early exit for speed

You’re ordering code like a very technical waiter.


🧪 Cursor Prompt Practice

  1. # Make a to-do list app
  2. # Let the user add, remove, and list tasks
  3. # Save the tasks in a JSON file
  4. # Add error handling if the file doesn't exist

Cursor will follow your lead like a caffeinated golden retriever. 🐕


🧰 Step 2: Edit the AI's Output (Don't Just Trust It)

Cursor is good—but you are the final authority.

Always:

Ask yourself:

Your job: curate the raw output into art (or at least runnable code).


🧙‍♂️ Step 3: Use It Like a Dev Team

Cursor SkillPrompt
Explain code# What does this function do?
Translate code# Convert this to JavaScript
Refactor code# Make this more efficient
Add logging# Add debug logs to this function
Write tests# Create unit tests for this class

It’s like five interns, one genius, and Stack Overflow’s ghost in your editor.


💡 Strategy: Chat with Your Code

Treat Cursor like a conversation partner:

  1. Comment what you want
  2. Let it generate
  3. Comment what’s wrong
  4. Let it fix it
  5. Repeat
# This function is too slow. Can you optimize it?
# I don't like the variable names. Make them friendlier.

You’re not just coding. You’re collaborating with a slightly manic assistant who never sleeps.


🎮 Mini Project: Refactor With AI

# Here's a messy function. Refactor it into clean, readable code.

Watch Cursor:

Then try:


🛠️ Pro-Level Moves

The AI is confident, not always correct.
Like a charismatic barista making up espresso science.

🧃 Workflow Recap Smoothie


🎁 Challenge: Build Something Entirely with Comments

# A command-line calculator
# that handles +, -, *, /
# with input validation and history tracking

Then guide it further:

You’re coding by vibes now. And that’s powerful.


THE END of Chapter 9