Prompt Engineering
Best practices for writing effective prompts
Effective prompts are the foundation of successful AI-assisted development. Clear, specific requests with appropriate context enable Verdent to deliver accurate, relevant results.
What You'll Learn
- Best practices for writing effective prompts
- How to provide context and avoid common mistakes
- Advanced techniques like @-mentions and subagent delegation
- Examples of well-structured prompts
What Makes an Effective Prompt
Effective prompts are clear, specific, and provide necessary context for Verdent to understand your intent and deliver accurate results.
Key Principles:
- Be Specific - State exactly what you need, not vague requests
- Include Details - Provide technical specs when you have preferences
- Specify Scope - Clarify which files/components are involved
- Provide Context - Help Verdent understand your architecture
- State Outcomes - Describe what success looks like
Example transformations:
| Bad | Good |
|---|---|
| Fix the code | Add input validation to the email field in ContactForm.js to reject invalid email formats |
| Add authentication | Add JWT authentication using the same middleware pattern as auth.js, store tokens in httpOnly cookies |
Common Prompting Mistakes
Make the app betterProblem: Verdent doesn't know what improvements you want.
Solution: Specify exactly what needs improvement.
Add authenticationProblem: Verdent might implement JWT when you use OAuth, or vice versa.
Solution: Specify implementation approach and existing patterns.
Build the entire user management system with authentication, authorization, profiles, settings, and admin dashboardProblem: Complex multi-system requests are harder to execute correctly.
Solution: Break into smaller tasks - start with authentication, then authorization, then profiles.
Update the validation logicProblem: Unclear which files or validation to modify.
Solution: Specify scope: "Update validation in UserController.js to require strong passwords"
Press Shift+Tab or Ctrl+. to switch to Plan Mode for complex changes.
Well-Structured Prompt Examples
Create a POST /api/tasks endpoint that:
- Accepts task title (required), description (optional), and category_id (required)
- Validates that the category exists in the database
- Returns 400 if validation fails with descriptive error messages
- Saves the task to the database and returns the created task with 201 status
- Add this to the existing tasks router in routes/tasks.jsWhat makes this effective:
- Clear requirements for inputs and validation
- Specific file locations for implementation
- Expected HTTP status codes and error handling
Fix the race condition in payment processing at checkout. When multiple users submit payments simultaneously, some transactions fail with "duplicate order ID" errors. The issue appears to be in PaymentController.js around line 45. Implement proper locking or use UUID generation.What makes this effective:
- Clear problem description with symptoms
- Specific location of issue (file and line number)
- Suggested solution approaches
Refactor the authentication middleware in middleware/auth.js to use JWT tokens instead of session cookies:
- Replace session validation with JWT verification
- Store tokens in httpOnly cookies
- Maintain the existing user object structure that routes expect
- Don't change authorization rulesWhat makes this effective:
- Clear goal (JWT instead of sessions)
- Specific file to refactor
- Explicit constraints (what should NOT change)
Write unit tests for the UserService class in services/UserService.js. Cover:
- User creation with valid and invalid data
- Email validation edge cases
- Password hashing verification
- Error handling for database failures
Use Jest and follow the testing patterns in existing service testsWhat makes this effective:
- Specific class/file to test
- Complete list of scenarios to cover
- Testing framework specified
Advanced Prompting Techniques
Reference specific files or subagents:
@auth.js @UserController.js Refactor authentication to use the same validation patternBenefits:
- Ensures Verdent has exact context
- Prevents ambiguity in large codebases
- Essential when referencing patterns from one file to apply in another
Press Shift+Tab or Ctrl+. to switch to Plan Mode before large changes:
Refactor the entire API layer to use TypeScriptBenefits:
- Review approach before any files are modified
- Prevents costly mistakes in large refactorings
- Iterate on the plan before execution begins
Delegate specialized tasks to subagents:
@verifier Validate the authentication logic in the middlewareBuilt-in Subagent:
@verifier- Quick code checks and validation
Build on previous responses progressively:
Initial: "Create a dashboard component"
Follow-up: "Add real-time data updates using WebSockets"
Follow-up: "Now add filtering and sorting capabilities"Benefits:
- Incremental development with testing at each step
- Reduces risk by validating each layer before adding complexity
Specify what NOT to change:
Add caching to the API endpoints, but:
- Don't modify the authentication middleware
- Keep the existing error handling unchanged
- Maintain backward compatibility with mobile clientsBenefits:
- Prevents modifying critical systems
- Avoids costly rework from breaking stable functionality