Prompting patterns that get better code from AI
Most bad AI code comes from vague prompts.
What to do
- State language, version, framework and style rules.
- Paste the interfaces your code must fit.
- Ask for a plan before code for anything non-trivial.
- Ask it to list assumptions.
Copy this prompt
Context: [language+version], [framework], style: [rules].
Existing interfaces: [paste].
Task: [describe].
First list your assumptions and a short plan. Then write the code with tests. Keep functions small.Check the bot's work
Compare the output to the plan.
Questions
Can I trust the bot on prompting for code?
Use it to plan and explain, then verify. Compare the output to the plan.
Which bot works best?
Grok Bot, ChatGPT, Claude and Gemini all handle this prompt. Paste the same prompt into two and compare; disagreements show where to check a source.
Where these facts come from
- OWASP Top 10
- CISA: Secure by Design
- GitHub Docs: Secret scanning
- W3C: WCAG overview
- Open Source Initiative: Licenses
- NIST SP 800-218: Secure Software Development Framework
Tools, features and prices change often. We don't list prices; check each vendor's official pricing page. Never paste secrets into a prompt. Checked Oct 30, 2026.
Coding with bots · Agents, tools and setup: all lessons → Next: Local coding models →