ref

Appendix C

Appendix C

Copy-paste templates for common coding tasks.

Appendix C: Prompt Templates

Copy and adapt these templates for common tasks.


Bug Fix Template

@file [path/to/file/with/bug] I'm getting this error: [PASTE FULL ERROR MESSAGE] The expected behavior is: [What should happen] The actual behavior is: [What's happening instead] Please identify the bug and provide a fix.

New Feature Template

@folder [path/to/relevant/folder] Create a new [component/function/endpoint] that: - [Requirement 1] - [Requirement 2] - [Requirement 3] It should follow the patterns used in [existing similar file]. [Any specific constraints or requirements]

Refactoring Template

@file [path/to/file/to/refactor] Refactor this [function/component/module] to: - [Goal 1 - e.g., improve readability] - [Goal 2 - e.g., reduce duplication] - [Goal 3 - e.g., improve performance] Keep the external interface the same. Don't change: [any constraints]

Code Review Template

@file [path/to/file/to/review] Review this code for: - Bugs or logic errors - Performance issues - Security concerns - Code style and readability For each issue found, explain: 1. What the issue is 2. Why it matters 3. How to fix it

Test Writing Template

@file [path/to/file/to/test] Write tests for this [function/component/class] that cover: - Happy path / normal usage - Edge cases: [list any specific edge cases] - Error handling Use [testing framework, e.g., Jest] and follow the patterns in [existing test file].

Debug Template

@file [path/to/relevant/code] I'm trying to debug why [describe the issue]. Here's what I've tried: 1. [Thing you tried] 2. [Another thing you tried] Here's the relevant output/logs: [PASTE LOGS] What should I check next?

Explanation Template

@file [path/to/code/to/explain] Explain what this code does: - What is its purpose? - How does it work step by step? - What are the key decisions and why? Assume I'm a [junior/senior] developer who is [new to this codebase / familiar with X but not Y].

Migration Template

@file [path/to/old/implementation] @file [path/to/new/patterns/or/docs] Migrate this code from [old approach] to [new approach]. Requirements: - Maintain the same functionality - Follow the patterns shown in [reference file] - [Any specific constraints] Please explain any tricky parts of the migration.

API Endpoint Template

@folder [path/to/api/folder] Create a new API endpoint: - Route: [e.g., POST /api/users/:id/settings] - Purpose: [what it does] - Input: [expected request body/params] - Output: [expected response format] - Auth: [auth requirements] Follow the patterns in [existing endpoint file]. Include input validation and error handling.

Component Template (React/Vue/etc.)

@folder [path/to/components] Create a new [ComponentName] component that: - [Visual/functional requirement 1] - [Visual/functional requirement 2] - [Visual/functional requirement 3] Props it should accept: - [prop1]: [type] - [description] - [prop2]: [type] - [description] Style it like [existing component] and include TypeScript types.

Quick One-Liners

Simple question:

@file [file] - What does [function/line] do?

Quick fix:

@file [file] - Fix the [specific issue] on line [X]

Add types:

@file [file] - Add TypeScript types to this file

Add error handling:

@file [file] - Add proper error handling to [function]

Improve naming:

@file [file] - Suggest better names for the variables and functions