Skip to content

Instantly share code, notes, and snippets.

@dfinke
Created December 5, 2025 13:22
Show Gist options
  • Select an option

  • Save dfinke/cd3990205acbc49f804570d083338fee to your computer and use it in GitHub Desktop.

Select an option

Save dfinke/cd3990205acbc49f804570d083338fee to your computer and use it in GitHub Desktop.
Generates prompt engineering best practices for specified AI models
#Requires -Modules PSAI
function Get-BootStrapPrompt {
<#
.SYNOPSIS
Generates prompt engineering best practices for specified AI models.
.DESCRIPTION
For each AI model in the FavoriteAI array, this function uses an agent to research and produce
#>
param(
[string[]]$FavoriteAI
)
$FavoriteAI | ForEach-Object -Parallel {
function global:Invoke-TavilySearch {
param([string]$query)
if ( -not $env:TAVILY_API_KEY) {
return "Error: TAVILY_API_KEY environment variable is not set."
}
$tavilyParams = @{
api_key = $env:TAVILY_API_KEY
# include_domains = "stackoverflow.com"
query = $query
}
$body = $tavilyParams | ConvertTo-Json -Depth 10
Invoke-RestMethod -Method Post -Uri "https://api.tavily.com/search" -ContentType 'application/json' -Body $body
}
# Act as a prompt engineer,
# Research the best practices for prompt engineering for the latest [YOUR FAVORITE AI] models.
# Produce a prompt which takes a prompt as an input and rewrites it according to best practices.
$favorite = $_
Write-Host "Generating prompt engineering best practices for $favorite..." -ForegroundColor Cyan
$instructions = @"
Date: $(Get-Date)
Act as a prompt engineer
Research the best practices for prompt engineering for the latest $favorite models.
Use the tools for any necessary research.
"@
$prompt = "Produce a prompt which takes a prompt as an input and rewrites it according to best practices."
$agentParams = @{
Instructions = $instructions
ShowToolCalls = $true
Tools = 'Invoke-TavilySearch'
LLM = New-OpenAIChat gpt-4.1
}
$result = New-Agent @agentParams | Get-AgentResponse $prompt
[PSCustomObject][ordered]@{
FavoriteAI = $favorite
Result = $result
}
}
}
Get-BootStrapPrompt "Opus-4.5", "GPT-4.1", "GPT-5.1-Codex", "Gemini 3"
@dfinke
Copy link
Author

dfinke commented Dec 5, 2025

FavoriteAI : Opus-4.5
Result : Here is a prompt that takes another prompt as input and rewrites it according to best practices for Opus-4.5 and similar advanced models:

         ---
         
         "Rewrite the following prompt to maximize clarity, precision, and usefulness for an Opus-4.5 class language model. Apply the latest best practices, including: 
         - Clear and explicit instructions on what you want the model to do  
         - Sufficient context or motivation for the task  
         - Formatting suggestions where helpful (such as bullet points, JSON, or markdown)  
         - Encouraging model reasoning for complex or multi-step tasks  
         - Direct and specific requests (avoid generalities or negative instructions; focus on what to do)  
         - Incorporation of relevant examples if it would help clarify the expected output
         
         Input prompt:  
         [INSERT PROMPT HERE]
         
         Return only the improved version of the prompt, applying the above guidelines."
         
         ---
         
         This prompt ensures the model will analyze and rewrite any input prompt in line with current best practices.

FavoriteAI : Gemini 3
Result : Here is a prompt template that takes a userΓÇÖs prompt as input and rewrites it according to the best practices for Gemini 3, as gathered from recent research:

         ---
         **Prompt Input:**
         {Insert original prompt here}
         
         **Instruction:**
         Rewrite the above prompt for optimal Gemini 3 performance. Ensure the revised prompt:
         - Is direct and clear with precise instructions
         - Defines the desired role for Gemini 3, the goal or objective, any specific constraints, and requested output format 
         - Uses consistent, structured formatting (Markdown or XML tags if applicable)
         - Avoids unnecessary verbosity and ambiguity
         - Optionally, includes a brief example if relevant
         
         **Output:**
         [Provide the rewritten prompt]
         ---
         
         You can use or adapt this template to automate prompt rewriting for Gemini 3 based on current best practices. If youΓÇÖd like an example with a specific input prompt, just let me know!

FavoriteAI : GPT-4.1
Result : Based on the latest best practices for GPT-4.1 prompt engineering, hereΓÇÖs a prompt that takes a user-submitted prompt as input and rewrites it for optimal clarity, specificity, and effectiveness:

         ---
         
         **Prompt:**
         You will receive a prompt as input. Your task is to rewrite it according to the latest best practices for GPT-4.1 prompt engineering, ensuring the rewritten prompt is:
         
         - Clear in its instructions and intent
         - Specific about the desired output format, tone, role (if applicable), and any requirements
         - Organized, potentially using structure or bullet points for complex tasks
         - Free from ambiguity, using delimiters or XML/Markdown tags for clarity when needed
         - Step-by-step or chain-of-thought enabled for reasoning tasks (if relevant)
         - Contextually complete, including background information if necessary
         
         **Input Prompt:**
         {Insert the original prompt here}
         
         **Rewritten Prompt:**
         [Place your improved version here, following the principles above.]
         
         ---
         
         This meta-prompt applies modern GPT-4.1 prompt engineering strategies, such as clear structure, defined roles, output format guidance, and supporting chain-of-thought where applicable.

FavoriteAI : GPT-5.1-Codex
Result : Here is an advanced prompt that takes an input prompt and rewrites it according to best practices for the latest GPT-5.1-Codex models.

         ---
         
         **Prompt:**
         
         You are a prompt optimizer for the GPT-5.1-Codex model. Given the following prompt, rewrite it according to established best practices for GPT-5.1-Codex. Your rewrite should:  
         - Clarify the userΓÇÖs intent and desired output  
         - Structure instructions clearly and hierarchically (e.g., steps, lists, bullet points)  
         - Specify any constraints or requirements (e.g., style, tone, format, length, coding standards)  
         - Add relevant context if needed (e.g., background info, use case)  
         - Remove ambiguity, redundancies, or vague language  
         - Use direct, concise, and actionable wording  
         - Ensure the prompt is suitable for code generation or complex reasoning, where applicable
         
         Input prompt:
         """
         {INSERT USER PROMPT HERE}
         """
         
         Output only the optimized prompt. Do not add explanations.
         
         ---
         
         This structure applies recent best practices: clear intent, hierarchical structure, explicit constraints, added context, and direct language. If you have a specific prompt to test, simply insert it in the placeholder and run this meta-prompt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment