Lesson 10 / 25
Writing Functions and Boilerplate
Generate repetitive code quickly while keeping it consistent with your project.
Where the time savings are
The biggest wins are repetitive, well-understood code: data classes, API clients, form validation, config files, type definitions, CRUD handlers. Point at an existing file as the pattern and say "follow the same structure and naming". Read the result as a pull-request from a stranger: does it match your conventions, handle errors the way the rest of the code does, and avoid adding needless dependencies?
Watch for new dependencies
Assistants sometimes reach for a package when three lines of standard code would do. Every dependency is a long-term cost and a security surface, so ask whether you really need it.
Quick check: What is a good way to keep generated code consistent with your project?
- Point at an existing file as the pattern to follow
- Never mention conventions
- Use random naming
- Ask for the longest code possible
Answer
Point at an existing file as the pattern to follow — A concrete example of your style gives the assistant something specific to imitate.