For complex tasks, a single prompt is rarely enough. Prompt chaining breaks large tasks into small steps — and Structured Output makes AI results machine-readable for automation.
📖 Definition: Prompt chaining connects multiple prompts into a workflow, where each step uses the previous result as input. Instead of solving a complex task in one massive prompt, you break it into manageable substeps.
Example: Competitive report in 4 steps
Step 1: "Identify the 5 most important competitors for
[company] in [market] based on: market share, product
offering, pricing model."
Step 2: "Analyze for each identified competitor: strengths,
weaknesses, pricing model, target audience, and current
strategy."
Step 3: "Create a 2x2 positioning matrix based on the
analysis (axes: price and feature depth)."
Step 4: "Formulate 3 strategic recommendations: How can
we differentiate ourselves?"
💡 Tip: Each step in a chain should deliver a clearly verifiable result. Check the result before moving to the next step — catch errors early, not at the end.
| Pattern | Description | Ideal For | Example |
|---|---|---|---|
| 🔗 Sequential | Step by step, linear | Reports, analyses | Research → Analysis → Recommendation |
| 🌐 Fan-Out | One prompt generates multiple parallel tasks | Brainstorming, variants | 1 briefing → 5 campaign ideas → evaluation |
| 🔽 Filter | Generate → Evaluate → Select best | Content creation | 10 headlines → evaluate 3 → select 1 |
| ✅ Verify | Generate → Fact-check → Correct | Research, reports | Summary → Fact check → Final version |
Fan-Out example:
Step 1: "Create 5 different campaign concepts for [PRODUCT].
Each concept: name, target audience, core message, channels."
Step 2 (for each concept): "Evaluate concept [N]:
Originality (1-10), Feasibility (1-10), Expected impact."
Step 3: "Select the best concept and create a detailed
implementation plan."
For automation and system integration, you need machine-readable outputs. Modern LLMs like Claude Opus 4.6 and GPT-5 handle JSON output reliably.
Analyze the following customer review and return the result
as valid JSON. No explanatory text, only JSON.
{
"sentiment": "positive" | "neutral" | "negative",
"score": 1-10,
"topics": ["string", "string"],
"urgency": 1-5,
"summary": "string (max 50 words)",
"recommended_action": "string"
}
Review: [INSERT TEXT]
📖 Definition: JSON Mode is a feature of modern APIs (Claude, GPT-5) that guarantees the model outputs only valid JSON. This prevents parsing errors in your automations.
The latest development in AI automation: Function Calling allows the model to invoke predefined functions — e.g., "Create a calendar event" or "Send an email."
| Feature | What It Does | Available In |
|---|---|---|
| JSON Mode | Guarantees valid JSON output | Claude API, OpenAI API |
| Function Calling | Model calls predefined functions | Claude API, OpenAI API |
| Tool Use | Model uses external tools (web, DB, APIs) | Claude, GPT-5 |
Example: Function Calling for ticket creation
Functions:
- create_ticket(title, priority, assignee, description)
- send_notification(recipient, message)
Prompt: "The customer reported that the login page isn't
loading. Create a ticket and notify the development team."
→ AI calls create_ticket() and send_notification()
⚠️ Caution: Function Calling is powerful but requires careful permission control. Define exactly which functions the AI may call, and implement confirmation for critical actions.
Combine chaining + structured output for fully automated workflows:
🏢 Real-world example: An e-commerce company automated product review analysis: New reviews are sent to Claude via API, classified as JSON (sentiment, topics, urgency), and automatically fed into the CRM. 500 reviews/day processed in seconds.
🎯 Exercise: Create a 3-step prompt chain for a recurring task from your daily work. Bonus: Define the last step's output as a JSON schema.
Congratulations! You've completed the "Prompt Engineering" course. In the next course, you'll discover the best AI tools for your daily work.