Module 5 · Chapter 27 Reasoning and Complex Task Prompting › Step-by-Step Instruction Prompting

Step-by-Step Instruction Prompting

Step-by-step instruction prompting divides a complex task into a clear, ordered sequence of small actions - each with a defined input, output, and completion condition - so an AI model follows a controlled process instead of guessing at a broad request.

Quick takeaway: Give every step one main action, state dependencies explicitly ("using the result from Step 1"), add measurable decision points and verification before the final output, define what happens on failure and when the process should stop, and ask for a concise evidence-based justification instead of unrestricted hidden reasoning.

Introduction

Complex tasks often contain several actions, decisions, dependencies, and validation requirements. When all these requirements are written in one long instruction, a Large Language Model may skip important details, perform actions in the wrong order, or produce an incomplete response.

Step-by-step instruction prompting solves this problem by dividing a complex task into a clear sequence of smaller instructions.

Instead of saying:

Create a complete website performance report.

A step-by-step prompt explains exactly how the task should be completed:

  1. Review the provided performance data.
  2. Identify the slowest pages.
  3. Find the likely cause of each issue.
  4. Recommend a solution.
  5. Verify that each recommendation matches the available data.
  6. Present the final report in a table.

This structure makes the task easier to understand, execute, verify, and improve.

Step-by-step prompting is useful for:

  • Software development
  • Data analysis
  • Troubleshooting
  • Research
  • Content creation
  • Business planning
  • Decision-making
  • Process documentation
  • Testing
  • Technical explanations
  • Report generation
  • Workflow automation

What Is Step-by-Step Instruction Prompting?

Step-by-step instruction prompting is a technique in which a task is divided into ordered and clearly defined actions.

Each step tells the model:

  • What action to perform
  • When to perform it
  • What information to use
  • What result to produce
  • What condition to check
  • What to do if something goes wrong
  • When to continue or stop

A step-by-step prompt usually contains:

  1. A clear goal
  2. Input data or context
  3. Ordered instructions
  4. Decision rules
  5. Intermediate outputs
  6. Verification requirements
  7. Error-handling instructions
  8. Stop conditions
  9. Final output requirements

The purpose is not simply to make the prompt longer. The purpose is to make the workflow clear.

Why Step-by-Step Prompting Is Important

Step-by-step prompting improves the reliability of complex tasks.

Its main benefits include:

  • Reduces skipped requirements
  • Keeps actions in the correct order
  • Makes dependencies visible
  • Improves output consistency
  • Makes errors easier to locate
  • Supports conditional processing
  • Allows intermediate validation
  • Improves complex reasoning workflows
  • Makes prompts easier to maintain
  • Produces more structured responses
  • Helps control large tasks
  • Makes results easier to review

A model can often complete a simple instruction without detailed steps. However, complex tasks usually benefit from explicit sequencing.

For example, the following instruction is too broad:

Analyse this application and fix all problems.

A better prompt is:

Prompt
# Review the application in a controlled sequence
Step 1: Identify the application architecture.
Step 2: List all visible functional issues.
Step 3: Check the code related to each issue.
Step 4: Explain the root cause of each issue.
Step 5: Suggest the smallest safe correction.
Step 6: Verify that the correction does not break another feature.
Step 7: Present the final changes file by file.

The second prompt defines a process instead of only defining a goal.

Learning Objectives

After studying this chapter, you should be able to:

  • Divide complex tasks into ordered steps
  • Keep one main action in each step
  • Identify dependencies between steps
  • Add decision points to prompts
  • Define conditional instructions
  • Add verification steps
  • Request intermediate results
  • Define clear stop conditions
  • Add error-recovery instructions
  • Use checklist-based workflows
  • Separate process explanations from hidden reasoning
  • Request concise and useful justification
  • Build reusable step-by-step prompt templates
  • Create step-by-step prompts for coding, research, data analysis, and business tasks

Prerequisites

Before using step-by-step prompting, you should understand:

  • Basic prompt structure
  • Instructions and constraints
  • Input and output formats
  • Conditional statements
  • Task decomposition
  • Required and optional information
  • Basic validation methods
  • The difference between a task and its result

You do not need advanced programming knowledge to use this technique.

Key Terminology

TermMeaning
StepA clearly defined action in a process
SequenceThe order in which steps must be completed
DependencyA requirement that must be completed before another step
Decision pointA stage where the next action depends on a condition
ConditionA rule that determines whether an action should happen
Intermediate resultA temporary result created before the final output
VerificationA check used to confirm correctness
Stop conditionA rule that ends the process
Error recoveryInstructions for handling failure or missing information
ChecklistA list of items that must be completed or verified
JustificationA short explanation of why a result or decision was selected
Final outputThe completed result returned after all required steps

Basic Structure of a Step-by-Step Prompt

A strong step-by-step prompt can follow this structure:

Prompt
# Define the task
Goal: Analyse the provided customer feedback and identify the main product problems.
# Define the input
Input: Customer feedback records provided below.
# Define the process
Step 1: Read all feedback records.
Step 2: Remove duplicate feedback.
Step 3: Group similar complaints into categories.
Step 4: Count the complaints in each category.
Step 5: Rank the categories from highest to lowest frequency.
Step 6: Select the three most common problems.
Step 7: Verify that every selected problem is supported by the feedback.
# Define the output
Output: Present the result as a Markdown table.
# Define the columns
Columns: Rank, problem, complaint count, example feedback, suggested action.
# Define a constraint
Constraint: Do not invent complaints that are not present in the input.

This prompt defines the goal, input, process, verification, output, and constraints.

Defining Ordered Steps

Ordered steps tell the model exactly which action should happen first, second, third, and so on.

Order is important when the result of one action is needed by the next action.

For example, a model should understand the problem before suggesting a solution. Therefore, problem identification should appear before solution generation.

Weak Prompt

Review the code, optimise it, explain the issue, test the solution, and provide corrected code.

This prompt contains several actions, but their order is not fully controlled.

Improved Prompt

Prompt
# Analyse before making changes
Step 1: Read the complete code.
Step 2: Explain what the code is intended to do.
Step 3: Identify correctness, performance, and security issues.
Step 4: Rank the issues by severity.
Step 5: Correct the highest-priority issues.
Step 6: Verify that the corrected code still satisfies the original requirement.
Step 7: Present the corrected code.
Step 8: Summarise the changes.

