prompting templates practical

5 Prompts That Actually Work (Copy These)

Stop writing vague prompts. Here are 5 battle-tested templates you can copy and customize right now.

· VibeWerks

5 Prompts That Actually Work

Tired of mediocre AI output? The problem is the prompt, not the AI.

PromptUse When
Feature BuilderAdding new features
Bug SquasherSomething’s broken
RefactorerCode needs cleanup
ExplainerDon’t understand code
Test WriterNeed tests

Here are 5 templates I use daily. Copy them. Customize them. Ship faster.

1. The Feature Builder

Use when: Adding a new feature to existing code.

I need to add [FEATURE] to my [FRAMEWORK] app.

Context:
- Tech stack: [LIST YOUR STACK]
- Existing patterns: [DESCRIBE OR REFERENCE FILE]
- This feature should: [REQUIREMENTS]

Constraints:
- Must work with existing [AUTH/DB/ETC]
- Follow the patterns in [FILE PATH]
- No new dependencies unless necessary

Start with [SPECIFIC STARTING POINT].

Example:

I need to add password reset to my Next.js app.

Context:
- Tech stack: Next.js 14, Prisma, NextAuth, Resend for email
- Existing patterns: See src/lib/auth.ts for auth helpers
- This feature should: Let users reset password via email link

Constraints:
- Must work with existing NextAuth setup
- Follow the patterns in src/app/api/auth
- No new dependencies unless necessary

Start with the API route for requesting a reset.

2. The Bug Squasher

Use when: Something’s broken and you can’t figure out why.

Bug: [DESCRIBE WHAT'S WRONG]

Expected: [WHAT SHOULD HAPPEN]
Actual: [WHAT ACTUALLY HAPPENS]

Reproduction:
1. [STEP 1]
2. [STEP 2]
3. [BUG OCCURS]

Relevant code:
[PASTE THE RELEVANT CODE]

Error message (if any):
[PASTE ERROR]

What I've tried:
- [ATTEMPT 1]
- [ATTEMPT 2]

Example:

Bug: Login redirect loops infinitely

Expected: User logs in and sees dashboard
Actual: Page keeps redirecting between /login and /dashboard

Reproduction:
1. Go to /login
2. Enter valid credentials
3. Click submit
4. Infinite redirect loop

Relevant code:
[middleware.ts code]
[login route code]

Error message: None (just redirects forever)

What I've tried:
- Clearing cookies
- Checking session in console (shows valid session)

3. The Refactorer

Use when: Code works but needs to be cleaner.

Refactor this code to [GOAL].

Current code:
[PASTE CODE]

Goals:
- [SPECIFIC IMPROVEMENT 1]
- [SPECIFIC IMPROVEMENT 2]
- [SPECIFIC IMPROVEMENT 3]

Keep:
- [WHAT MUST STAY THE SAME]
- [EXTERNAL INTERFACE/API]

Don't:
- [WHAT TO AVOID]

Example:

Refactor this code to be more readable and testable.

Current code:
[200-line function]

Goals:
- Break into smaller functions (max 20 lines each)
- Extract magic numbers into named constants
- Add TypeScript types

Keep:
- Same input/output behavior
- Same function name and signature

Don't:
- Add new dependencies
- Change the public API

4. The Explainer

Use when: You inherited code you don’t understand.

Explain this code like I'm [EXPERIENCE LEVEL].

Code:
[PASTE CODE]

Specifically, I want to understand:
1. What is the main purpose?
2. What are the inputs and outputs?
3. [SPECIFIC CONFUSING PART]
4. Are there any gotchas or edge cases?

Then suggest improvements if any are obvious.

Example:

Explain this code like I'm familiar with JavaScript but new to RxJS.

Code:
[complex RxJS observable chain]

Specifically, I want to understand:
1. What is the main purpose?
2. What are the inputs and outputs?
3. What does the switchMap do here vs mergeMap?
4. Are there any gotchas or edge cases?

Then suggest improvements if any are obvious.

5. The Test Writer

Use when: You need tests for existing code.

Write tests for this [FUNCTION/COMPONENT/MODULE].

Code to test:
[PASTE CODE]

Testing requirements:
- Framework: [JEST/VITEST/PYTEST/ETC]
- Style: [DESCRIBE ANY CONVENTIONS]
- Coverage goals: [WHAT TO COVER]

Test cases to include:
- Happy path: [NORMAL USAGE]
- Edge cases: [UNUSUAL INPUTS]
- Error cases: [WHAT SHOULD FAIL]

Mocking needs:
- [EXTERNAL DEPENDENCIES TO MOCK]

Example:

Write tests for this email validation function.

Code to test:
[validateEmail function]

Testing requirements:
- Framework: Vitest
- Style: Arrange-Act-Assert pattern
- Coverage goals: All branches

Test cases to include:
- Happy path: Valid email formats
- Edge cases: Empty string, very long emails, unicode
- Error cases: Invalid formats, null/undefined

Mocking needs:
- None (pure function)

Bonus: The Meta-Prompt

When you’re not sure what to ask:

I want to [HIGH LEVEL GOAL].

My situation:
- [CONTEXT]
- [CONSTRAINTS]
- [WHAT I'VE CONSIDERED]

Before we start coding:
1. What clarifying questions do you have?
2. What approach would you recommend?
3. What are the main risks or challenges?

This gets you thinking partners, not just code generators.


Quick Tips

  • Be specific — “Add error handling” → “Add try/catch that logs errors and returns user-friendly message”
  • Show don’t tell — Paste examples of existing patterns
  • State constraints — What can’t change? What’s off-limits?
  • Ask for options — “Show me 3 ways to do this” before committing

🎯 Use One Now

  1. Scroll up and find the prompt that matches your current task
  2. Copy the template
  3. Fill in the [BRACKETS] with your details
  4. Paste into your AI tool
  5. Ship something today

These prompts work. Now go use them.


Keep Learning

Guides:

Cheatsheets:

Tools: