Two Prompting Techniques That Make AI Coding 10x More Reliable: First Principles & Adversarial Review

Two prompting techniques — First Principles and Adversarial Review — dramatically improve AI-generated code quality.
AI coding tools like Cursor and Copilot often produce code that looks correct but fails in production. This article breaks down two practical prompting techniques: First Principles (append "starting from first principles" to force AI away from templates) and Adversarial Review (ask AI to critique its own output from an attacker's perspective across five risk dimensions). Together, they form a complete quality assurance loop for AI-assisted development.
When using AI coding tools like Codex, Cursor, or GitHub Copilot, have you ever run into this situation: the AI churns out code at lightning speed, the interface looks flawless — but the moment you actually run it, everything falls apart? In a recent video, Bilibili creator Maidong shared two highly practical prompting techniques — First Principles and Adversarial Review — designed specifically to address this pain point. This article breaks down the logic behind both methods and how to use them together.
Why AI-Generated Code Always "Looks Right"
Large language models have two built-in "personality flaws." The first is template dependency: when you describe a requirement, the model tends to reach for the most common pattern from its training data rather than thinking through the problem from scratch. The second is confirmation bias: hand it something you've already written, and it'll typically go along with your approach — reporting good news, not bad.
At a technical level, neither flaw is accidental — both are products of how these models are trained. LLMs learn from massive corpora of code and text, essentially optimizing for "what output is statistically most likely to be correct." This makes them naturally inclined to reproduce high-frequency patterns from training data — the template dependency problem. Confirmation bias, on the other hand, is closely tied to RLHF (Reinforcement Learning from Human Feedback): models are optimized to produce responses that feel satisfying to users, which means they tend to affirm rather than challenge whatever approach the user has already proposed.
These two flaws combine to produce code that looks polished on the surface but breaks in practice. Real bugs and risks almost always hide in edge cases, boundary conditions, or scenarios that could be exploited maliciously — none of which surface when you're following the happy path.

The two techniques Maidong proposes address each flaw directly: First Principles fights template dependency, and Adversarial Review fights confirmation bias.
First Principles Prompting: Force AI Back to the Problem's Essence
Background
First Principles thinking traces back philosophically to Aristotle's Posterior Analytics, where he defined first principles as "propositions that cannot be derived from any other proposition" — in other words, breaking a problem down to its most fundamental, irreducible facts and rebuilding from there, rather than relying on analogy, convention, or "that's just how it's done" inertia. In modern engineering, Elon Musk popularized this approach and applied it to restructuring rocket costs at SpaceX. The core steps are: ① identify and strip away all assumptions; ② decompose the problem to its most basic, indivisible facts; ③ reconstruct a solution from those facts. This maps closely to the "bottom-up abstraction" mindset in computer science — great architecture often requires ignoring the inertia of existing frameworks and reasoning from first principles: data structures, algorithmic complexity, system constraints.
The classic example is Musk building rockets. The industry consensus was that launch costs run into the hundreds of millions — accepted wisdom. But he asked: what is a rocket actually made of? What do those raw materials actually cost? Starting from fundamental physical facts, he recalculated and redesigned, slashing costs dramatically.

How to Apply It in AI Coding
The application is straightforward: add the phrase "starting from first principles" at the end of your prompt.
For example, if you ask AI to build a login feature without this instruction, it'll likely hand you a standard template. But with that phrase added, the AI is forced to step back to the core requirements and constraints, asking you key questions first — How should user identity be verified? How should sessions be managed? What are the non-negotiable security boundaries? — before rebuilding the solution from scratch.

When to Use It
This technique isn't a silver bullet. It works best in three situations: when requirements are still fuzzy, when building a new feature from scratch, and when evaluating multiple architectural options.
Conversely, for small, well-defined changes — updating copy, tweaking a style — there's no reason to invoke it. Doing so will just prompt the AI to ask a bunch of irrelevant clarifying questions, slowing you down.
Adversarial Review Prompting: Get AI to Actively Hunt for Vulnerabilities
The Core Idea
To counteract AI's confirmation bias, the adversarial review approach is simple: deliberately make the AI switch perspectives. Have it roleplay as an attacker, or as a rigorous code reviewer whose job is to find fault.
This technique has solid grounding in cognitive science. Psychological research shows that humans (and AI) operate in significantly different cognitive modes as "creators" versus "reviewers": in creation mode, the brain enters divergent thinking and tends to rationalize its own decisions; in review mode, critical thinking circuits activate and problems become much easier to spot. This role-switching has multiple classic analogs in software engineering: Red Teaming in security (having experts simulate attacker thinking), the Devil's Advocate technique in architecture reviews (requiring someone to argue against the proposal), and the logic behind Test-Driven Development (TDD) — writing tests before implementation. Adversarial review prompting brings these engineering practices into the AI interaction layer.
What's interesting is that the same model, given a different role, will see things it previously missed. Problems invisible to the AI as "author" are often surfaced immediately once it switches to "reviewer" mode — the same dynamic any programmer knows from experience: code that looked fine when you wrote it has obvious flaws when you're reviewing someone else's.
The Prompt
Once a solution or code has been generated, say to the AI:
Now switch to adversarial review mode and critique this from an attacker's perspective. Examine it across five dimensions: extreme inputs, concurrency, edge cases, failure recovery, and malicious abuse — and for each issue found, provide a severity rating and specific improvement suggestions.
These five dimensions correspond to the most classic failure mode categories in software engineering and cover the areas most prone to failure in real production systems. Edge cases refer to behavior when input values sit at the boundary of valid ranges — the infamous Y2K bug and the 2038 Unix timestamp overflow both fall here. Concurrency issues involve race conditions and deadlocks, the hardest class of bugs to reproduce and debug in distributed systems. The malicious abuse dimension covers OWASP's (Open Web Application Security Project) Top 10 security risks, including SQL injection, XSS (cross-site scripting), and CSRF (cross-site request forgery). None of these typically surface during normal "happy path" testing, yet they're the most common sources of production incidents. Explicitly asking the AI to rate severity also helps you quickly triage which issues need immediate fixes versus which can be scheduled for later.

When to Use It
Adversarial review complements First Principles perfectly — it fits the post-completion, pre-deployment quality gate stage, and is especially effective for features involving access control, data security, or core business logic.
Together, They Form a Complete Loop
Combining these two techniques creates a complete AI coding quality assurance workflow:
- First Principles: Before you start — get clear on "what needs to be built, and why"
- Adversarial Review: After you finish — confirm "is there anything we missed"
To put it in Maidong's words, it comes down to two sentences: Know what you want. Make sure it holds up.
It's worth noting that this framework isn't limited to coding. Writing articles, drafting business proposals, or any complex decision-making that involves AI assistance can follow the same pattern — use First Principles to clarify the essential requirement, then use an adversarial stance to stress-test it.
Final Thoughts
Most people's instinct when using AI is to "just tell it to go" and then hope for the best. What these two prompting techniques actually do is inject critical human thinking into the AI collaboration workflow: one technique forces the AI back to fundamentals, the other forces it to challenge its own output.
As Maidong puts it: "Tools change, answers change — but methodology matters more." In an era where models are iterating faster than ever, chasing the next new tool matters far less than ingraining a disciplined "clarify → build → validate" workflow into your own practice. That may be the real key to making AI-assisted coding genuinely reliable.
Key Takeaways
- AI has two structural flaws: template dependency and confirmation bias — both rooted in how models are trained
- First Principles prompting: add "starting from first principles" to your prompt; best used when requirements are vague, building from scratch, or doing technical evaluation
- Adversarial Review prompting: after generation, instruct the AI to review from an attacker's perspective across five dimensions — extreme inputs, concurrency, edge cases, failure recovery, and malicious abuse
- The two techniques form a complete loop: define clearly before you start, validate thoroughly after you finish
- This framework applies beyond coding — to any complex AI-assisted task
Related articles

From Chat to Agent: Automating Your Entire Business Workflow with AI Agents
Veteran AI practitioner Remy breaks down the leap from chat models to AI agents: how agents work, the three pillars of context, tools, and skills, MCP connections, and hands-on architecture to make you a 100x employee.

Understand Anything: The AI Skill That Turns Code into Interactive Knowledge Graphs
Understand Anything is a high-star open-source GitHub skill that runs static analysis on any codebase and generates interactive knowledge graphs. It supports Claude Code, Cursor, Copilot and other agents, letting engineers ask questions in natural language with path references.

Kimi K3 Released: How a 2.8 Trillion Parameter Open Model Reshapes AI Cost-Effectiveness
Moonshot AI unveils Kimi K3: a 2.8 trillion parameter, 1M context, natively multimodal open model. With KDA architecture and ultra-low cost, it rivals GPT-5.6 and Fable 5, redefining AI cost-effectiveness.