0

Example — Feature-to-Prompt Translator

Demonstration of prompts/ai-coding/feature-to-prompt.txt with the variables filled in. Illustrative example of what such a prompt can produce. The response was generated by an AI in one pass — not guaranteed, and not professional advice. All na

Prompt · برومبت

Works with

claude-code (compatible), claude (compatible), codex (compatible), chatgpt (compatible), gemini-cli (compatible), cursor (compatible), copilot (compatible), opencode (compatible), amp (compatible), roo (compatible), kiro (compatible), goose (compatible), junie (compatible), trae (compatible), cline (compatible), continue (compatible), antigravity (compatible), windsurf (compatible), augment (compatible), qwen-code (compatible), aider (compatible)

Content

Example — Feature-to-Prompt Translator

Demonstration of [prompts/ai-coding/feature-to-prompt.txt](../prompts/ai-coding/feature-to-prompt.txt) with the variables filled in. Illustrative example of what such a prompt can produce. The response was generated by an AI in one pass — not guaranteed, and not professional advice. All names, numbers, and details are fictional (Egypt-plausible where relevant).

Prompt (filled)

You are a prompt engineer for AI coding tools (Copilot, Cursor, ChatGPT, Claude). Convert my rough feature idea into a precise build prompt the AI can execute in one shot.
MY DETAILS
- The feature in my words: users can save posts to read later
- Stack, framework, and versions: Next.js 15, Supabase, Tailwind
- Existing patterns in my codebase it must match (state management, folder layout): server actions + optimistic UI pattern
- What "done" looks like (behaviors, edge cases): works logged-in only, undo toast, empty state
YOUR TASK — answer in this exact order:
1. THE REFINED FEATURE: my idea restated precisely — inputs, outputs, states (empty, loading, error, success), and permissions.
2. THE BUILD PROMPT: a copy-paste prompt block containing — context (stack + server actions + optimistic UI pattern), the exact files to create/modify, step-by-step implementation order, edge cases from works logged-in only, undo toast, empty state, and what NOT to do (no new dependencies, no refactors beyond scope).
3. THE ACCEPTANCE LIST: 5 checkable statements to verify the output against ("form disables submit while loading").
4. SCOPE GUARD: the one-line instruction that stops the AI from "helpfully" rewriting unrelated code.
5. FOLLOW-UP PROMPTS: the 2 most likely follow-ups (fix a failing case, add a test) pre-written.
RULES
- If critical information is missing, ask up to 3 clarifying questions first; otherwise proceed with clearly-stated assumptions.
- The prompt names exact file paths and function names — vague prompts get vague code.
- Edge cases are explicit bullets, not implied.
- One feature per prompt; if my idea bundles three, split it into three prompts and say so.
OUTPUT FORMAT
- Five numbered sections: refined feature (states + permissions listed), one copy-paste build-prompt block, exactly 5 acceptance statements, scope-guard line, 2 pre-written follow-ups. Lead with THE REFINED FEATURE.

Example AI response

1. THE REFINED FEATURE A "Save for later" bookmark on each post card and post page. Logged-in users can save/unsave any post; saved posts appear on a /saved page ordered newest-first. Unauthenticated clicks redirect to /login?next=<current path>. States: optimistic toggle with undo toast (5s), loading spinner on initial /saved load, empty state with a "browse posts" link, error toast if the server action fails (UI reverts). Permission: any authenticated user saves only for themselves.

2. THE BUILD PROMPT

Stack: Next.js 15 (App Router), Supabase (Postgres + auth), Tailwind.
Follow the existing patterns: server actions in app/actions/, optimistic UI
with useOptimistic, cn() helper for classes.

Feature: post bookmarks ("save for later").

Files:
1. supabase/migrations/<timestamp>_post_bookmarks.sql — table post_bookmarks
   (user_id uuid references auth.users, post_id uuid references posts,
   created_at timestamptz default now(), primary key (user_id, post_id));
   enable RLS: select/insert/delete only where user_id = auth.uid().
2. app/actions/bookmarks.ts — toggleBookmark(postId) server action:
   insert or delete, return the new state; throw typed errors.
3. components/SaveButton.tsx — client component: optimistic toggle +
   undo toast (5s window deletes the bookmark on dismiss).
4. app/saved/page.tsx — server component: list the user's saved posts
   newest-first; empty state with a link to /.
5. components/PostCard.tsx — add <SaveButton postId={...} />.

Edge cases: double-click toggles twice (end state = start state); anonymous
click → router.push('/login?next=' + pathname); server error → toast +
revert; saving your own post is allowed.

Do NOT: add any dependency, change the auth flow, or refactor anything
outside the five files above.

3. THE ACCEPTANCE LIST

  1. Anonymous user clicking Save lands on /login?next=/posts/<slug>.
  2. Clicking Save shows the saved state immediately, before the server responds.
  3. Dismissing the undo toast within 5s removes the bookmark.
  4. /saved with no bookmarks shows the empty state, not an error.
  5. The generated RLS policy blocks reading another user's bookmarks (test with two accounts).

4. SCOPE GUARD "Modify only the files listed. If another file seems related, propose the change in a comment instead of applying it."

5. FOLLOW-UP PROMPTS

  • "The undo toast double-deletes when dismissed twice — make toggleBookmark idempotent and guard the toast action, then show me the diff."
  • "Add a Vitest for toggleBookmark: anon user call throws AuthRequiredError; member toggle inserts then deletes. Mock Supabase client."

--- *Generated for demonstration as part of Prompt Stash. Outputs vary by model and run.*

Source and license

Source
Prompt Stash
Original
Ziadtareks/prompt-stash/examples/ai-coding-feature-to-prompt.md
License
MIT