Module 4 of 7
4. Code Prompting
Code Prompting Patterns
How to get the best code output from AI
Describe, Don't Dictate
Tell the AI what you need, not how to code it. Let it choose the implementation.
"Build a function that validates email addresses" not "Write a regex for..."
Error-Paste Debugging
Copy the full error trace into chat. Don't interpret it yourself.
"Fix this error: [paste full stack trace]"
Refactor by Intent
Give the AI the outcome you want, not the mechanics.
"Make this function more readable" or "Split into smaller functions"
LLMs are effective tools for developers. This module teaches you how to use prompts to speed up your coding workflow, from writing and debugging code to performing full-scale refactors and generating tests.
Code Prompt Patterns
Five patterns for effective code generation and manipulation
Generate"Write a Node.js function that..."New code from spec
Refactor"Refactor to use async/await"Improved existing code
Debug"This throws TypeError, fix it"Bug fix + explanation
Test"Write Jest tests for this module"Test suite
Document"Add JSDoc to every function"Inline documentation