1.5 KiB
1.5 KiB
Prompting Patterns
You are here: AI Docs Home > Cross-Platform AI Usage > Prompting Patterns
Contents
- Why Prompt Patterns Matter
- Prompt Template
- Common Prompt Patterns
- Next Steps
Why Prompt Patterns Matter
Good prompt patterns reduce rework. They tell the assistant exactly what to change, what not to change, and what output you expect.
Prompt Template
Use this structure for most requests:
- Goal: The specific outcome you want.
- Scope: The file or function to change.
- Constraints: What must stay the same.
- Output: What you want returned (code only, bullets, tests, and so on).
Example prompt:
Goal: Refactor validation logic for readability.
Scope: Only ValidationService.swift.
Constraints: Keep behavior and public API unchanged.
Output: Return code changes and a short list of tests to update.
Common Prompt Patterns
- Refactor safely: Example prompt:
Refactor this file to improve readability without changing behavior.
- Add tests: Example prompt:
Add unit tests for this service. Keep the existing public API.
- Debug: Example prompt:
Explain this error and list likely fixes in priority order.
- Understand code: Example prompt:
Summarize what this module does and call out the top 3 risks.
Next Steps
- Read Prompting Anti-Patterns to avoid common mistakes.
- Use Starter Prompts when you need copy/paste examples.