Make security part of your prompts:
"Generate a user registration endpoint. Use bcrypt for password hashing, parameterized queries for database access, and validate that email format is correct before insertion. Return appropriate HTTP status codes for different failure modes."
Front-loading security requirements produces more secure initial code. Bolting security on afterward misses things.