GPT Prompt Refiner
Refine prompts to get better results from GPT models by applying OpenAI's recommended patterns.
When to Use
Invoke this skill when you have a task for GPT that:
-
Requires a specific persona or expertise
-
Involves procedural steps
-
Needs structured output
-
Benefits from explicit examples
Refinement Process
Step 1: Analyze the Draft Prompt
Review the user's prompt for:
-
Clear role/persona definition
-
Step-by-step breakdown (if procedural)
-
Output format specification
-
Concrete examples
Ask clarifying questions if any of these are missing.
Step 2: Apply GPT-Specific Patterns
Role framing: GPT models respond well to clear role definitions. Start with: "You are a [specific role] working on [specific context]..."
Numbered procedures: Break complex tasks into numbered steps that build on each other.
Output specification: Be explicit about format: "Return as JSON", "Format as markdown with headers", etc.
Chain of thought: For reasoning tasks, add: "Think through this step by step."
Step 3: Structure the Prompt
Effective order for GPT:
-
Role definition (who/what)
-
Context (background info)
-
Task (what to do)
-
Steps (how to do it, if procedural)
-
Output format (what to return)
-
Examples (optional clarification)
Step 4: Output the Refined Prompt
Present the improved prompt with:
-
Clear role statement
-
Numbered steps where applicable
-
Explicit output requirements
-
An explanation of what changed and why
Example Transformations
Example 1: Security Review
Before:
Review this code for security issues
After:
You are a senior security engineer conducting a security audit of a Node.js payment processing service.
Context: This service handles credit card transactions and communicates with Stripe's API. It runs in AWS ECS with access to a PostgreSQL database.
Task: Review the code in src/payments/ for security vulnerabilities.
Complete these steps:
- Check for proper input validation on all endpoints
- Verify secrets are not hardcoded or logged
- Review authentication and authorization logic
- Check for SQL injection and XSS vulnerabilities
- Verify proper error handling that doesn't leak sensitive info
- Review rate limiting and abuse prevention
Output format: Return a security report in markdown with these sections:
- Critical: Issues that must be fixed before deployment
- High: Significant risks that should be addressed soon
- Medium: Improvements to consider
- Recommendations: General security enhancements
For each issue, include:
- File and line number
- Description of the vulnerability
- OWASP category if applicable
- Recommended fix with code example
Example 2: Refactoring Task
Before:
Refactor this function to be cleaner
After:
You are a senior TypeScript developer focused on code quality and maintainability.
Context: This function in src/utils/dataProcessor.ts handles data transformation for our analytics pipeline. It currently has high cyclomatic complexity and is difficult to test.
Task: Refactor the processData function to improve readability and testability.
Steps:
- Analyze the current function and identify code smells
- Extract logical units into smaller, focused functions
- Add TypeScript types for all parameters and return values
- Ensure each extracted function is independently testable
- Preserve all existing behavior (no functional changes)
- Add JSDoc comments for public functions
Output format:
- Brief analysis of issues in the current code (3-5 bullet points)
- The refactored code
- List of extracted functions with their responsibilities
- Example test cases for the new functions
Example 3: API Design
Before:
Design an API for user management
After:
You are an API architect designing a RESTful API for a B2B SaaS application.
Context: We need user management endpoints for our multi-tenant application. Users belong to organizations, and permissions are role-based (admin, member, viewer).
Task: Design a complete REST API for user management operations.
Requirements:
- CRUD operations for users
- Organization membership management
- Role assignment and permission checking
- Invitation flow for new users
- Password reset functionality
Constraints:
- Follow REST best practices
- Use consistent naming conventions
- Support pagination for list endpoints
- Include proper error responses
Output format: For each endpoint, provide:
- HTTP method and path
- Request body schema (if applicable)
- Response schema
- Possible error codes
- Example request/response
Use OpenAPI 3.0 YAML format for the specification.
Example 4: Debugging
Before:
Why is this test failing?
After:
You are a senior developer debugging a failing test in a React application.
Context: The test in UserProfile.test.tsx is failing intermittently in CI but passes locally. The component fetches user data and displays it.
Task: Analyze the test and identify the root cause of the flaky failure.
Think through this step by step:
- What async operations does the test involve?
- Are there any race conditions?
- Is the test properly waiting for state updates?
- Are mocks set up correctly?
- Could there be timing issues with the test environment?
Output format:
- Most likely root cause (1-2 sentences)
- Evidence supporting your diagnosis
- Recommended fix with code
- How to verify the fix works
Tips for Best Results
-
Define the role clearly - "senior security engineer" > "developer"
-
Number your steps - GPT follows ordered lists reliably
-
Specify output format explicitly - JSON, markdown, etc.
-
Use "Think through this step by step" for reasoning tasks
-
Provide examples when the expected format is complex
-
Include constraints to prevent scope creep