Pattern Application Prompt

Showing ChatGPT an existing function, hook, or service from your codebase and asking it to write a new one following the exact same pattern. Produces better-integrated code than blank specification prompts.

Syntax

chatgpt
Here is an existing [function/hook/service]:
[paste existing code]

Following the exact same pattern:
- Same error handling
- Same return type structure
- Same TypeScript type style

Write a [new function] for [new entity].
[Entity: table, fields, filters]

Match the pattern exactly.

Example

chatgpt
Here is our existing useProjects hook:
[paste hook code]

Following the exact same pattern — TanStack Query
structure, error handling, TypeScript types —
write a useTasks hook.

Details:
- Table: tasks
- Fields: id, title, project_id, status, due_date
- Filter: project_id = [projectId parameter]
- Real-time: yes (same subscription approach)
- Auth: user_id = current auth user

Match the pattern exactly.