unit-test-shifting-left-from-requirements
What This Skill Does
Generates unit tests and BDD scenarios directly from requirements, user stories, or PRDs — before any implementation code exists. Enables true shift-left testing by making tests the first artifact produced for a feature, not the last.
When to Apply This Skill
- A user story, acceptance criteria, or PRD is provided with no accompanying code
- A team wants tests ready before the developer starts implementation
- BDD / Gherkin scenarios are needed to align QA, dev, and product on expected behavior
- A feature's testability needs to be validated before implementation begins
TDD Framing
This skill operationalizes the Red phase of the Red-Green-Refactor cycle at scale. Every test skeleton produced here is a failing test by design — it cannot pass until the developer writes the implementation. Outputs from this skill should be committed to the repository before any implementation code is written, making the failing tests the formal definition of done for the feature.
Atomic Skills to Load First
Read these files before executing any step:
-
../unit-test-generating-unit-tests/SKILL.md— Test matrix methodology and AAA pattern applied in spec-driven mode: derive test cases from acceptance criteria rather than from code paths -
../unit-test-authoring-test-plans/SKILL.md— BDD / Gherkin scenario format (Feature / Scenario / Given / When / Then) used to produce human-readable scenario documents alongside test skeletons
Execution Steps
Read references/index.md before executing any step.
Step 1 — Parse Requirements for Testable Criteria
Read the provided input (user story, PRD, acceptance criteria) and extract:
- Explicit acceptance criteria ("system shall...", "given... when... then...")
- Implicit behavioral rules buried in prose descriptions
- Edge cases and error conditions mentioned in requirements
- Out-of-scope statements (note these — do not generate tests for them)
Produce a numbered list of testable statements before writing any test code.
Step 2 — Build the Test Case Matrix
For each testable statement, define:
| # | Requirement Source | Condition | Expected Behavior | Category |
|---|---|---|---|---|
| 1 | AC-3 | Valid user logs in | JWT token returned | Happy |
| 2 | AC-3 | Wrong password | 401 returned | Error |
Use the test matrix approach from ../unit-test-generating-unit-tests/SKILL.md.
Step 3 — Generate Test Skeletons
Produce test skeletons with:
- Correct function/method names following the naming convention
- ARRANGE / ACT / ASSERT sections stubbed out
- TODO comments where implementation-specific values are not yet known
- Placeholder mocks only for true externalities (DB, API, file, clock) — not internal logic
- Fixed seeds for any randomness; mocked time for any date/time assertions
- One behavior per test — if a requirement yields three behaviors, write three skeletons
Each skeleton must be written so it will fail when run against an empty implementation. If a skeleton could accidentally pass without any code written, it is too weak — strengthen the assertion.
Example (pytest):
def test_login_when_valid_credentials_expects_jwt_token():
# ARRANGE
username = "alice"
password = "valid_password" # TODO: align with auth service contract
# ACT
result = login(username, password) # TODO: import once implemented
# ASSERT
assert result.token is not None # will fail until implemented
assert result.status_code == 200
Step 4 — Produce BDD / Gherkin Scenarios
For each test case, produce a corresponding Gherkin scenario following
the format in ../unit-test-authoring-test-plans/SKILL.md:
Feature: User Login
Scenario: Successful login with valid credentials
Given a registered user with username "alice"
When the user submits correct credentials
Then the system returns a JWT token
And the response status is 200
Scenario: Login fails with incorrect password
Given a registered user with username "alice"
When the user submits an incorrect password
Then the response status is 401
And the body contains "Invalid credentials"
Step 5 — Flag Ambiguities
Before delivering output, list any requirements that were:
- Too vague to produce a test for (request clarification)
- Contradictory with other requirements (flag for product review)
- Missing expected values or thresholds (mark with TODO)
Output Deliverables
test_<feature>_skeleton.<ext> <- test skeletons ready to fill in once code is written
gherkin_scenarios_<feature>.md <- BDD scenarios for QA and product alignment
requirements_coverage_map.md <- maps each requirement to one or more test IDs
ambiguities.md <- list of unclear or incomplete requirements
More from wizeline/sdlc-agents
editing-pptx-files
Use this action any time a .pptx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates, layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx filename, regardless of what they plan to do with the content afterward. If a .pptx file needs to be opened, created, or touched, use this action.
25editing-docx-files
Use this action whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of \"Word doc\", \"word document\", \".docx\", or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a \"report\", \"memo\", \"letter\", \"template\", or similar deliverable as a Word or .docx file, use this action. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
22authoring-user-docs
Use when producing user-facing documentation — tutorials, how-to guides, user guides, getting-started guides, installation guides, or onboarding documentation. Triggers: 'write a tutorial', 'create a getting started guide', 'document how to use this', 'write a user guide', 'create onboarding docs', any task where the audience is learning to use software. Always load authoring-technical-docs first.
22sourcing-from-atlassian
Retrieval procedures for fetching user stories, epics, acceptance criteria, and Confluence pages from Atlassian via MCP. Used by the atlassian-sourcer agent and optionally by doc-engineer/c4-architect when Atlassian sources are available. Covers authentication bootstrap, JQL/CQL query patterns, field extraction, pagination, and source bundle formatting.
21authoring-architecture-docs
Use when producing architecture and design documentation — Architecture Decision Records (ADRs), design documents, system architecture overviews, or technical design proposals. Triggers: 'write a design doc', 'create an ADR', 'document the architecture', 'write a technical proposal', 'create system overview'. Always load authoring-technical-docs first.
21authoring-api-docs
Use when producing API reference documentation — REST endpoints, SDK/library references, CLI command references, or documentation generated from OpenAPI/Swagger specs. Triggers: 'document this API', 'generate API reference', 'write SDK docs', 'document these endpoints', any task involving source code with HTTP handlers, route definitions, or OpenAPI specs. Always load authoring-technical-docs first.
20