The improved prompt reduces the chance that the model will change code before understanding it.

How to Define Ordered Steps

Use the following method:

  1. Define the final objective.
  2. List every action required to reach the objective.
  3. Identify which action must happen first.
  4. Place dependent actions after their required inputs.
  5. Add verification before the final output.
  6. Number the steps clearly.
  7. Use direct action verbs.

Useful action verbs include:

  • Read
  • Identify
  • Extract
  • Compare
  • Group
  • Calculate
  • Validate
  • Select
  • Generate
  • Review
  • Correct
  • Summarise
  • Present

Example

Prompt
Step 1: Extract all product names from the input.
Step 2: Extract the price of each product.
Step 3: Remove products with missing prices.
Step 4: Sort the remaining products from lowest to highest price.
Step 5: Select the five lowest-priced products.
Step 6: Present the selected products in a table.

Each step follows a logical order.

One Action per Step

A clear step should normally contain one main action.

When several actions are placed inside one step, the model may perform only some of them or may perform them inconsistently.

Weak Step

Step 1: Read the document, summarise it, identify errors, correct the errors, and prepare a final report.

This single step contains five major actions.

Improved Steps

Prompt
Step 1: Read the complete document.
Step 2: Summarise the main argument.
Step 3: Identify factual, grammatical, and structural issues.
Step 4: Correct the identified issues.
Step 5: Prepare the final report.

Each step now has one clear responsibility.

Why One Action per Step Helps

It provides:

  • Better instruction clarity
  • Easier verification
  • Better error isolation
  • More predictable outputs
  • Easier prompt modification
  • Clearer intermediate results

Acceptable Combined Actions

Small supporting actions can sometimes remain in the same step when they are part of one operation.

For example:

Step 2: Extract each customer name and email address.

This is acceptable because both fields are extracted from the same record during the same operation.

However, the following should be separated:

Extract customer details and create a marketing strategy.

These are different tasks with different outputs.

Practical Rule

Ask this question:

Can this step be completed and verified as one unit?

If the answer is no, divide it into smaller steps.

Example

Prompt
# Process support tickets one action at a time
Step 1: Read each support ticket.
Step 2: Identify the main issue in each ticket.
Step 3: Assign one category to each issue.
Step 4: Assign a priority level.
Step 5: Suggest the next support action.
Step 6: Present the processed tickets in a table.

Sequential Dependencies

A sequential dependency exists when one step requires the output of an earlier step.

For example:

  • A summary requires source content.
  • A recommendation requires analysis.
  • A calculation requires extracted numbers.
  • A code correction requires an identified issue.
  • A final report requires verified intermediate results.

Dependencies must be written clearly so the model does not perform later steps too early.

Dependency Example

Prompt
Step 1: Extract the monthly revenue values.
Step 2: Use the values from Step 1 to calculate total revenue.
Step 3: Use the total from Step 2 to calculate the average monthly revenue.
Step 4: Compare each month with the average from Step 3.
Step 5: Identify months that performed below average.

Each step uses a result produced earlier.

Explicit Dependency Language

Useful phrases include:

  • Using the result from Step 1
  • Based on the categories created in Step 2
  • Continue only after Step 3 is complete
  • Use the validated data from the previous step
  • Do not start Step 5 until Step 4 passes verification
  • Apply this rule to the values extracted earlier

Weak Dependency

Analyse the data and create recommendations.

The relationship between analysis and recommendations is implied but not controlled.

Strong Dependency

Prompt
Step 1: Analyse the sales data and identify measurable trends.
Step 2: Verify each trend using at least two data points.
Step 3: Create recommendations only from the verified trends in Step 2.
Step 4: Do not include recommendations that are unsupported by the data.

Dependency Mapping

For very complex tasks, define inputs and outputs for each step.

StepInputActionOutput
1Raw recordsRemove invalid recordsClean records
2Clean recordsGroup by categoryCategory groups
3Category groupsCalculate totalsCategory totals
4Category totalsRank categoriesRanked categories
5Ranked categoriesCreate reportFinal report

This makes the workflow easier to understand and maintain.

Decision Points

A decision point is a stage where the process chooses between two or more possible actions.

Decision points are useful when the task cannot always follow the same path.

For example:

  • If the data is complete, continue.
  • If the data is missing, request clarification.
  • If the test passes, provide the result.
  • If the test fails, correct the issue.
  • If a risk is high, escalate it.
  • If a value is below a threshold, flag it.

Basic Decision Structure

Prompt
Step 1: Check whether the input contains a customer email address.
Step 2: If the email address is present, validate its format.
Step 3: If the email address is missing, mark the record as incomplete.
Step 4: If the format is invalid, mark the record as invalid.
Step 5: If the format is valid, mark the record as accepted.

Decision Table

Decision tables are useful when several conditions control the result.

ConditionAction
Score is 80 or higherMark as excellent
Score is between 60 and 79Mark as satisfactory
Score is below 60Mark as needs improvement
Score is missingMark as incomplete

Prompt Example

Prompt
# Evaluate the score using defined decision rules
Step 1: Read the score.
Step 2: Check whether the score is present.
Step 3: If the score is missing, return Incomplete.
Step 4: If the score is 80 or higher, return Excellent.
Step 5: If the score is between 60 and 79, return Satisfactory.
Step 6: If the score is below 60, return Needs Improvement.
Step 7: Return only one classification.

Best Practices for Decision Points

  • Define every important condition.
  • Define the action for each condition.
  • Avoid overlapping conditions.
  • Include a fallback condition.
  • Specify whether one or multiple conditions may apply.
  • Define the order of condition checking.
  • Use measurable rules where possible.

Conditional Steps

Conditional steps are performed only when a specific condition is true.

They allow a prompt to adapt to different inputs.

Common condition formats include:

  • If
  • If not
  • When
  • Unless
  • Only when
  • Otherwise
  • In case of
  • Continue only if

Example

Prompt
Step 1: Check whether the code contains database operations.
Step 2: If database operations are present, review the code for SQL injection risks.
Step 3: If user input is inserted directly into a query, recommend parameterised queries.
Step 4: If no database operations are present, skip the database security review.
Step 5: Continue with the general code-quality review.

