Five essential components of an effective prompt:
| Component | Purpose | Example |
|---|---|---|
| Role | Set persona/expertise | You are a senior Python developer... |
| Task | Clear action to perform | Review the following code for bugs... |
| Context | Background information | This runs on Python 3.12 with FastAPI... |
| Format | Output structure | Respond as a numbered list... |
| Constraints | Limits and requirements | Keep under 200 words. No jargon. |
You are a senior Python developer.
Review the following FastAPI route for security issues.
Context: This is a public API endpoint handling user login.
Format: List each issue with Severity (High/Med/Low) and a fix.
Constraint: Focus on security only, not code style.
```python
@app.post('/login')
def login(username: str, password: str):
user = db.query(f"SELECT * FROM users WHERE name='{username}'")
```