# Prompt Engineering Helper (`scraper_guru/prompt-engineering-helper`) Actor

Transform basic prompts into optimized LLM prompts using 12 research-proven templates. Works with ChatGPT, Claude, GPT-4, and any LLM.

- **URL**: https://apify.com/scraper\_guru/prompt-engineering-helper.md
- **Developed by:** [LIAICHI MUSTAPHA](https://apify.com/scraper_guru) (community)
- **Categories:** AI, Developer tools, Agents
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Prompt Engineering Templates

### Tired of Writing Bad Prompts?

You know ChatGPT can do amazing things. You've seen others get incredible results. But your prompts? They get mediocre responses.

**The problem isn't the AI. It's how you're asking.**

This actor automatically wraps your prompts in research-proven templates used by prompt engineering experts. No more remembering techniques. No more inconsistent results. Just paste your question, pick a template, and get a prompt that actually works.

---

### What It Does

**Input:** Your basic prompt  
**Output:** Optimized prompt ready for ChatGPT, Claude, GPT-4, or any LLM

#### Example

**Before:**
````

How do I fix a memory leak in my Python app?

```

**After (Chain of Thought):**
```

How do I fix a memory leak in my Python app?

Let's work this out step by step to ensure we have the right answer:

1. First, let's break down the problem
2. Then, let's consider each component
3. Finally, let's arrive at a solution

Think through this carefully and show your reasoning.

````

**Result:** Instead of a generic answer, the LLM gives you systematic, step-by-step debugging.

---

### 12 Templates Inside

Each template is based on peer-reviewed research (Wei et al. 2022, Kojima et al. 2022, etc.) and optimized for specific tasks.

#### 1. **Zero-Shot** - Simple & Direct
Best for straightforward questions that need clear answers.

#### 2. **Few-Shot Learning** - With Examples
Best for teaching the model a specific pattern or style with 3 worked examples.

#### 3. **Chain of Thought** ⭐ MOST POPULAR
Best for complex problems, debugging, analysis. Adds step-by-step reasoning structure.

#### 4. **Zero-Shot CoT** - Quick Reasoning
Best for fast problems. Just adds "Let's think step by step."

#### 5. **Role-Based** - Expert Persona
Best for specialized advice. Model becomes an expert (15+ years experience).

#### 6. **Structured Output** - Formatted Response
Best for parseable responses. Gets organized sections, code blocks, bullet points.

#### 7. **Emotional Stimulus** - High Priority
Best for critical tasks. Adds urgency for better quality (research-proven!).

#### 8. **Step-Back** - Conceptual First
Best for learning. Explains fundamentals before diving into specifics.

#### 9. **Self-Consistency** - Multiple Approaches
Best for important decisions. Generates 3 different reasoning paths.

#### 10. **Problem Decomposition** - Break It Down
Best for very complex problems. Breaks into sub-problems and solves each.

#### 11. **Metacognitive** - Explain Reasoning
Best for transparency. Model explains what's relevant and why.

#### 12. **Comparative Analysis** - Compare Options
Best for choosing between alternatives. Structured pros/cons comparison.

---

### How to Use

#### Input

```json
{
  "user_prompt": "Your question here",
  "template_type": "chain_of_thought",
  "custom_context": "Any additional context (optional)",
  "output_format": "markdown"
}
````

#### Parameters

| Parameter | Required | Description |
|-----------|----------|-------------|
| `user_prompt` | ✅ Yes | Your question or prompt |
| `template_type` | No | Which template (default: `chain_of_thought`) |
| `custom_context` | No | Extra context like tech stack, constraints |
| `output_format` | No | `text` (JSON) or `markdown` (default: `text`) |

#### Template Options

Use one of these for `template_type`:

- `zero_shot`
- `few_shot`
- `chain_of_thought` ⭐ (recommended)
- `zero_shot_cot`
- `role_based`
- `structured_output`
- `emotional_stimulus`
- `step_back`
- `self_consistency`
- `problem_decomposition`
- `metacognitive`
- `comparative_analysis`

#### Output

You get:

- `enhanced_prompt` - Copy this and paste into your LLM
- `original_prompt` - Your input for reference
- `template_name` - Which template was used
- `character_count` / `word_count` - Stats
- `usage_instructions` - How to use it

***

### Real Examples

#### Debugging Code

```json
{
  "user_prompt": "My React app crashes when users log in",
  "template_type": "problem_decomposition",
  "custom_context": "Using JWT, Redux, Auth0"
}
```

#### Writing Content

```json
{
  "user_prompt": "Write an intro for my blog about AI ethics",
  "template_type": "structured_output"
}
```

#### Making Decisions

```json
{
  "user_prompt": "MongoDB vs PostgreSQL for my SaaS?",
  "template_type": "comparative_analysis",
  "custom_context": "10k users expected, team of 8"
}
```

#### Learning Concepts

```json
{
  "user_prompt": "Explain how neural networks work",
  "template_type": "step_back"
}
```

***

### Which Template Should I Use?

**Simple question?** → `zero_shot`\
**Need examples?** → `few_shot`\
**Complex problem?** → `chain_of_thought` ⭐\
**Expert advice?** → `role_based`\
**Specific format?** → `structured_output`\
**Critical task?** → `emotional_stimulus` or `self_consistency`\
**Learning something?** → `step_back`\
**Very complex?** → `problem_decomposition`

**Not sure?** Use `chain_of_thought` - it works for 80% of cases.

***

### Works With Everything

✅ ChatGPT (GPT-3.5, GPT-4, GPT-4o)\
✅ Claude (Opus, Sonnet, Haiku)\
✅ Google Gemini\
✅ Meta Llama\
✅ Mistral\
✅ Any other LLM

**No API calls made.** This actor just wraps your prompt in a template. You paste the result into your LLM.

***

### Use in Workflows

#### n8n

```
Trigger → Apify (this actor) → OpenAI → Process result
```

#### Zapier

```
Slack mention → Apify → Claude → Reply in thread
```

#### Make

```
Webhook → Apify → GPT-4 → Email response
```

#### API

```javascript
const client = new Apify.ApifyClient({ token: 'YOUR_TOKEN' });

const run = await client.actor('muliaichi/prompt-engineering-templates').call({
    user_prompt: "How do I optimize my database?",
    template_type: "chain_of_thought"
});

const enhancedPrompt = run.output.enhanced_prompt;
// Use with OpenAI, Claude, etc.
```

***

### Why This Works

Based on research from:

- **Wei et al. (2022)** - Chain-of-Thought Prompting
- **Kojima et al. (2022)** - Zero-Shot Reasoners
- **Wang et al. (2022)** - Self-Consistency
- **Bsharat et al. (2024)** - Principled Instructions

These aren't random hacks. They're proven techniques that improve LLM responses by 20-50%.

***

### Pricing

**Fast:** < 1 second per prompt\
**Cheap:** ~$0.0001 per run\
**No AI costs:** Just template wrapping (no LLM API calls)

***

### Questions?

**Does this call GPT-4 or Claude?**\
No. It wraps your prompt in a template. You paste the output into your LLM.

**Will this work with \[any LLM]?**\
Yes. Works with ChatGPT, Claude, Gemini, Llama, any LLM.

**Can I use this commercially?**\
Yes. It's just template wrapping.

**Which template is best?**\
Chain of Thought works for most cases. For critical decisions, use Self-Consistency.

***

### Contact

**LIAICHI MUSTAPHA**\
AI Engineer | Creator of [n8nlearninghub.com](https://n8nlearninghub.com)

📧 mustaphaliaichi@gmail.com\
🐙 [GitHub: MuLIAICHI](https://github.com/MuLIAICHI)\
💬 [r/n8nLearningHub](https://reddit.com/r/n8nLearningHub)

***

**Stop guessing. Start using templates that work.** 🚀

# Actor input Schema

## `user_prompt` (type: `string`):

Enter your prompt or question (any topic - coding, writing, analysis, etc.)

## `template_type` (type: `string`):

Choose the prompt engineering template to apply

## `custom_context` (type: `string`):

Add any extra context, constraints, or requirements

## `output_format` (type: `string`):

Choose how you want the result formatted

## Actor input object example

```json
{
  "user_prompt": "Can you help me debug this Python function that's throwing a TypeError?",
  "template_type": "chain_of_thought",
  "custom_context": "I'm using Python 3.11 and need the solution to be compatible with async/await",
  "output_format": "text"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("scraper_guru/prompt-engineering-helper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("scraper_guru/prompt-engineering-helper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call scraper_guru/prompt-engineering-helper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=scraper_guru/prompt-engineering-helper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Prompt Engineering Helper",
        "description": "Transform basic prompts into optimized LLM prompts using 12 research-proven templates. Works with ChatGPT, Claude, GPT-4, and any LLM.",
        "version": "1.0",
        "x-build-id": "KGtKSuLTNKhnc3vWr"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/scraper_guru~prompt-engineering-helper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-scraper_guru-prompt-engineering-helper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/scraper_guru~prompt-engineering-helper/runs": {
            "post": {
                "operationId": "runs-sync-scraper_guru-prompt-engineering-helper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/scraper_guru~prompt-engineering-helper/run-sync": {
            "post": {
                "operationId": "run-sync-scraper_guru-prompt-engineering-helper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "user_prompt"
                ],
                "properties": {
                    "user_prompt": {
                        "title": "Your Prompt",
                        "type": "string",
                        "description": "Enter your prompt or question (any topic - coding, writing, analysis, etc.)"
                    },
                    "template_type": {
                        "title": "Select Template",
                        "enum": [
                            "zero_shot",
                            "few_shot",
                            "chain_of_thought",
                            "zero_shot_cot",
                            "role_based",
                            "structured_output",
                            "emotional_stimulus",
                            "step_back",
                            "self_consistency",
                            "problem_decomposition",
                            "metacognitive",
                            "comparative_analysis"
                        ],
                        "type": "string",
                        "description": "Choose the prompt engineering template to apply",
                        "default": "chain_of_thought"
                    },
                    "custom_context": {
                        "title": "Additional Context (Optional)",
                        "type": "string",
                        "description": "Add any extra context, constraints, or requirements"
                    },
                    "output_format": {
                        "title": "Output Format",
                        "enum": [
                            "text",
                            "markdown"
                        ],
                        "type": "string",
                        "description": "Choose how you want the result formatted",
                        "default": "text"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
