Using AI Assistants Without Shipping Their Mistakes Prompting: Context Is the Whole Trick
2 / 5
Next
Prompting: Context Is the Whole Trick ~15min

Weak prompt

write a login function

You will get something generic, in a framework you may not use, with assumptions you cannot see.

Strong prompt

PHP 8.3, plain PDO, no framework. MySQL users table with
columns id, email, password_hash, is_active.

Write a login function that:
- takes email and password
- uses a prepared statement
- verifies with password_verify
- returns the same error message whether the email or the password was wrong
- does not leak whether an email is registered

Return only the function.

The four things worth including

  1. Stack and versions, language, framework, database
  2. The real shape of your data. Actual column names
  3. Constraints. What it must and must not do
  4. Output format, just the function, or with comments

Paste the actual error

The full message and the surrounding code beats describing it. "It doesn't work" gets you a guess.

Iterate rather than restart

"That uses a function removed in PHP 8; rewrite without it" is faster than a fresh prompt, because the context is already there.

Ask for the reasoning

"Explain the trade-offs before writing code" often produces a better answer, and lets you catch a wrong assumption before it is buried in fifty lines.

Tasks
Preview