The security review is performed only when relevant.

Conditional Prompt for Content Review

Prompt
Step 1: Identify the intended audience.
Step 2: If the audience is beginner-level, replace advanced terms with simple explanations.
Step 3: If the audience is technical, retain standard technical terminology.
Step 4: If the audience is not defined, use language suitable for a general professional audience.
Step 5: Preserve the original meaning in every case.

Conditional Prompt for Missing Information

Prompt
Step 1: Check whether all required input fields are available.
Step 2: If all required fields are available, continue with the analysis.
Step 3: If one or more required fields are missing, list the missing fields.
Step 4: Do not invent values for missing fields.
Step 5: Complete only the parts that can be supported by the available input.

Avoid Ambiguous Conditions

Weak condition:

If the report is good, approve it.

The word “good” is not measurable.

Improved condition:

Approve the report only if it contains all five required sections, has no unsupported claims, and includes a source for every numerical statement.

Clear conditions produce more predictable decisions.

Verification Steps

Verification steps check whether the result is complete, correct, consistent, and supported.

A task should not always move directly from creation to final output. Important work should include validation.

Verification can check:

  • Accuracy
  • Completeness
  • Format
  • Calculations
  • Logical consistency
  • Requirement coverage
  • Source support
  • Code correctness
  • Data validity
  • Missing values
  • Duplicate items
  • Security risks

Basic Verification Pattern

Prompt
Step 1: Generate the result.
Step 2: Compare the result with every requirement.
Step 3: Identify missing or incorrect parts.
Step 4: Correct the identified problems.
Step 5: Perform a final verification.
Step 6: Return the result only after verification is complete.

Verification Example for Data Extraction

Prompt
Step 1: Extract the invoice number, date, customer name, and total amount.
Step 2: Verify that every extracted value appears in the original invoice.
Step 3: Check that the date follows the YYYY-MM-DD format.
Step 4: Check that the total amount is numeric.
Step 5: Use null for fields that are not available.
Step 6: Do not guess missing values.

Verification Example for Code

Prompt
# Review and verify the generated function
Step 1: Write a Python function that calculates the factorial of a non-negative integer.
Step 2: Check the behaviour for input 0.
Step 3: Check the behaviour for input 1.
Step 4: Check the behaviour for a positive integer.
Step 5: Check the behaviour for a negative integer.
Step 6: Add input validation if any test fails.
Step 7: Return the final function and a short test summary.

Verification Checklist

A useful verification checklist may include:

  • Did the response answer the requested task?
  • Were all required steps completed?
  • Are all calculations correct?
  • Is the output format correct?
  • Are important claims supported?
  • Are any values invented?
  • Are any requirements missing?
  • Are terms used consistently?
  • Does the result contain unnecessary repetition?
  • Does the result satisfy all constraints?

Intermediate Results

Intermediate results are temporary outputs created during a multi-step task.

They are not always the final answer, but they help later steps complete correctly.

Examples include:

  • Extracted values
  • Cleaned data
  • Category lists
  • Calculated totals
  • Identified problems
  • Ranked options
  • Draft outlines
  • Test results
  • Validation reports
  • Assumptions
  • Dependency lists

Why Intermediate Results Matter

They help with:

  • Tracking progress
  • Verifying each stage
  • Reusing earlier outputs
  • Detecting errors
  • Improving transparency
  • Preventing unsupported conclusions
  • Keeping complex tasks organised

Example

Suppose the task is to recommend the best software tool.

Intermediate results may include:

  1. User requirements
  2. Evaluation criteria
  3. Candidate tools
  4. Feature comparison
  5. Weighted scores
  6. Final recommendation

Prompt Example

Prompt
Step 1: Extract the user's requirements.
Intermediate Result 1: Present the requirements as a numbered list.
Step 2: Convert the requirements into evaluation criteria.
Intermediate Result 2: Present the criteria and their importance.
Step 3: Compare each available option against the criteria.
Intermediate Result 3: Present the comparison in a table.
Step 4: Calculate a score for each option.
Intermediate Result 4: Present the score calculation.
Step 5: Recommend the highest-scoring option.
Final Result: Provide the recommendation with a concise justification.

Controlling Intermediate Output

Not every intermediate result must be displayed to the user.

You can request:

  • Visible intermediate results
  • A short progress summary
  • Only the final result
  • A compact checklist of completed stages
  • A table of key findings
  • A summary of assumptions and validations

Example:

Prompt
Perform the required intermediate analysis internally.
Do not provide hidden reasoning or private internal notes.
Show only the extracted facts, calculations, verification results, and final conclusion.

This keeps the response useful without requesting unnecessary internal reasoning.

Stop Conditions

A stop condition defines when the process must end.

Without a stop condition, a model may continue adding details, repeat actions, or process invalid data.

Common stop conditions include:

  • Stop when the goal is achieved.
  • Stop when no valid records remain.
  • Stop when a required input is missing.
  • Stop after a defined number of attempts.
  • Stop when validation passes.
  • Stop when a critical error is found.
  • Stop when a confidence threshold is not met.
  • Stop when the requested word limit is reached.
  • Stop after selecting the required number of results.

Example

Prompt
Step 1: Search the provided text for duplicate sentences.
Step 2: Remove one duplicate at a time.
Step 3: Verify the text after each removal.
Step 4: Repeat until no duplicate sentences remain.
Stop Condition: Stop when a complete scan finds no duplicate sentences.

Stop Condition for Iterative Correction

Prompt
Step 1: Validate the JSON output.
Step 2: If the JSON is valid, return it and stop.
Step 3: If the JSON is invalid, correct the formatting.
Step 4: Validate the corrected JSON.
Step 5: Repeat the correction process a maximum of two times.
Stop Condition: Stop after successful validation or after two failed correction attempts.
Failure Output: If validation still fails, explain which requirement could not be satisfied.

Stop Condition for Selection

Prompt
Step 1: Rank the products by total score.
Step 2: Select products from the highest score downward.
Step 3: Stop after three valid products have been selected.
Step 4: Do not include additional products.

Good Stop Conditions Are

  • Clear
  • Measurable
  • Directly connected to the goal
  • Easy to verify
  • Limited when repetition is possible

Error Recovery Steps

