liveBook · Manning

Anti-pattern prompting

As explained in Coding with AI

Anti-pattern prompting asks an AI system to identify harmful or ineffective implementation approaches and explain how to avoid them.

Anti-pattern prompting asks an AI system to identify harmful or ineffective implementation approaches and explain how to avoid them. Use it to turn vague concerns about generated code into explicit review criteria, boundary conditions, or design constraints. section 9.6.1

Apply the technique by asking the system to:

  • Review code for security vulnerabilities, performance bottlenecks, error handling, duplication, and SOLID-principle violations. section 9.6.1
  • Check generated tests against edge cases such as negative values, zero, fractional values, maximum integers, and null or undefined inputs. section 9.6.1
  • Examine architectural choices before implementation, such as JWT versus session-based authentication in a microservices architecture. section 9.6.1

A practical review prompt

Review this implementation for security vulnerabilities, performance bottlenecks, missing error handling, code duplication, and SOLID-principle violations. For each issue, explain the risk and suggest a safer alternative. Treat generated suggestions as candidates for developer validation, not as trusted fixes. section 9.6.1

How Coding with AI covers it

How deep it goes
Demonstrates prompt patterns and concrete checks but does not develop a complete anti-pattern taxonomy.
Examples
Uses authentication architecture, age-restriction tests, code-review checklists, and performance constraints as concrete cases.
What it assumes
Assumes familiarity with implementation, testing, architectural choices, and common code-quality concerns.
What you can do after
Diagnose/debug with it by eliciting risks, missing cases, and safer alternatives before accepting generated code.
How it connects
Connects with code review, unit testing, SOLID principles, few-shot prompting, role-reversal prompting, and architectural decision-making.

This explainer was generated by Manning's knowledge graph from the text of Coding with AI. The section links point to the parts of the book it draws on.