Prompt Patterns

Reference intermediate

Feature Development

New Feature (Full)

I want to add [FEATURE NAME].

Context:
- [relevant existing code or architecture]
- [dependencies or related features]

Requirements:
- [requirement 1]
- [requirement 2]
- [requirement 3]

Constraints:
- [what NOT to do]
- [libraries to use or avoid]
- [patterns to follow]

Think about the approach first, then implement step by step.

Quick Feature

Add [FEATURE] to [FILE/COMPONENT].
It should [BEHAVIOUR].
Follow the same pattern as [EXISTING EXAMPLE].

Debugging

Error Diagnosis

I'm getting this error:
[PASTE FULL ERROR + STACK TRACE]

It happens when [TRIGGER/STEPS].
Expected: [WHAT SHOULD HAPPEN]
Actual: [WHAT HAPPENS INSTEAD]

Relevant files: [FILE PATHS]
I've already checked: [WHAT YOU RULED OUT]

Logic Bug

[FUNCTION/COMPONENT] produces wrong output.

Input: [SPECIFIC INPUT]
Expected output: [WHAT IT SHOULD RETURN]
Actual output: [WHAT IT RETURNS]

Walk through the execution step by step and find where it goes wrong.

Intermittent Bug

[BEHAVIOUR] happens sometimes but not always.

Pattern I've noticed:
- Happens when: [CONDITIONS]
- Doesn't happen when: [CONDITIONS]
- Frequency: [HOW OFTEN]

Suspect area: [WHERE YOU THINK THE BUG IS]
Could be: [YOUR HYPOTHESIS — race condition? timing? state?]

Refactoring

Extract and Reuse

The following logic is duplicated in [FILE1], [FILE2], and [FILE3]:
[DESCRIBE THE DUPLICATED LOGIC]

Extract it into a shared utility in [TARGET LOCATION].
Update all three files to use the shared version.
Make sure the existing tests still pass.

Rename Across Codebase

Rename [OLD_NAME] to [NEW_NAME] everywhere in the project.
Update: imports, variable names, function calls, file names, tests.
Preserve functionality — this is purely a naming change.

Restructure

Move [WHAT] from [CURRENT LOCATION] to [NEW LOCATION].
Reason: [WHY THE MOVE]
Update all imports and references across the project.

Testing

Generate Tests

Write tests for [FILE/FUNCTION].

Cover:
- Happy path with valid input
- Error cases (null, undefined, empty, invalid)
- Edge cases ([SPECIFIC EDGES])
- [ANY SPECIFIC SCENARIOS]

Use [TEST FRAMEWORK]. Follow the pattern in [EXISTING TEST FILE].

Fix Failing Test

This test is failing:
[PASTE TEST + ERROR OUTPUT]

The code under test is in [FILE].
Recent changes: [WHAT CHANGED THAT MIGHT HAVE BROKEN IT]

Is the test wrong or is the code wrong? Fix whichever is incorrect.

Code Review

Self-Review

Review my changes (git diff against main) for:
1. Bugs or logic errors
2. Security vulnerabilities (injection, auth, data exposure)
3. Missing error handling
4. Performance issues
5. Inconsistency with project patterns

Only report real issues. For each issue, explain WHY it's a problem.

Focused Review

Review [FILE] specifically for [CONCERN]:
- Security: injection, auth bypass, data leaks
- Performance: N+1, memory leaks, blocking operations
- Correctness: off-by-one, null handling, race conditions

Documentation

Generate Docs

Add documentation to [FILE]:
- JSDoc for all exported functions
- @param and @returns with types
- Brief description of what each function does
- Usage example for complex functions

Don't modify any logic — documentation only.

Explain Code

Explain [FILE/FUNCTION] to me:
1. What it does (high level)
2. How it works (step by step)
3. Why it's implemented this way
4. Any non-obvious behaviour or edge cases

Architecture

Design Discussion

I want to build [FEATURE/SYSTEM].

Requirements:
- [LIST OF REQUIREMENTS]

Before implementing:
1. What are 2-3 approaches we could take?
2. What are the trade-offs of each?
3. Which do you recommend and why?
4. What files would each approach touch?

Plan Then Execute

PLAN ONLY (don't implement yet):

Task: [WHAT NEEDS TO BE DONE]
Context: [CURRENT STATE]

Tell me:
1. Which files need to change
2. What changes to each file
3. What order to make changes
4. Any risks or considerations

I'll review the plan then tell you to execute.

Git Workflows

Commit

Stage all my changes and generate a conventional commit message.
Use format: type(scope): description
Types: feat, fix, refactor, docs, test, chore
Show the message before committing.

PR Description

Generate a PR description for this branch (compared to main).
Include:
- Summary (2-3 sentences)
- Changes (bullet list)
- Testing instructions
- Notes for reviewers

Conflict Resolution

I have merge conflicts after rebasing on main.
For each conflicted file:
1. Explain what both sides changed
2. Recommend how to resolve (keep both intents)
3. Apply the resolution

Automation

Batch Processing

For every file matching [PATTERN] in [DIRECTORY]:
[WHAT TO DO TO EACH FILE]

Constraints:
- [SAFETY GUARDRAILS]
- Skip files that already have [CONDITION]
- Don't modify tests

Migration

Migrate all [OLD PATTERN] to [NEW PATTERN].

Old: [EXAMPLE OF OLD CODE]
New: [EXAMPLE OF NEW CODE]

Apply across all files in [SCOPE].
Show me a count of changes before applying.