Error recovery steps explain what to do when the normal process cannot continue.

Errors may occur because of:

  • Missing input
  • Invalid data
  • Conflicting instructions
  • Unsupported file formats
  • Failed validation
  • Incorrect calculations
  • Ambiguous requirements
  • Empty results
  • Code errors
  • Unavailable evidence

A good prompt should not only describe the successful path. It should also describe the failure path.

Error Recovery Structure

Prompt
Step 1: Attempt the required action.
Step 2: Check whether the action succeeded.
Step 3: If it succeeded, continue to the next step.
Step 4: If it failed, identify the cause.
Step 5: Apply the defined recovery action.
Step 6: Retry only when retrying is safe.
Step 7: Stop and report the issue if recovery fails.

Missing Data Example

Prompt
Step 1: Check for product name, price, category, and stock quantity.
Step 2: If all fields are available, process the product normally.
Step 3: If optional fields are missing, use null.
Step 4: If the product name or price is missing, mark the record as invalid.
Step 5: Do not invent missing values.
Step 6: Continue processing the remaining valid records.
Step 7: Report the number of invalid records at the end.

Conflicting Instruction Example

Prompt
Step 1: Review all output requirements.
Step 2: Identify instructions that conflict with each other.
Step 3: Follow the instruction with the higher stated priority.
Step 4: If no priority is defined, choose the interpretation that best matches the main task.
Step 5: State the assumption briefly.
Step 6: Continue without inventing additional requirements.

Code Error Recovery Example

Prompt
# Generate and validate the implementation
Step 1: Generate the Java method.
Step 2: Review the code for syntax errors.
Step 3: If a syntax error is found, correct it.
Step 4: Check the corrected method against the required input and output.
Step 5: If the requirement is still not satisfied, revise the algorithm once.
Step 6: If the issue remains unresolved, report the exact limitation.
Step 7: Do not claim that the code works when verification is incomplete.

Error Recovery Best Practices

  • Never hide an important failure.
  • Do not invent missing data.
  • Limit retries.
  • Define recoverable and non-recoverable errors.
  • Preserve valid intermediate results.
  • Explain unresolved problems clearly.
  • Continue unaffected parts when possible.
  • Avoid restarting the complete task unnecessarily.

Checklist-Based Reasoning

Checklist-based reasoning uses a defined list of requirements to guide and verify a task.

It is useful when the output must satisfy many conditions.

A checklist does not require the model to reveal private internal reasoning. It provides a visible set of requirements that can be checked objectively.

Example Checklist

Before returning the article, verify that it:

  • Has a clear title
  • Contains an introduction
  • Covers every requested topic
  • Uses simple language
  • Includes practical examples
  • Uses Markdown formatting
  • Avoids repeated explanations
  • Includes a conclusion
  • Follows the required structure
  • Does not contain unsupported claims

Prompt Example

Prompt
# Create the article
Step 1: Read the topic and audience requirements.
Step 2: Create an outline covering every required section.
Step 3: Write the article using simple technical language.
Step 4: Add one practical example to each major concept.
Step 5: Review the article using the checklist below.
# Verification checklist
Check 1: Every requested topic is included.
Check 2: Every heading matches its content.
Check 3: No section repeats the same explanation.
Check 4: Technical terms are explained in simple language.
Check 5: Examples are directly related to the topic.
Check 6: The article uses valid Markdown.
Step 6: Correct every failed checklist item.
Step 7: Return the final article.

Checklist for Code Generation

Prompt
# Implementation checklist
Check 1: The code matches the requested programming language.
Check 2: The method name matches the requirement.
Check 3: Input validation is included.
Check 4: Edge cases are handled.
Check 5: The algorithm is logically correct.
Check 6: The code does not contain unnecessary dependencies.
Check 7: The example output matches the code.
Check 8: The explanation matches the final implementation.

Checklist for Data Analysis

Prompt
# Data analysis checklist
Check 1: Missing values are identified.
Check 2: Duplicate records are identified.
Check 3: Calculations use the correct columns.
Check 4: Units are consistent.
Check 5: Comparisons use the same time period.
Check 6: Conclusions are supported by the data.
Check 7: Limitations are stated.
Check 8: The final table contains all required fields.

Benefits of Checklist-Based Reasoning

  • Makes quality requirements visible
  • Reduces missing sections
  • Improves consistency
  • Supports self-review
  • Makes evaluation easier
  • Works well with repeated workflows
  • Can be reused as a prompt template
  • Helps separate objective verification from subjective judgement

Process Explanation vs Hidden Reasoning

A process explanation describes the method, major steps, evidence, calculations, assumptions, and verification used to produce an answer.

Hidden reasoning refers to private internal model processing that is not needed for a useful response.

A good prompt should request useful and reviewable information rather than asking for every hidden internal thought.

Useful Information to Request

You can ask for:

  • A summary of the approach
  • The main steps used
  • Important assumptions
  • Relevant facts
  • Calculations
  • Decision criteria
  • Comparison tables
  • Verification results
  • Sources used
  • Limitations
  • A concise justification
  • A checklist showing requirement coverage

Less Useful Request

Show every thought you had while solving the problem.

This may produce unnecessary, unclear, or unreliable text. It also does not guarantee that the visible explanation represents the model’s complete internal processing.

Better Request

Prompt
Solve the problem carefully.
Provide the final answer.
Show the important calculation steps.
List the assumptions used.
Explain the selected method in five concise points.
Include a verification check.
Do not provide private hidden reasoning or unnecessary internal notes.

Example: Mathematical Task

Instead of requesting unlimited internal reasoning, ask for visible calculations:

Prompt
Step 1: Identify the formula required.
Step 2: Substitute the provided values into the formula.
Step 3: Show the calculation.
Step 4: Verify the unit.
Step 5: Provide the final answer.
Step 6: Explain the result in one sentence.

Example: Business Decision

Prompt
Step 1: Define the decision criteria.
Step 2: Compare each option using the criteria.
Step 3: Present the comparison in a table.
Step 4: Select the strongest option.
Step 5: Provide a concise justification based on the table.
Step 6: State one important limitation.

This produces an auditable explanation without requiring hidden reasoning.

