Prompt Chain Builder (Chain-of-Thought)
Design multi-step prompt chains where output from one step feeds into the next. Export as runnable scripts.
Prompt Chain Builder
How to build a prompt chain
You are building a customer-support chatbot that needs to classify incoming tickets before responding. Instead of writing one massive prompt, add three steps: a system message setting the persona ("You are a support agent for Acme Corp"), a user message with the ticket text, and an assistant message pre-filled with the classification output you want. Export as JSON and paste it directly into the OpenAI API call.
A typical effective chain is 2 to 6 messages. The tool exports a valid messages array ready for OpenAI or Anthropic API calls, plus a human-readable text preview for documentation. Reorder steps with the up/down arrows to test different conversation flows before writing any code.
Build a system-to-user-to-assistant sequence to prototype chatbot flows before writing any API code. A 4-step chain that sets the persona, provides context, asks the question, and pre-fills the expected answer format gives you a working prototype in minutes.
Pre-fill assistant messages with example responses to guide the model's output format and style consistently. Each example adds 50-200 tokens, so use 2-3 examples for best cost-quality balance rather than 10.
Design a loop where the model's output feeds back into a new user message, enabling step-by-step improvement of code, text, or analysis. For example: "Review this code" -> assistant response -> "Now fix the bugs you found" -> updated response.
What is a prompt chain?
A prompt chain is a structured sequence of messages passed to an LLM API as the messages array. Rather than a single prompt, multi-turn chains let you pre-fill the conversation history to guide the model's reasoning, set up personas, provide worked examples, and build iterative refinement loops.
System role
Sets the context, persona, and constraints. Processed before any user messages. For GPT, passed as {role:'system'}; for Claude, as a separate system parameter.
User role
Contains the actual task or question. In multi-step chains, later user messages can reference earlier assistant responses to create iterative refinement.
Assistant role
Pre-filling an assistant message primes the model to continue from a specific starting point. Useful for constraining output format, chain-of-thought reasoning, and few-shot examples.
Export formats
JSON export produces a valid messages array ready for OpenAI or Anthropic API calls. Text export provides a human-readable summary of each step for documentation and review.
Frequently asked questions
How many steps should a prompt chain have?
There is no hard limit, but longer chains consume more tokens and cost more. A system message plus 1-3 user/assistant turns is typical. Beyond 6 messages, consider whether the task should be broken into separate API calls with the output of one passed as context to the next. Each additional message adds latency and cost at inference time.
Can I use this chain with Claude as well as GPT?
Yes with adaptation. The JSON format exports in OpenAI style with system/user/assistant roles. For Anthropic Claude API, pass the system message as a separate system parameter, and keep only user and assistant alternating turns in the messages array. The content of each step is portable β only the wrapping changes.
What is the difference between a chain and a single prompt?
A single prompt sends one message and gets one response. A chain pre-fills multiple turns of conversation history, letting you control the model persona, show examples, and structure complex reasoning before the model generates its response. Chains are especially useful for few-shot learning and multi-step reasoning tasks.
How do I handle variable inputs in a chain?
Use placeholder text like [INSERT DATA HERE] in your step content. After exporting, replace these placeholders with actual values programmatically or manually before sending to the API. This keeps your chain template reusable across different inputs β build once, use everywhere.
What does pre-filling the assistant message do?
Pre-filling an assistant message tells the model to continue from that starting point rather than generating from scratch. This is useful for constraining output format (e.g., starting with "```json" to force JSON output), providing chain-of-thought reasoning, and ensuring consistent few-shot examples across calls.