Prompt Engineering 101 – How to Write High-Accuracy AI Prompts
Master prompt engineering with a step-by-step framework: Role, Context, Constraints, Output Format. Before-and-after examples for Gemini, Claude, and DeepSeek.
Introduction: Why Prompt Engineering Matters
AI models are powerful, but their output depends heavily on the prompt. A vague prompt gives generic answers; a well-structured prompt delivers precise, usable results. This tutorial teaches you a repeatable framework.
1. The RCCO Framework
Use four components in every serious prompt:
- Role — Who should the AI act as?
- Context — What background information matters?
- Constraints — What rules, limits, or formats apply?
- Output Format — How should the answer be structured?
2. Weak vs. Strong Prompts
Before (Weak)
"Write a Python function to sort a list."
The AI does not know the context, constraints, or expected format.
After (Strong)
"Act as a senior Python developer (Role).
I have a list of student dictionaries with keys name and score (Context).
Write a function that sorts the list by score descending, handles ties by name ascending, and does not modify the original list (Constraints).
Return only the function code with type hints and a short docstring (Output Format)."
3. Applying RCCO to Real Tasks
Example 1: Code Review
"Act as a senior PHP developer.
Context: This code connects to MySQL using PDO but may have security issues.
Constraints: Focus only on SQL injection and XSS vulnerabilities.
Output Format: A numbered list of issues, each with a suggested fix."
Example 2: Research Summary
"Act as an academic researcher.
Context: I am summarizing a paper on climate change for a university essay.
Constraints: Maximum 200 words, no jargon, cite key findings.
Output Format: Three bullet points followed by one concluding sentence."
Example 3: Exam Preparation
"Act as an experienced SSC physics teacher.
Context: I am preparing for the SSC exam on motion and force.
Constraints: Generate 10 MCQ questions, four options each, one correct answer.
Output Format: Questions followed by an answer key with 2-line explanations."
4. Before-and-After Across Models
Gemini Example
Before: "Explain CSS Grid."
After: "Act as a front-end instructor. Explain CSS Grid to a beginner who knows Flexbox. Use one real layout example with code. Output in 5 short sections."
Claude Example
Before: "Improve my essay."
After: "Act as an academic editor. Improve this 500-word essay for clarity and flow without changing the meaning. Highlight changes in bold. Output the revised essay only."
DeepSeek Example
Before: "Solve this math problem."
After: "Act as a math tutor. Solve this problem step by step, show each formula used, and end with a one-line summary. Problem: [paste problem]."
5. Advanced Tips
- Chain prompts: split complex tasks into steps.
- Provide examples: show the model the pattern you want.
- Use negative constraints: say what NOT to do.
- Iterate: refine based on the first output.
- Test across models: Gemini, Claude, and DeepSeek may respond differently.
6. Common Mistakes
- Too vague: "Write something about AI."
- Too long without structure.
- No output format—results are hard to use.
- Ignoring constraints like word count or tone.
Conclusion
The RCCO framework—Role, Context, Constraints, Output Format—turns vague requests into precise instructions. Practice with the before-and-after examples above, and you will see a dramatic improvement in AI output quality across Gemini, Claude, and DeepSeek.
Ready to Deploy Your AI Web App or Portfolio?
Building an AI-powered web tool or developer portfolio? Host your PHP, Python, or Node.js projects online with fast NVMe SSD servers. Students and developers get an automatic 20% discount (code: AR10-5) on their first order at Hostnin Web Hosting (starting from ৳149/mo with free SSL and bKash/Nagad support), or check full details in our Eduvalle Student Shop.
Eduvalle-এর একাডেমিক টিম: HSC ও ভর্তি পরীক্ষার প্রস্তুতির জন্য যাচাইকৃত নোট ও কুইজ।