Use phrases such as:

  • Explain the method briefly.
  • Show the key calculation steps.
  • List the evidence supporting the conclusion.
  • State the assumptions used.
  • Provide a concise justification.
  • Summarise the decision criteria.
  • Show the verification results.
  • Explain why the selected option scored highest.
  • Provide the main reasons, not private internal reasoning.

Requesting Concise Justification

A concise justification explains why an answer, decision, classification, or recommendation was selected.

It should be short, evidence-based, and directly connected to the result.

Weak Request

Explain everything in detail.

This may produce a long response containing unnecessary information.

Better Request

Provide the answer followed by a two-sentence justification based only on the supplied data.

Useful Justification Formats

You can request:

  • One sentence
  • Two or three bullet points
  • A short paragraph
  • A reason-and-evidence format
  • A score explanation
  • A comparison summary
  • A decision rule
  • A confidence statement

Example

Prompt
Step 1: Classify the support ticket as Low, Medium, or High priority.
Step 2: Apply the provided priority rules.
Step 3: Return the selected priority.
Step 4: Provide a one-sentence justification mentioning the exact rule that was triggered.

Expected Response

High priority — the customer cannot access the paid service, which matches the service-blocking issue rule.

Recommendation Example

Prompt
Step 1: Compare the three hosting plans.
Step 2: Evaluate price, storage, traffic capacity, backup support, and scalability.
Step 3: Recommend one plan.
Step 4: Provide exactly three justification points.
Step 5: Each point must reference one evaluation criterion.
Step 6: Do not repeat the feature list.

Code Review Example

Prompt
Step 1: Determine whether the function is correct.
Step 2: Identify the most important defect.
Step 3: Return Correct or Incorrect.
Step 4: Provide a maximum two-sentence justification.
Step 5: Mention the input that causes the failure.

Good Concise Justification

A strong justification should:

  • Mention the decision
  • Mention the key reason
  • Refer to evidence or a rule
  • Avoid repeating the complete answer
  • Avoid unsupported opinions
  • Stay within the requested length

Step-by-Step Prompt Examples

This section provides practical examples for different task types.

Example 1: Article Generation

Prompt
# Define the writing goal
Goal: Write a beginner-friendly article about Java exception handling.
# Define the process
Step 1: Define exception handling in simple language.
Step 2: Explain why exception handling is required.
Step 3: Explain try, catch, finally, throw, and throws.
Step 4: Add one Java example for each main concept.
Step 5: Explain each example in simple points.
Step 6: Add common mistakes.
Step 7: Add best practices.
Step 8: Add a short summary.
# Verification
Step 9: Verify that every requested keyword is explained.
Step 10: Remove repeated explanations.
# Output rules
Output Format: Markdown.
Audience: Beginners.
Constraint: Do not use unnecessary advanced terminology.

Example 2: Java Code Generation

Prompt
# Define the requirement
Goal: Create a Java method that finds duplicate values in an integer array.
# Define the implementation steps
Step 1: Validate that the input array is not null.
Step 2: Select an efficient data structure.
Step 3: Iterate through the array once.
Step 4: Store previously seen values.
Step 5: Add repeated values to a duplicate collection.
Step 6: Prevent the same duplicate from appearing multiple times.
Step 7: Return the duplicate values.
# Verification
Step 8: Test the method with an empty array.
Step 9: Test the method with no duplicates.
Step 10: Test the method with repeated duplicates.
Step 11: Verify the time and space complexity.
# Output
Output 1: Final Java code.
Output 2: Example input and output.
Output 3: Concise complexity explanation.
Constraint: Do not use external libraries.

Possible Java Implementation

Java
import java.util.HashSet;
import java.util.Set;
public class DuplicateFinder {
    public static Set<Integer> findDuplicates(int[] numbers) {
        // Reject a null input before processing
        if (numbers == null) {
            throw new IllegalArgumentException("Input array cannot be null");
        }
        Set<Integer> seen = new HashSet<>();
        Set<Integer> duplicates = new HashSet<>();
        for (int number : numbers) {
            if (!seen.add(number)) {
                duplicates.add(number);
            }
        }
        return duplicates;
    }
    public static void main(String[] args) {
        int[] numbers = {1, 2, 3, 2, 4, 1, 2};
        System.out.println(findDuplicates(numbers));
    }
}

The prompt controls implementation, testing, verification, and output explanation.

Example 3: Python Data Processing

Prompt
# Define the goal
Goal: Analyse a CSV file containing monthly sales records.
# Define the data-cleaning process
Step 1: Load the CSV file.
Step 2: Verify that date, product, quantity, and revenue columns exist.
Step 3: Convert the date column to a valid date format.
Step 4: Convert quantity and revenue to numeric values.
Step 5: Remove exact duplicate records.
Step 6: Report records containing invalid required values.
# Define the analysis process
Step 7: Calculate total revenue by month.
Step 8: Calculate total revenue by product.
Step 9: Identify the highest-revenue month.
Step 10: Identify the three highest-revenue products.
# Verification
Step 11: Verify that grouped revenue totals match the cleaned dataset total.
Step 12: Report any difference.
# Output
Output 1: Cleaning summary.
Output 2: Monthly revenue table.
Output 3: Top-product table.
Output 4: Concise findings.
Constraint: Do not silently replace invalid values.

Possible Python Structure

Python
import pandas as pd
def analyse_sales(file_path):
    # Load the sales data
    data = pd.read_csv(file_path)
    required_columns = {"date", "product", "quantity", "revenue"}
    missing_columns = required_columns.difference(data.columns)
    if missing_columns:
        raise ValueError(f"Missing columns: {sorted(missing_columns)}")
    data["date"] = pd.to_datetime(data["date"], errors="coerce")
    data["quantity"] = pd.to_numeric(data["quantity"], errors="coerce")
    data["revenue"] = pd.to_numeric(data["revenue"], errors="coerce")
    data = data.drop_duplicates()
    invalid_rows = data[data[list(required_columns)].isnull().any(axis=1)]
    clean_data = data.dropna(subset=list(required_columns))
    clean_data["month"] = clean_data["date"].dt.to_period("M").astype(str)
    monthly_revenue = clean_data.groupby("month", as_index=False)["revenue"].sum()
    product_revenue = clean_data.groupby("product", as_index=False)["revenue"].sum()
    product_revenue = product_revenue.sort_values("revenue", ascending=False)
    return {
        "invalid_rows": invalid_rows,
        "monthly_revenue": monthly_revenue,
        "top_products": product_revenue.head(3)
    }

