Beyond Basic Prompting
Chapters 1—11 established the core workflow. This chapter introduces seven optional structures for comparing options, making assumptions visible, reviewing output, and preserving useful context.
Multi-Persona Prompting
You can ask for reviews through different lenses, such as performance, security, and usability. A persona changes the focus of the response; it does not give the model the qualifications, access, or accountability of a real specialist.
Step 1 — As a React performance expert:
Analyze this component for unnecessary re-renders and
expensive computations.
Step 2 — As a security auditor:
Review the same code for vulnerabilities and data exposure.
Step 3 — As a UX engineer:
Evaluate the user-facing behavior. Are there edge cases
that would confuse users?
Step 4 — Synthesize all three perspectives into a
prioritized list of improvements.
Each role label requests a different review lens: performance, security, or usability. The model does not acquire the qualifications or independent perspective of those specialists, so verify the combined findings with evidence and accountable reviewers.
Structured Decision Scaffolds
For a decision with several trade-offs, ask for explicit options, assumptions, evidence to verify, and a concise rationale. This makes the response easier to inspect than a bare recommendation.
I need to add real-time collaboration to the family planner.
Before proposing a solution, think through these steps:
1. What are the technical options? (WebSocket, SSE, polling)
2. What are the trade-offs of each for my use case?
3. What's the simplest option that handles 10 concurrent users?
4. What changes to my current architecture are needed?
5. What are the main risks or failure modes?
For each step, list the assumptions, evidence to verify,
trade-offs, and a concise rationale. Then recommend an option.
A decision scaffold makes the response easier to inspect because options, assumptions, evidence, and trade-offs are explicit. It does not guarantee that the analysis is complete or correct.
AI language models generate tokens sequentially — each word influences the next. When you force structured reasoning, early analysis tokens (trade-offs, constraints, risks) directly influence later conclusion tokens. The reasoning itself improves the answer.
Adversarial Self-Review
After AI generates code, ask it to attack its own output. This technique consistently finds issues that a standard "review this code" prompt misses.
You just wrote this code. Now switch roles.
You are a hostile code reviewer whose job is to find
every possible issue. Be ruthless. Look for:
- Bugs that would only appear under unusual conditions
- Performance problems that emerge at scale
- Security vulnerabilities an attacker could exploit
- Assumptions that might not hold in production
- Race conditions or timing issues
Don't be diplomatic. List every problem you can find.
The instruction "don't be diplomatic" is important. AI has a tendency to be polite about its own output, hedging criticism with "this is mostly fine but..." Forcing a hostile stance produces far more thorough analysis.
Progressive Complexity
Instead of asking for the final complex version immediately, build complexity incrementally. Each stage adds one layer of sophistication, and you verify correctness at each level.
Build a data table component. We'll add complexity in stages.
Stage 1: Static table that renders an array of objects.
Just rows and columns, nothing else.
Stage 2: Add sorting (click column headers to sort).
Stage 3: Add filtering (search input that filters rows).
Stage 4: Add pagination (10 rows per page with controls).
Stage 5: Add row selection with checkboxes.
Start with Stage 1 only. I'll tell you when to proceed.
This strategy prevents the "complexity explosion" where AI tries to build everything at once and produces tangled code. Each stage is simple, testable, and builds cleanly on the previous one. By stage 5, you have a sophisticated component with a clean architecture.
Comparative Analysis
Instead of asking "what's the best way to do X," compare credible approaches against explicit criteria. The structure improves inspectability; the facts and conclusions still require verification.
Compare these three state management approaches for my app:
1. React useState + context
2. Zustand
3. Redux Toolkit
Evaluate each on these dimensions:
- Learning curve (for a mid-level React developer)
- Bundle size impact
- Boilerplate required
- DevTools quality
- Suitability for my app size (~15 components, ~5 data entities)
Present as a comparison, then recommend one with reasoning.
The explicit evaluation dimensions prevent AI from defaulting to the most popular option. It forces genuine analysis across criteria that matter for your specific situation.
Rubber Duck Debugging with AI
Traditional rubber duck debugging works by forcing you to explain the problem out loud. AI takes this further — it actually responds, asks clarifying questions, and proposes hypotheses.
I'm stuck on a problem and need to think it through.
Situation: My activity filter works for single-member
selection but breaks with multi-select. The filtered
list shows the right count but the wrong activities.
I've checked:
- The filter function logic (seems correct)
- The state updates (members array updates correctly)
- The component re-renders (it does)
Something is wrong but I can't see what.
Ask me questions to help me narrow down the issue.
Don't guess the answer — help me find it myself.
The instruction "help me find it myself" is key. It tells AI to ask diagnostic questions rather than jumping to solutions. This approach builds your own debugging skills while leveraging AI's ability to ask the right questions — questions you might not think to ask yourself.
Prompt Templates as Code
Save prompts that worked for recurring tasks together with their inputs, expected outputs, and limitations. Re-test them when the model, tool, or task changes.
A prompt library can reduce repeated setup work and preserve lessons from earlier reviews. Version prompts against measured outcomes; reuse without re-testing can also preserve obsolete assumptions.
Building Your Prompt Library
Here's a starter library organized by task type. Save these, customize them for your stack, and add your own as you discover prompts that work well.
Pro Tip: Version Your Prompts
Store your prompt library in a Markdown file or a dedicated folder in your project. When you find a prompt that consistently produces great results, save it with a name, a description of when to use it, and an example of the output it produces. Over time, this becomes one of your most valuable development assets.
Working Across Multiple AI Sessions
Projects often outlast a single AI conversation. Preserve authoritative state in project files so a new session does not depend on conversational memory.
- Start with relevant context — Provide the current task, verified project state, applicable decisions, and completion checks. Confirm that the model's summary matches those sources.
- Keep a "project context" document — A Markdown file containing your architecture decisions, current data types, component list, and API endpoints. Paste relevant sections at the start of each session.
- Share code incrementally — Don't dump your entire codebase. Share the specific files relevant to today's task, plus interfaces and types that define the contract.
- Reference previous decisions — "In our last session, we decided to use Zustand for state management. Continue with that approach."
PROJECT CONTEXT:
Family schedule planner — React/TypeScript frontend,
Express/MySQL backend.
CURRENT STATE:
- Milestones 1-5 complete (calendar, CRUD, filtering)
- Working on: milestone 6 (real-time sync)
- Stack: the project's declared React version, TypeScript, Zustand, Express, MySQL
KEY TYPES:
[paste Activity and FamilyMember interfaces]
TODAY'S TASK:
Add WebSocket-based sync so changes on one client
appear on others within 2 seconds.
Systematic Experimentation
When a task recurs, compare prompt or workflow variants against the same inputs and acceptance criteria rather than relying on memory or preference.
A/B Test Prompts
Try two versions of a prompt for the same task. Compare output quality. Keep the better one.
Track What Works
Keep a simple log: prompt approach → output quality → lessons learned. Patterns emerge quickly.
Iterate on Structure
Does role-first or goal-first produce better results? Does listing constraints help or hurt? Test and measure.
Refine Over Time
Keep a revision only when measured results improve, and re-test it when the task, model, or tool changes.
Put three advanced strategies into practice:
- Strategy 1 — Multi-persona: Take a component you've built and run it through three different AI personas (performance expert, security auditor, UX engineer). Synthesize the findings.
- Strategy 3 — Adversarial review: After generating any piece of code, immediately ask AI to attack it. Fix everything it finds.
- Strategy 7 — Prompt library: Create a Markdown file and save your 5 best prompts from the exercises in this book. Format each with a name, when-to-use description, and the full prompt text.
Key Takeaways
- Review lenses can focus a response on different concerns without substituting for real specialists
- Structured decision scaffolds make assumptions, evidence, and trade-offs easier to inspect
- Adversarial self-review can suggest additional issues, but independent checks remain necessary
- Progressive complexity builds sophisticated features cleanly — one layer at a time
- Comparative analysis with explicit criteria makes assumptions and trade-offs easier to inspect
- Maintain a tested prompt library for recurring tasks, including limitations and re-test conditions
- Manage context across sessions with project summaries, type definitions, and decision references
- Experiment systematically: A/B test prompts, track results, refine continuously
Related Guides
AI Prompt Library
Build on reusable prompt patterns across common workflows.
Leading AI-Assisted Development
Turn advanced prompting patterns into shared team practice.