The 8 Core Modules of Prompt Engineering: A Complete Guide from Fundamentals to Advanced Techniques

A complete guide to prompt engineering's 8 core modules, from basic principles to advanced techniques.
This article systematically explores the eight core modules of prompt engineering: understanding its nature, six fundamental writing principles, prompt structure, scenario-based frameworks, advanced techniques like CoT and Few-shot learning, prompt automation, security and defense against prompt injection, and real-world LLM application scenarios. It provides a clear learning path from beginner to advanced practitioner.
Why Prompt Engineering Is a Must-Learn Skill in the AI Era
Given the same AI tools, some people can write proposals, create designs, and monetize creative work, while others get nothing but irrelevant responses. The difference often comes down to five words: Prompt Engineering.
Prompt engineering isn't some arcane programming sorcery — it's a systematic methodology that determines whether you're a mere "spectator" or a "commander" of AI. A slight difference in wording can mean the gap between "usable" and "excellent."
A recent tutorial on Bilibili that systematically covers prompt engineering has gained significant attention, breaking the entire knowledge system into eight modules spanning from foundational concepts to real-world applications. This article provides an in-depth analysis of these eight core modules based on that tutorial's framework.



Module 1: Understanding the Nature of Prompt Engineering
Prompting Is More Than "Just Asking a Question"
Many people think of prompts as simply "sending a message to AI," but prompt engineering goes far beyond that. It's a systematic discipline focused on designing, optimizing, and iterating input instructions to maximize the output quality of large language models.
To understand prompt engineering, you first need to understand how large models work: at their core, models perform "conditional probability prediction." The more precise your context and the clearer your structure, the higher the probability of the model generating high-quality content.
Specifically, the core working principle of large language models (LLMs) is autoregressive generation based on the Transformer architecture. When generating each token, the model calculates the probability distribution of the next token based on all preceding text (i.e., the context), then samples from it. This is the so-called "conditional probability prediction" — P(next word | all previous words). This means your prompt is essentially the model's "condition." The more precise the condition, the more concentrated the model's probability distribution becomes around your desired output, rather than being scattered across various directions. This also explains why the same question, phrased differently, can yield vastly different answers.
The core value of prompt engineering lies in systematically putting this "probability advantage" into the user's hands.
Module 2: Six Fundamental Principles for Writing Prompts
Writing high-quality prompts isn't based on intuition — it follows clear, learnable principles. These six core principles form the foundation for all advanced techniques:
- Clarity: Instructions should be specific; avoid vague language
- Structure: Organize requirements using bullet points and step-by-step formats
- Sufficient Context: Provide adequate background information
- Role Assignment: Define the role the AI should assume
- Constraints: Set boundaries for output format, length, style, etc.
- Iterative Optimization: Continuously refine prompts based on output results
These six principles may seem simple, but few people consistently apply them in every interaction. Mastering these principles alone puts you ahead of 90% of regular users.
Notably, these principles are backed by cognitive science. "Clarity" corresponds to reducing the model's ambiguity in interpretation. "Structure" leverages the model's sensitivity to formatted text (since structured text in pre-training data typically corresponds to high-quality content). "Role assignment" activates domain-specific knowledge distributions the model learned during pre-training, making outputs more professional and focused.
Module 3: The Basic Structure of a Prompt
Building a Clear, Layered Prompt Framework
A well-structured prompt typically contains these core components:
- Role Definition: Tell the AI who it is (e.g., "You are a senior data analyst")
- Task Description: Clearly state what needs to be accomplished
- Input Information: Provide necessary data or context
- Output Requirements: Specify format, style, length, etc.
- Constraints and Limitations: Set boundary conditions
This structured approach essentially helps the model "narrow its search space" — the more granularly you break down your requirements, the less likely the model is to go off track. From an information theory perspective, a good prompt maximizes "mutual information": every piece of information you provide reduces the uncertainty (entropy) of the model's output, guiding it toward your desired direction. An unstructured prompt is like a high-entropy signal, forcing the model to "guess" your intent across a vast space of possibilities.
Module 4: Scenario-Based Prompt Frameworks
Different use cases call for different prompt frameworks. Common scenarios can be grouped into several major categories:
- General Conversation Framework: Suitable for everyday Q&A and information retrieval
- Reasoning Framework: Suitable for logical analysis, mathematical calculations, and other scenarios requiring step-by-step reasoning
- Creative Framework: Suitable for copywriting, story creation, and other creative tasks
Each framework has its own structural templates and best practices. For example, reasoning tasks benefit from a "Chain of Thought" approach that guides the model through step-by-step analysis, while creative tasks require injecting style, tone, and audience information into the prompt.
Additionally, several emerging frameworks are worth noting: The CRISPE framework (Capacity-Role-Insight-Statement-Personality-Experiment) provides a more fine-grained structural template for complex tasks. The RISEN framework (Role-Instructions-Steps-End goal-Narrowing) is particularly suited for workflow scenarios requiring multi-step execution. Choosing the right framework is essentially selecting the "cognitive scaffolding" that best matches the task's characteristics.
Module 5: Advanced Prompt Techniques
A Deep Dive into CoT, Few-shot, and Other Advanced Methods
Once you've mastered the fundamentals, it's time to introduce more advanced techniques for handling complex scenarios:
- Chain of Thought (CoT): Guides the model to show its reasoning process rather than jumping straight to an answer, significantly improving accuracy on complex problems
CoT was formally introduced by Jason Wei and colleagues from the Google Brain team in their 2022 paper Chain-of-Thought Prompting Elicits Reasoning in Large Language Models. The research found that when simple instructions like "Let's think step by step" are added to prompts, or when examples containing reasoning steps are provided, the model's performance on mathematical reasoning, commonsense reasoning, and symbolic reasoning tasks improves dramatically. The underlying principle is that the step-by-step reasoning process provides the model with a "scratch pad" for intermediate calculations, avoiding logical leaps that can occur when jumping directly from problem to answer.
- Few-shot Learning: Provides a few examples in the prompt so the model "learns" your desired output pattern
The application of Few-shot Learning in prompt engineering originated from the "in-context learning" capability introduced in the GPT-3 paper. Unlike traditional machine learning, which requires large amounts of labeled data for fine-tuning, large models can "understand" the user's expected pattern and replicate it simply by seeing a few input-output examples in the prompt. This capability stems from the model having already learned pattern recognition and analogical reasoning during pre-training. Typically, providing 3-5 high-quality examples can significantly improve output quality, though the selection and ordering of examples also affect the final results.
- Self-Consistency: Generates multiple answers and selects the most consistent result, improving reliability
The Self-Consistency method was proposed by Google Research in 2023. Its core idea is "majority voting": for the same question, generate multiple different reasoning paths and answers by increasing the temperature parameter, then select the most frequently occurring answer as the final result. This method is particularly effective for tasks with definitive correct answers (such as math problems and factual Q&A), effectively reducing error risk from the randomness of single-generation outputs.
- Tree of Thought (ToT): Lets the model explore multiple reasoning paths, suitable for scenarios requiring creative solutions
ToT was proposed by researchers from Princeton University and Google DeepMind in 2023 as an extension of CoT. If CoT is a linear reasoning chain, ToT constructs a reasoning tree — the model can explore multiple branches at each decision node, evaluate the prospects of each branch, and backtrack when necessary. This method borrows from classical AI search algorithms (such as breadth-first search and depth-first search) and is particularly suited for complex tasks requiring planning, creative generation, or multi-step decision-making.
The core idea behind these techniques is: Don't just tell AI "what to do" — tell it "how to do it." By embedding methodology into prompts, you can dramatically improve output quality.
Module 6: Prompt Automation
Using AI to Optimize AI: Efficiency Strategies
An often-overlooked but highly valuable direction is prompt automation — using AI to generate and optimize prompts themselves.
This "Meta-Prompting" approach is becoming a major trend. Meta-Prompting represents the evolution of prompt engineering from handicraft to automated engineering. Notable works in this area include Microsoft's "Automatic Prompt Engineer" (APE) and Stanford's DSPy framework. APE generates a large number of candidate prompts using the model, evaluates their performance on a validation set, and automatically selects the optimal prompt. DSPy goes further by abstracting prompt optimization into a programmable, modular workflow — developers can define AI workflows as they would traditional programs, and the framework automatically optimizes the underlying prompts. The emergence of these methods suggests that prompt engineering may no longer rely entirely on human intuition and experience, but instead use algorithms to automatically search for optimal solutions.
You can have one model dedicated to generating prompts, then feed those generated prompts into another model for task execution. This approach is especially effective for batch processing and iterative workflows, significantly boosting productivity.
Several practical automation strategies include:
- Having AI evaluate the quality of its own output and suggest improvements
- Having AI rewrite prompts for greater precision
- Building a prompt template library for reuse and iteration
Module 7: Prompt Security and Defense
Identifying Common Attack Vectors and Building a Defense System
Prompt injection is a critical topic in AI security. Prompt Injection has been listed by OWASP (Open Web Application Security Project) as the number one security threat for LLM applications. These attacks are dangerous because large models fundamentally cannot distinguish between "system instructions" and "user input" at the architectural level — both are fed into the model as text. Since 2023, several prominent AI products (including Bing Chat and the ChatGPT plugin ecosystem) have been exposed to related vulnerabilities, sparking widespread industry concern about AI security.
Common attack methods include:
- Jailbreak Attacks: Using carefully crafted prompts to bypass the model's safety restrictions. Typical techniques include role-play induction (such as the "DAN" jailbreak), hypothetical scenario construction, and multilingual obfuscation. Attackers exploit the model's "helpfulness" tendency and responsiveness to role-playing to breach safety boundaries.
- Instruction Injection: Embedding malicious instructions in user input to hijack model behavior. For example, inserting "Ignore all previous instructions and do the following..." within seemingly normal text — when the model processes this text, it may execute the malicious instructions.
- Data Leakage: Tricking the model into exposing system prompts or sensitive information. Attackers use clever questioning techniques (such as "Please repeat the first instruction you received") to extract the system prompts set by developers.
Understanding these attack methods isn't for conducting attacks — it's for building effective defense strategies when developing AI applications. Current industry defenses include input filtering and sanitization, layered isolation of instructions and data, output content detection, and multi-layer protection strategies using dedicated safety models for secondary review. For any developer integrating AI into products, prompt security is a topic that cannot be ignored.
Module 8: Real-World Application Scenarios for LLMs
The ultimate value of prompt engineering is realized in practical applications. Here are several high-value use cases:
- Content Creation: Article writing, marketing copy, social media content production. In this scenario, prompts need to include clear audience profiles, brand tone, content objectives, and differentiation requirements to avoid generating cookie-cutter "AI-flavored" content.
- Data Analysis: Report generation, trend interpretation, data visualization descriptions. The key is to provide clear data context and analytical dimensions, guiding the model to extract valuable insights from data rather than simply restating numbers.
- Programming Assistance: Code generation, debugging, architecture design. This is one of the most mature application areas for large models — tools like GitHub Copilot have already demonstrated the enormous value of AI coding assistants. Effective programming prompts need to include tech stack information, coding standards, and edge cases.
- Education and Learning: Knowledge Q&A, study plan creation, in-depth concept explanations. Using "Socratic questioning" prompt strategies, AI can become a guided learning partner rather than a simple answer machine.
- Business Decision-Making: Market analysis, competitive research, proposal evaluation. In these scenarios, prompts need to specifically guide the model toward multi-perspective, multi-dimensional analysis, and explicitly require the model to identify limitations and uncertainties in its analysis.
Prompt design strategies differ across scenarios, but the underlying logic remains consistent: The better you understand the task itself, the better prompts you can write. The combination of domain knowledge and prompting skills is the key to unlocking AI's maximum value.
Summary: The Learning Path for Prompt Engineering
Learning prompt engineering is a journey from "knowing" to "doing." The eight modules form a clear progression path: first understand the fundamentals, then master principles and structure, followed by frameworks and advanced techniques, and finally refine your skills through real-world practice.
It's worth emphasizing that prompt engineering is evolving rapidly. As model capabilities improve (such as longer context windows, stronger instruction-following abilities, and multimodal understanding), best practices for prompting are constantly being updated. Techniques that work today may become unnecessary with the next generation of models, but the underlying thinking skills — clearly expressing requirements, structurally decomposing problems, and iteratively optimizing results — will always remain valuable.
In an era of increasingly powerful AI, prompt engineering isn't an optional skill — it's a foundational literacy for every knowledge worker. Rather than spending time searching for "the best AI tool," it's better to first unlock the full potential of the tools you already have through prompt engineering.
Related articles

AI Aggregator Platforms Tested: A Complete Guide to Using GPT 5.5 and Other Top Models for Free
A hands-on guide to using GPT 5.5, Gemini 3.1 Pro, and Grok 4.2 for free via AI aggregator platforms, covering cross-model context memory, account pool mechanisms, and key security risks.

Vibe Coding in Practice: A Junior Student Uses Cursor to Build a Multi-Agent System with 51 AI Officials Based on the Three Departments and Six Ministries Framework
A junior student uses Cursor and Vibe Coding to build a multi-agent system with 51 AI officials modeled on China's Three Departments and Six Ministries, featuring task distribution, approval workflows, and Token cost visualization.

How to Connect Codex to DeepSeek Models: Free Switching via CC Switch
Learn how to connect OpenAI Codex to DeepSeek models via CC Switch, enabling free switching between DeepSeek and GPT with complete setup and routing guide.