Example 4: SQL Query Generation

Prompt
# Define the goal
Goal: Write an SQL query that finds the five customers with the highest total order value.
# Define the database structure
Table 1: customers with customer_id and customer_name.
Table 2: orders with order_id, customer_id, order_total, and order_status.
# Define the query steps
Step 1: Join customers and orders using customer_id.
Step 2: Include only orders with order_status equal to Completed.
Step 3: Group records by customer ID and customer name.
Step 4: Calculate the total completed order value for each customer.
Step 5: Sort customers by total order value in descending order.
Step 6: Return only the first five customers.
# Verification
Step 7: Ensure customers are not duplicated in the final result.
Step 8: Ensure cancelled orders are excluded.
# Output
Output 1: SQL query.
Output 2: Two-sentence explanation.
Constraint: Use standard SQL where possible.

Possible SQL Output

SQL
SELECT
    c.customer_id,
    c.customer_name,
    SUM(o.order_total) AS total_order_value
FROM customers c
INNER JOIN orders o ON o.customer_id = c.customer_id
WHERE o.order_status = 'Completed'
GROUP BY c.customer_id, c.customer_name
ORDER BY total_order_value DESC
FETCH FIRST 5 ROWS ONLY;

Example 5: Debugging a Software Problem

Prompt
# Define the problem
Problem: A Spring Boot API returns HTTP 500 when a user record is not found.
# Define the debugging process
Step 1: Identify the controller method handling the request.
Step 2: Identify the service method used by the controller.
Step 3: Check how the repository handles a missing record.
Step 4: Identify the exception currently produced.
Step 5: Determine the correct HTTP status for a missing resource.
Step 6: Add or update the custom exception.
Step 7: Add global exception handling.
Step 8: Return a structured error response.
# Verification
Step 9: Verify the response for an existing user.
Step 10: Verify the response for a missing user.
Step 11: Verify that unexpected exceptions still return HTTP 500.
# Output
Output 1: Root cause.
Output 2: Corrected code.
Output 3: Expected HTTP responses.
Output 4: Concise test checklist.

Example 6: Research Task

Prompt
# Define the research question
Goal: Compare remote work and office work for software development teams.
# Define the research process
Step 1: Define the comparison criteria.
Step 2: Separate measurable factors from opinion-based factors.
Step 3: Collect evidence for productivity, communication, cost, hiring, and employee satisfaction.
Step 4: Record the date and source of each important claim.
Step 5: Compare the findings under each criterion.
Step 6: Identify areas where evidence is mixed.
Step 7: State the limitations of the comparison.
Step 8: Create a balanced conclusion.
# Verification
Step 9: Remove claims that have no reliable support.
Step 10: Verify that the conclusion matches the evidence.
# Output
Output 1: Comparison table.
Output 2: Key findings.
Output 3: Balanced conclusion.
Output 4: Source list.

Example 7: Customer Support Response

Prompt
# Define the task
Goal: Create a customer support response for a delayed order.
# Define the process
Step 1: Identify the customer's concern.
Step 2: Acknowledge the inconvenience.
Step 3: State the available order status.
Step 4: Explain the next action.
Step 5: Mention the expected update time only if it is known.
Step 6: Provide a support contact option.
# Conditional rule
Step 7: If the delivery date is unknown, do not invent one.
Step 8: If a refund is available, explain the refund option.
# Verification
Step 9: Check that the response is polite and direct.
Step 10: Check that no unsupported promise is included.
# Output
Output: A professional customer email under 150 words.

Example 8: Product Comparison

Prompt
# Define the goal
Goal: Compare three laptops for a software development student.
# Define the criteria
Criterion 1: Processor performance.
Criterion 2: RAM capacity.
Criterion 3: Storage.
Criterion 4: Battery life.
Criterion 5: Display quality.
Criterion 6: Upgrade options.
Criterion 7: Price.
# Define the process
Step 1: Extract the specification of each laptop.
Step 2: Mark any unavailable specification as Not Available.
Step 3: Compare all laptops using the same criteria.
Step 4: Identify the strongest option for coding.
Step 5: Identify the strongest option for battery life.
Step 6: Identify the best value option.
Step 7: Recommend one laptop based on the user's main requirement.
# Verification
Step 8: Ensure the recommendation is supported by the comparison.
# Output
Output 1: Comparison table.
Output 2: Category winners.
Output 3: Final recommendation with three justification points.

Example 9: Content Localisation

Prompt
# Define the goal
Goal: Localise the provided English product description for Indian users.
# Define the process
Step 1: Identify the original meaning and main selling points.
Step 2: Preserve product names and technical specifications.
Step 3: Replace unfamiliar cultural references with suitable Indian references.
Step 4: Use Indian English spelling and usage.
Step 5: Use rupees for price examples when conversion information is provided.
Step 6: Preserve the original professional tone.
Step 7: Avoid word-for-word translation when it sounds unnatural.
# Verification
Step 8: Compare the localised version with the original meaning.
Step 9: Verify that no product claim was added or removed.
# Output
Output 1: Localised description.
Output 2: Short list of major localisation changes.

Example 10: Project Planning

Prompt
# Define the goal
Goal: Create a four-week plan for launching a programming tutorial website.
# Define the process
Step 1: Define the launch requirements.
Step 2: Divide the work into content, development, testing, SEO, and deployment.
Step 3: Identify dependencies between tasks.
Step 4: Estimate the effort of each task.
Step 5: Assign tasks to four weekly phases.
Step 6: Mark tasks that can run in parallel.
Step 7: Add a verification checkpoint at the end of each week.
Step 8: Identify the main launch risks.
Step 9: Define a fallback action for each high-priority risk.
# Stop condition
Step 10: Stop adding tasks when every launch requirement is assigned to a week.
# Output
Output 1: Weekly plan table.
Output 2: Dependency list.
Output 3: Risk and recovery table.
Output 4: Launch-readiness checklist.

Beginner-Level Step-by-Step Prompt

A beginner prompt should use simple actions and a small number of steps.

Prompt
Goal: Summarise the provided article.
Step 1: Read the complete article.
Step 2: Identify the main topic.
Step 3: Identify the five most important points.
Step 4: Remove repeated information.
Step 5: Write a summary of 150 words.
Step 6: Verify that the summary does not add new facts.
Output Format: One paragraph followed by five bullet points.

Intermediate-Level Step-by-Step Prompt

An intermediate prompt can include dependencies, conditions, and verification.

Prompt
Goal: Review the provided API design.
Step 1: Identify every endpoint.
Step 2: Record the method, path, request body, response body, and status codes.
Step 3: Check endpoint naming consistency.
Step 4: Check whether HTTP methods match the intended operations.
Step 5: Check whether success and error responses are defined.
Step 6: If authentication is required, verify that the authentication requirement is documented.
Step 7: If pagination is required, verify that pagination parameters and metadata are defined.
Step 8: List all identified issues.
Step 9: Rank the issues as Critical, High, Medium, or Low.
Step 10: Suggest one correction for each issue.
Step 11: Verify that each suggestion matches the original API purpose.
Output Format: Summary followed by an issue table.

Advanced Step-by-Step Prompt

An advanced prompt may include multiple branches, intermediate results, recovery actions, and stop conditions.

Prompt
# Define the objective
Goal: Analyse application logs and identify the most likely cause of a production failure.
# Define the first stage
Step 1: Extract timestamps, service names, request IDs, error levels, exception names, and messages.
Intermediate Result 1: Structured event list.
# Define the second stage
Step 2: Sort events by timestamp.
Step 3: Group events by request ID.
Intermediate Result 2: Request-level timelines.
# Define the third stage
Step 4: Identify the first error in each failed request.
Step 5: Separate primary errors from secondary errors.
Intermediate Result 3: Candidate root causes.
# Define decision rules
Step 6: If the same primary error appears across multiple requests, mark it as a repeated failure pattern.
Step 7: If an error appears only after another failure, mark it as a possible secondary effect.
Step 8: If required log details are missing, state which evidence is unavailable.
# Define verification
Step 9: Compare each candidate cause with the complete event timeline.
Step 10: Remove candidates that conflict with the timeline.
Step 11: Rank the remaining candidates by evidence strength.
# Define recovery
Step 12: If no candidate has enough evidence, return Insufficient Evidence.
Step 13: Recommend the additional logs or metrics required.
# Define the stop condition
Stop Condition: Stop after one root cause is strongly supported or after available evidence is exhausted.
# Define the output
Output 1: Incident timeline.
Output 2: Most likely root cause.
Output 3: Supporting evidence.
Output 4: Confidence level.
Output 5: Recommended corrective action.
Output 6: Missing evidence and limitations.

Common Mistakes in Step-by-Step Prompting

Too Many Steps

Excessive steps can make a simple task unnecessarily complicated.

Weak approach:

  • Create 20 steps for a basic summary.
  • Repeat the same validation in several places.
  • Separate very small actions that belong together.

Better approach:

Use only the steps required to control the task.

Vague Steps

Weak step:

Step 3: Make the result better.

Improved step:

Step 3: Remove duplicate points, correct grammar, and replace unclear sentences.

Steps should define observable actions.

Incorrect Order

Weak order:

  1. Write the final recommendation.
  2. Analyse the options.
  3. Define the evaluation criteria.

Improved order:

  1. Define the criteria.
  2. Analyse the options.
  3. Compare the results.
  4. Write the recommendation.

Missing Dependencies

Weak instruction:

Calculate the average and clean the data.

Improved instruction:

Prompt
Step 1: Remove invalid and duplicate records.
Step 2: Use the cleaned records to calculate the average.

The average should be calculated after cleaning.

Missing Failure Path

Weak instruction:

Extract the invoice total.

This does not explain what to do when the total is missing.

Improved instruction:

Prompt
Step 1: Locate the invoice total.
Step 2: If the total is present, extract it.
Step 3: If the total is not present, return null.
Step 4: Do not calculate or guess the missing total.

No Verification

A generated answer may look correct without actually meeting all requirements.

Add a final validation step:

Verify that every required field is present and every value is supported by the input.

Conflicting Conditions

Weak conditions:

  • If score is above 60, mark Pass.
  • If score is above 80, mark Excellent.

A score of 90 matches both conditions.

Improved conditions:

  • If score is 80 or higher, mark Excellent.
  • Otherwise, if score is between 60 and 79, mark Pass.
  • Otherwise, mark Fail.

Requesting Unnecessary Hidden Reasoning

Avoid asking for unrestricted private internal reasoning.

Request useful outputs instead:

  • Key steps
  • Calculations
  • Assumptions
  • Evidence
  • Verification
  • Concise justification
  • Limitations

Best Practices

Start with the Goal

State the final objective before listing steps.

Example:

Goal: Identify the root cause of the failed payment transactions.

This helps every step remain connected to the main task.

Use Direct Action Verbs

Start steps with words such as:

  • Read
  • Extract
  • Check
  • Calculate
  • Compare
  • Validate
  • Correct
  • Select
  • Present

Avoid vague words such as:

  • Handle
  • Improve
  • Deal with
  • Make better
  • Do properly

Define Inputs and Outputs

A step becomes clearer when its input and expected output are known.

Example:

Use the cleaned sales records from Step 2 to calculate monthly revenue totals.

Make Conditions Measurable

Weak:

If performance is poor, optimise the code.

Strong:

If execution time exceeds 500 milliseconds for the provided test input, identify the slowest operation and suggest an optimisation.

Add Verification Near Important Results

Do not wait until the end when an early error could affect every later step.

Example:

  1. Extract values.
  2. Verify extracted values.
  3. Perform calculations.
  4. Verify calculations.
  5. Create the final report.

Limit Retry Attempts

Unlimited retries may create repetitive output.

Example:

Retry the formatting correction a maximum of two times.

Define the Required Detail Level

Example:

Provide one sentence of justification for each recommendation.

This prevents unnecessarily long explanations.

Preserve Evidence

When later steps depend on facts, request visible evidence.

Example:

Include the original sentence supporting each extracted claim.

Use a Final Checklist

A final checklist ensures the completed result satisfies the original task.

Reusable Step-by-Step Prompt Template

