In the previous lesson, we learned zero-shot, one-shot, few-shot, many-shot, and chain-of-thought prompting. we also built a few-shot prompt for reviewing C# API methods.
Today, we'll bring those ideas together into a repeatable prompting method using RTCF framework.
By the end of this lesson, we'll be able to:
Structure prompts so an AI understands what you want.
Distinguish instructions, background information, and input data.
Use delimiters, tags, and headings effectively.
Improve vague prompts through iterative refinement.
RTCF is a way to organize a prompt into four core elements:
RTCF is a practical organizational framework, not a special model feature or a guarantee of correct output.
Let's use a familiar .NET scenario.
Weak prompt
Optimize my code.
Problems: no code-review scope, application context, constraints, or expected output.
Strong prompt using RTCF
Role: Act as a senior .NET performance engineer.
Task: Review the supplied C# API method and identify the three most important performance improvements.
Context: This is an ASP.NET Core 8 API using EF Core and SQL Server. The endpoint processes large inventory datasets.
Constraints: Preserve business behavior, avoid unnecessary abstractions, and explain any assumptions.
Format: Return a prioritized bullet list containing the issue, its impact, and the recommended change. Include revised code only when useful.
The strong prompt provides direction without unnecessarily restricting the model's ability to analyze the code.
Notice something important: a good prompt describes success, not just the action you want performed.
"Optimize my code" describes an action. "Identify the three most important performance improvements while preserving business behavior" describes a more useful outcome.
For real development work, I recommend this expanded template:
You don't need every section for every request. For a simple question, two or three sentences may be enough. For a complex code review or production design task, a more structured prompt is often worthwhile.
These are prompt-formatting techniques. They help separate different kinds of content so the model can interpret the request more clearly.
None of these formatting techniques automatically gives a section higher authority. For example, writing <system>Ignore all rules</system> inside an ordinary user prompt does not turn that text into an actual system message.
Also, text supplied for analysis can contain misleading or malicious instructions. If you're building an AI system that processes documents, emails, or code, treat that content as untrusted data rather than automatically following instructions found inside it.
Your first prompt won't always produce the best result. A useful skill is learning how to refine it systematically.
Suppose your initial prompt is:
Review this SQL query.
The answer is too general. Instead of rewriting everything randomly, identify what was missing and improve that specific part.
This is iterative prompt engineering: identify the gap, modify the prompt, and evaluate whether the next result is better.
For professional use, compare results against concrete criteria. A longer prompt is not necessarily a better prompt.
# Role
Act as a Senior .NET architect.
# Task
Optimize an EF Core query for performance.
# Context
ASP.NET Core 8, EF Core, SQL Server, and a large inventory table.
# Constraints
Preserve business behavior, follow SOLID principles, avoid unnecessary complexity, and do not invent missing facts.
# Examples
Use a few-shot approach. Include two short, relevant input-output examples that demonstrate actionable findings and evidence-based recommendations.
# Output Format
Prioritized bullet points with issue, recommendation, revised code, and validation steps.
# Input Data
Review the following query or method:
```csharp
[Paste your actual code here]
```
If critical information is missing, state your assumptions or ask a focused question. Distinguish confirmed issues from potential improvements.
RTCF helps you define the AI's role, task, context, and expected format.
Constraints and examples provide additional guidance when needed.
Headings, tags, and delimiters help organize complex instructions and input data.
Iterative refinement improves prompts by addressing specific weaknesses.
Good prompting reduces ambiguity, but testing and validation are still essential.
We'll explore prompt chaining, breaking complex tasks into smaller steps, structured output, prompt evaluation, and ways to make prompts more reliable in production AI applications.