๐Ÿง˜โ€โ™‚๏ธ PromptVibe

APE Prompt Framework

APE = Action, Purpose, Execution. An action-oriented framework that leads with what to do, why it matters, and how the output should be delivered. Best for data analysis, code tasks, and process automation.

When to Use APE

Use the APE framework when:

  • The task is action-driven โ€” analyze, transform, generate, automate, clean, or calculate.
  • The purpose (the why) shapes how the AI should approach or prioritize the output.
  • You need code generation, data manipulation, or process automation with controlled output format.
  • You want a focused prompt without the overhead of persona or scenario setup.

When Not to Use APE

  • Complex scenarios with background context โ€” use COAST when the situational context is as important as the action itself.
  • Tasks requiring a specific expert persona โ€” use ROLE when the AI persona and output constraints are central to the task.
  • Educational explanations โ€” use RACE for teaching and explanatory content.

APE Framework Template

Action: [What specific action should the AI take?] Purpose: [Why is this being done? What is the goal?] Execution: [How should the output be structured or delivered?]

Example: Data Analysis

Before (weak prompt):

Analyze this sales data

After (structured prompt):

Action: Analyze monthly sales data for Q1โ€“Q3 across 5 product categories Purpose: Identify which categories are declining and which are growing to inform Q4 budget allocation Execution: Output a summary table with category, trend (up/flat/down), and a 1-sentence insight per category; follow with 3 prioritized budget recommendations

Example prompt:

Analyze monthly sales data for Q1 through Q3 across 5 product categories. I need to identify which categories are declining and which are growing to inform Q4 budget allocation. Produce a summary table with each category, its trend (up, flat, or down), and a one-sentence insight. Follow the table with 3 prioritized budget recommendations.

Example: Code Generation

Before (weak prompt):

Write a script to clean my data

After (structured prompt):

Action: Write a Python script to clean a CSV file โ€” remove duplicate rows, fill missing numeric values with column medians, and standardize date columns to ISO 8601 format Purpose: Prepare raw customer export data for import into a data warehouse; data quality directly affects downstream reporting accuracy Execution: Single Python file using pandas; add inline comments explaining each cleaning step; include a print summary at the end showing rows removed and columns modified

Example prompt:

Write a Python script using pandas to clean a CSV file. The script should remove duplicate rows, fill missing numeric values with column medians, and standardize date columns to ISO 8601 format. This is for preparing raw customer export data for a data warehouse import, so data quality matters. Add inline comments explaining each step and print a summary at the end showing how many rows were removed and which columns were modified.

How to Write an APE Prompt โ€” Step by Step

  1. Define the Action. State the specific action you want the AI to take โ€” analyze, generate, clean, transform, write, calculate.
  2. Explain the Purpose. Describe why this action is being performed and what goal it serves. This helps the AI prioritize and frame the output correctly.
  3. Specify the Execution. Define how the output should be structured, formatted, and delivered โ€” tables, code blocks, bullet points, prose, etc.

Frequently Asked Questions

What does APE stand for in prompt engineering?

APE stands for Action, Purpose, Execution. It is a three-part prompt framework that leads with what to do, explains why it matters, and defines how the output should be delivered. Best suited for data analysis, code tasks, and process automation.

When should I use APE instead of TAG?

Use APE when the reason behind the action โ€” the purpose โ€” is important context for the AI to shape the output correctly. Use TAG when the task is simple and the goal can be stated directly without a separate purpose explanation.

Is APE good for code generation prompts?

Yes, APE is well-suited for code generation, data transformation, and automation tasks. The Action component makes the request precise, the Purpose explains the business or technical goal, and the Execution component controls output format โ€” language, comments, and structure.

Try the Prompt Generator โ†’

Also see: All AI Prompt Frameworks ยท AI Prompt Optimizer