Prompt
# Define the role
Role: Act as a [role or subject expert].
# Define the objective
Goal: [Describe the final result].
# Define the context
Context: [Provide relevant background information].
# Define the input
Input: [Provide or describe the input data].
# Define the ordered process
Step 1: [Perform the first action].
Step 2: [Perform the second action].
Step 3: [Use the result from Step 2 to perform the next action].
Step 4: [Apply a decision rule].
Step 5: [Create an intermediate result].
Step 6: [Verify the intermediate result].
Step 7: [Correct any identified issue].
Step 8: [Generate the final result].
# Define conditional rules
Condition 1: If [condition], then [action].
Condition 2: If [condition], then [action].
Fallback Condition: If no defined condition applies, [fallback action].
# Define error recovery
Error Rule 1: If required input is missing, [recovery action].
Error Rule 2: If validation fails, [recovery action].
Retry Limit: [Maximum number of retries].
# Define the stop condition
Stop Condition: Stop when [measurable completion condition].
# Define verification
Verification 1: Check [requirement].
Verification 2: Check [requirement].
Verification 3: Check [requirement].
# Define the output
Output Format: [Markdown, table, JSON, code, report, or another format].
Required Fields: [List required output fields].
Explanation Length: [Define explanation limit].
# Define constraints
Constraint 1: Do not [prohibited action].
Constraint 2: Use only [allowed information].
Constraint 3: State missing information instead of guessing.
# Define justification
Justification: Provide [number] concise reasons based on [evidence or criteria].

Compact Step-by-Step Prompt Template

Prompt
Goal: [Define the result].
Step 1: [First action].
Step 2: [Second action].
Step 3: [Third action].
Step 4: Verify [important requirement].
Step 5: Correct any failed verification.
Stop Condition: Stop when [completion condition].
Error Rule: If [error condition], [recovery action].
Output: [Required output format].
Constraint: [Important restriction].
Justification: Explain the result in [defined length].

Step-by-Step Prompt Quality Checklist

Before using a prompt, verify the following:

  • The final goal is clearly defined.
  • Every step starts with a clear action.
  • Steps are arranged in logical order.
  • Each step has one main responsibility.
  • Dependencies are stated explicitly.
  • Important decision points are defined.
  • Conditional actions have clear rules.
  • Missing input is handled safely.
  • Intermediate results are defined where needed.
  • Important results are verified.
  • Error-recovery instructions are included.
  • Retry limits are defined.
  • Stop conditions are measurable.
  • The output format is clearly stated.
  • The required explanation length is controlled.
  • The prompt does not request unnecessary hidden reasoning.
  • The model is asked to provide evidence, calculations, or concise justification.
  • Conflicting conditions are removed.
  • The prompt does not allow unsupported guessing.

Final Summary

Step-by-step instruction prompting is an effective method for controlling complex AI tasks.

It works by converting a large request into a structured process containing:

  • Ordered steps
  • Single-action instructions
  • Dependencies
  • Decision points
  • Conditional rules
  • Intermediate results
  • Verification
  • Error recovery
  • Stop conditions
  • Checklists
  • Concise justification
  • Clear output requirements

The strongest step-by-step prompts do more than list actions. They define how each action connects to the next, what should happen when a condition changes, how errors should be handled, and how the final result should be verified.

For reliable results:

  1. Start with a clear goal.
  2. Divide the task into logical actions.
  3. Keep one main action in each step.
  4. State dependencies explicitly.
  5. Add conditions and decision rules.
  6. Define intermediate outputs.
  7. Verify important results.
  8. Add recovery instructions.
  9. Define when the process must stop.
  10. Request a concise, evidence-based explanation instead of unnecessary hidden reasoning.

A well-designed step-by-step prompt acts like a process guide. It gives the model a clear path from the original input to a complete, verified, and properly formatted result.

Frequently Asked Questions

What is step-by-step instruction prompting?

Step-by-step instruction prompting divides a complex task into an ordered sequence of clearly defined actions, where each step states what to do, what input to use, what result to produce, and what condition to check - instead of describing everything in one broad instruction.

Why should each step contain only one action?

When several actions are bundled into one step, the model may perform only some of them or perform them inconsistently. One action per step gives better clarity, easier verification, cleaner error isolation, and more predictable intermediate results.

What is a sequential dependency, and how should it be written?

A sequential dependency exists when a step needs the output of an earlier step, such as a recommendation requiring completed analysis. Write it explicitly - "using the result from Step 1" or "do not start Step 5 until Step 4 passes verification" - rather than leaving the relationship implied.

What is the difference between a decision point and a conditional step?

A decision point is a stage where the process chooses between multiple defined paths based on a condition (e.g. score ranges mapping to different outcomes). A conditional step is a single action that only runs when a specific condition is true, such as reviewing SQL injection risk only if the code touches a database.

Why are verification steps important in a multi-step prompt?

Verification steps check whether a result is complete, correct, and supported before it feeds later steps or the final output - catching missing fields, wrong calculations, or unsupported claims early instead of letting them propagate through the rest of the workflow.

What is a stop condition, and why does every iterative process need one?

A stop condition defines exactly when a repeating process must end, such as "stop after two failed correction attempts" or "stop when a complete scan finds no duplicates." Without one, a model may keep adding detail, repeat actions, or process invalid data indefinitely.

How should error recovery be handled in a step-by-step prompt?

Define the failure path explicitly alongside the success path: check whether an action succeeded, identify the cause if it failed, apply a defined recovery action, retry only when safe, and stop and report the issue clearly if recovery fails - never invent missing data to paper over a failure.

What is checklist-based reasoning?

Checklist-based reasoning uses a visible, objective list of requirements to guide and verify a task - such as confirming every requested topic is covered or every edge case is handled - without requiring the model to expose its private internal reasoning process.

What's the difference between a process explanation and hidden reasoning?

A process explanation is useful, reviewable information - the method used, key calculations, assumptions, and verification results. Hidden reasoning is unrestricted private internal processing that adds length without adding reliability; a good prompt asks for the former, not the latter.

What are common mistakes in step-by-step prompting?

Common mistakes include creating far too many tiny steps, writing vague steps like "make the result better," putting steps in the wrong order, omitting dependencies, missing a failure path, skipping verification, writing overlapping conditions, and requesting unlimited hidden reasoning instead of a concise justification.