Loading...
Loading...
Generate and improve prompts using best practices for OpenAI GPT-5 and other LLMs. Apply advanced techniques like chain-of-thought, few-shot prompting, and progressive disclosure.
npx skill4agent add zircote/.claude openai-prompt-engineerRole: You are a senior Python developer
Task: Review this code for security vulnerabilities
Constraints:
- Focus on OWASP Top 10
- Provide specific line numbers
- Suggest fixes with code examples
Output format: Markdown with severity ratingsInput: "User clicked login"
Output: "USER_LOGIN_CLICKED"
Input: "Payment processed successfully"
Output: "PAYMENT_PROCESSED_SUCCESS"
Input: "Email verification failed"
Output: [Your turn]<output_format>
<summary>One sentence overview</summary>
<details>
<point>Key finding 1</point>
<point>Key finding 2</point>
</details>
<recommendation>Specific action to take</recommendation>
</output_format>[ROLE/CONTEXT]
You are [specific role with relevant expertise]
[TASK]
[Clear, specific task description]
[CONSTRAINTS]
- [Limitation 1]
- [Limitation 2]
[FORMAT]
Output should be [exact format specification]
[EXAMPLES - if using few-shot]
[Example 1]
[Example 2]
[THINK STEP-BY-STEP - if complex reasoning]
Before answering, [thinking instruction]Problem: A store has 15 apples. They sell 60% in the morning and
half of what's left in the afternoon. How many remain?
Please solve this step-by-step:
1. Calculate morning sales
2. Calculate remaining after morning
3. Calculate afternoon sales
4. Calculate final remainingConvert casual text to professional business tone:
Input: "Hey! Thanks for reaching out. Let's chat soon!"
Output: "Thank you for your message. I look forward to our conversation."
Input: "That's a great idea! I'm totally on board with this."
Output: "I appreciate your suggestion and fully support this initiative."
Input: "Sounds good, catch you later!"
Output: [Model completes]Question: What are the security implications of storing JWTs
in localStorage?
Let's think step by step:Analyze this code for issues. Structure your response as:
<analysis>
<security_issues>
<issue severity="high|medium|low">
<description>What's wrong</description>
<location>File and line number</location>
<fix>How to fix it</fix>
</issue>
</security_issues>
<performance_issues>
<!-- Same structure -->
</performance_issues>
<best_practices>
<suggestion>Improvement suggestion</suggestion>
</best_practices>
</analysis>Stage 1: "Analyze this codebase structure and list the main components"
[Get response]
Stage 2: "Now, for the authentication component you identified,
show me the security review"
[Get response]
Stage 3: "Based on that review, generate fixes for the high-severity issues"ROLE: Senior TypeScript Developer
TASK: Implement user authentication service
CONSTRAINTS:
- Use JWT with refresh tokens
- TypeScript with strict mode
- Include comprehensive error handling
- Follow SOLID principles
OUTPUT: Complete TypeScript class with JSDoc comments
REASONING_EFFORT: high (for complex business logic)"Implement this feature step-by-step, asking for confirmation
before each major decision"
OR
"Complete this task end-to-end without asking for guidance.
Persist until fully handled.""Provide a concise implementation (under 100 lines) focusing
only on core functionality"<instruction>
Review this pull request for security issues
</instruction>
<code>
[Code to review]
</code>
<focus_areas>
- SQL injection vulnerabilities
- XSS attack vectors
- Authentication bypasses
- Data exposure risks
</focus_areas>
<output_format>
For each issue found, provide:
1. Severity (Critical/High/Medium/Low)
2. Location
3. Explanation
4. Fix recommendation
</output_format>Think through this architecture decision step by step:
1. First, identify the requirements
2. Then, list possible approaches
3. Evaluate trade-offs for each
4. Make a recommendation with reasoningBAD: "Make the response professional"
GOOD: "Use formal business language, avoid contractions,
address the user as 'you', keep sentences under 20 words""Write some code for user authentication""Write a TypeScript class called AuthService that:
- Accepts email/password credentials
- Validates against a User repository
- Returns a JWT token on success
- Throws AuthenticationError on failure
- Includes comprehensive JSDoc comments
- Follows dependency injection pattern""Convert these variable names to camelCase""Convert these variable names to camelCase:
user_name → userName
total_count → totalCount
is_active → isActive
Now convert:
order_status →
created_at →
max_retry_count →""Analyze this code for problems""Analyze this code and output in this format:
## Security Issues
- [Issue]: [Description] (Line X)
## Performance Issues
- [Issue]: [Description] (Line X)
## Code Quality
- [Issue]: [Description] (Line X)
## Recommendations
1. [Priority 1 fix]
2. [Priority 2 fix]""Build a complete e-commerce backend with authentication,
payments, inventory, and shipping""Let's build this in stages:
Stage 1: Design the authentication system architecture
[Get response, review]
Stage 2: Implement the auth service
[Get response, review]
Stage 3: Add payment processing
[Continue...]""Using the prompt-engineer skill, create a prompt for:
[Describe your task and requirements]""Using the prompt-engineer skill, improve this prompt:
[Your current prompt]
Goal: [What you want to achieve]
Model: [GPT-5 / Claude / Other]""Using the prompt-engineer skill, analyze this prompt:
[Your prompt]"ROLE: Senior Software Engineer conducting PR review
REVIEW THIS CODE:
[code block]
REVIEW CRITERIA:
1. Security vulnerabilities (OWASP Top 10)
2. Performance issues
3. Code quality and readability
4. Best practices compliance
5. Test coverage gaps
OUTPUT FORMAT:
For each issue found:
- Severity: [Critical/High/Medium/Low]
- Category: [Security/Performance/Quality/Testing]
- Location: [File:Line]
- Issue: [Clear description]
- Impact: [Why this matters]
- Fix: [Specific code recommendation]
At the end, provide:
- Overall assessment (Approve/Request Changes/Comment)
- Summary of critical items that must be fixedROLE: Technical writer with API documentation expertise
TASK: Generate API documentation for this endpoint
ENDPOINT DETAILS:
[code/specs]
DOCUMENTATION REQUIREMENTS:
- Target audience: Junior to mid-level developers
- Include curl and JavaScript examples
- Explain all parameters clearly
- Show example responses with descriptions
- Include common error cases
- Add troubleshooting section
FORMAT:
# [Endpoint Name]
## Overview
[One paragraph description]
## Endpoint
`[HTTP METHOD] /path`
## Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
## Request Example
```bash
[curl example][example with inline comments]
### Example 3: Data Analysis
**Task:** Analyze data and provide insights
**Optimized Prompt:**
## Best Practices Summary
### DO ✅
- **Be specific** - Exact requirements, not vague requests
- **Use structure** - Organize with clear sections
- **Provide examples** - Show what you want (few-shot)
- **Request reasoning** - "Think step-by-step" for complex tasks
- **Define format** - Specify exact output structure
- **Test iteratively** - Refine based on results
- **Match to model** - Use model-specific techniques
- **Include context** - Give necessary background
- **Handle edge cases** - Specify exception handling
- **Set constraints** - Define limitations clearly
### DON'T ❌
- **Be vague** - "Write something about X"
- **Skip examples** - When patterns need to be matched
- **Assume format** - Model will choose unpredictably
- **Overload single prompt** - Break complex tasks into stages
- **Ignore model differences** - GPT-5 and Claude need different approaches
- **Give up too soon** - Iterate on prompts
- **Mix instructions** - Keep separate concerns separate
- **Forget constraints** - Specify ALL requirements
- **Use ambiguous terms** - "Good", "professional", "better" without definition
- **Skip testing** - Always validate outputs
## Quick Reference
### Prompt Template (Universal)
### When to Use Each Technique
| Technique | Best For | Example Use Case |
|-----------|----------|------------------|
| Chain-of-Thought | Complex reasoning | Math, logic puzzles, multi-step analysis |
| Few-Shot | Pattern matching | Classification, style transfer, formatting |
| Zero-Shot | Simple, clear tasks | Direct questions, basic transformations |
| Structured (XML) | Parsed output | Data extraction, API responses |
| Progressive Disclosure | Large tasks | Full implementations, research |
| Role-Based | Expert knowledge | Code review, architecture decisions |
### Model Selection Guide
**Use GPT-5 when:**
- Need strong reasoning
- Agentic behavior helpful
- Code generation focus
- Latest knowledge needed
**Use Claude when:**
- Very long context (100K+ tokens)
- Detailed instruction following
- Safety-critical applications
- Prefer XML structuring
## Resources
All reference materials included:
- GPT-5 specific techniques and patterns
- Claude optimization strategies
- Advanced prompting patterns
- Optimization and improvement frameworks
## Summary
Effective prompt engineering:
- **Saves time** - Get right results faster
- **Reduces costs** - Fewer API calls needed
- **Improves quality** - More accurate, consistent outputs
- **Enables complexity** - Tackle harder problems
- **Scales knowledge** - Capture best practices
Use this skill to create prompts that:
- Are clear and specific
- Use proven techniques
- Match your model
- Get consistent results
- Achieve your goals
---
**Remember:** A well-crafted prompt is worth 10 poorly-attempted ones. Invest time upfront for better results.