Convert User Stories into Strict Acceptance Test Assertions

This prompt transforms vague business requirements into precise Given-When-Then test assertions with exact HTTP status codes and JSON payload structures for AI coding agents.

Agent prompt for Claude Code and Cursor

Prompt

Prompt
Act as a Senior QA Automation Engineer. Your job is to convert user stories into strict, executable acceptance test assertions. Before proceeding, ask me these 3 questions: 1. What is the user story or feature description? 2. What is the base API endpoint or service component involved? 3. What specific data schemas or status codes are required? Once I answer, provide the output. Rules: 1. Use Given-When-Then syntax for every scenario. 2. Define exact HTTP status codes for success and failure paths. 3. Include a specific JSON request body and expected response structure for each test. 4. Focus on edge cases like missing fields or invalid permissions. Output format: ## Test Scenario Name. ### Context. ### Assertions. 1. Given (state). 2. When (action). 3. Then (expected HTTP status and payload keys). This is technical documentation for test automation; do not include conversational filler.

Example output

Example for: a user registration API endpoint feature. ## Test: Successful User Registration. ### Context: Validates that a new user can sign up with correct credentials. ### Assertions: 1. Given a request body containing valid email, password, and username. 2. When a POST request is sent to /api/v1/users. 3. Then the response status must be 201 Created and the payload must contain user_id and created_at. ## Test: Invalid Email Format. ### Context: Validates that the system rejects malformed email addresses. ### Assertions: 1. Given a request body where email is missing the @ symbol. 2. When a POST request is sent to /api/v1/users. 3. Then the response status must be 400 Bad Request and the payload must contain an error_code equal to INVALID_EMAIL_FORMAT.

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Forces structured Given-When-Then format which AI agents parse reliably.
  • Ensures exact technical requirements like HTTP codes are defined upfront.
  • Eliminates ambiguity by requiring specific JSON payload keys in the output.

Use this when you have a feature requirement and need to write tests for Claude Code, Cursor, or GitHub Copilot. Copy the prompt into your chat window, answer the 3 questions, and paste the generated code directly into your test files.

Common edits

  • Add specific header requirements like Authorization: Bearer tokens if your API is secured.
  • Include database state assertions if your tests need to verify record persistence.

Reuse it: Use in a workflowAdapt in the builder

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

AI Coding AgentsClaude Code

Create Automated Verification Loops for Long-Running Coding Agents

Generate a deterministic shell pipeline that combines linting, isolated unit testing, and diff-budget monitoring to validate AI agent code changes.

AI Coding AgentsClaude Code

Design a Sandbox Security Policy for Autonomous Coding Agents

Generate a rigorous security policy for autonomous agents to define allowed shell commands, file access boundaries, and network restrictions.

AI Coding AgentsClaude Code

Generate Reproducible Bug Fix Specs for Coding Agents

Get a standalone reproduction test script and a precise technical plan to fix a bug, ensuring your AI agent stays focused and avoids unnecessary file changes.

AI Coding AgentsClaude Code

Create a Legacy Module Reference Sheet for Coding Agents

Compresses messy legacy source files into a dense markdown cheat sheet capturing public methods, hidden state changes, and side effects for coding agent contexts.

AI Coding AgentsClaude Code

Create a Verification Loop Script for AI Coding Agents

Generate a lightweight bash verification pipeline that validates linters, scoped test suites, and git diff budgets before an agent declares a task complete.