Kiro for QA

The Testing Academy · Kiro · QA Automation

Kiro lessons for QA.

Every module from the course overview, expanded into a practical lesson with a QA rule, implementation steps, deterministic verification, guardrails, and a drill.

Part 1 · 4 lessons Part 2 · 4 lessons Part 3 · 4 lessons

Part 1 · Foundations

Specify Quality Before Code

Use steering and observable requirements to define the behavior, constraints, and evidence path before implementation tasks begin.

1.1

Kiro's Spec-Driven QA Model

Kiro specs connect requirements, design, tasks, and implementation. QA adds risk, observable acceptance, counterexamples, and an independent definition of done.

A spec is useful when each artifact narrows ambiguity without erasing important risk. Requirements state behavior, design explains the system decision, tasks create an executable plan, and tests prove selected outcomes. None of those files certifies the others merely because Kiro generated them together.

Choose the lightest workflow that preserves the needed evidence. A feature spec suits a new cross-file capability. A bugfix spec starts from observed incorrect behavior. Quick Plan suits a contained change whose risk and design are already understood. High-impact authentication or payment changes deserve the deeper chain.

Work typeStarting artifactQA evidence
New account lockoutFeature specEARS acceptance, properties, API and E2E tests
Lockout resets too earlyBugfix specCurrent/expected/unchanged behavior plus regression
Rename a test helperQuick PlanFocused tests and diff review
Unknown production symptomInvestigation firstReproduction and classified evidence before a spec
Do not spec an unclassified symptom as a solution

First distinguish product, test, data, environment, and requirement failures. A polished spec for the wrong cause accelerates the wrong work.

QA drill

Classify three backlog items as feature spec, bugfix spec, Quick Plan, or investigation. Defend each choice using impact, ambiguity, and evidence needs.

1.2

Workspace Setup, Privacy, and Trust Boundaries

Kiro can read project context, execute tools, run hooks, and connect MCP servers. Establish file, command, network, and credential boundaries first.

Open a disposable repository and review project trust, privacy settings, enabled tools, hooks, and MCP configuration. Keep customer data and production credentials out of the workspace. Use a synthetic application whose test command is deterministic on a clean checkout.

Kiro CLI V3 introduces capability-based permissions and standalone hooks; older embedded-hook or trust-all examples may not match the current engine. Record the surface you are teaching and review current documentation before copying configuration between IDE and CLI.

workspace preflight
git switch -c training/kiro-lockout
git status --short
npm ci
npx playwright test tests/auth/lockout.spec.ts --project=chromium

# CLI V3, when used:
kiro-cli --v3
# Inside the session: /spec new account-lockout

Trust review

  • Which paths may the agent read and write?
  • Which commands may execute without a separate approval?
  • Which MCP servers can send data outside the workstation?
  • Which hooks can block, mutate, or publish after a task?
  • Which person reviews the final diff and residual risk?
Synthetic canaries only

Test exclusion and logging controls with fake values. Never expose a live credential to prove that a boundary catches it.

QA drill

Create a one-page workspace trust map with read paths, write paths, commands, network tools, credentials, hooks, and the final human owner.

1.3

Steering Files and AGENTS.md for Test Standards

Steering gives Kiro durable project context. Inclusion rules keep specialized guidance attached only when the related files or tasks need it.

Store project-specific guidance in .kiro/steering/. Use always-included content sparingly for repository-wide facts. Use file-match guidance for Playwright, API, mobile, or performance conventions. Manual inclusion is useful for deep references that should enter context only on request.

Kiro also recognizes AGENTS.md. Avoid duplicating conflicting rules across files. State where a standard is authoritative, who owns it, and which deterministic command enforces it. Steering can describe locator policy; lint and tests must still catch violations.

.kiro/steering/playwright-testing.md
---
inclusion: fileMatch
fileMatchPattern: "tests/**/*.spec.ts"
---

# Playwright quality contract

- Trace every critical test to a requirement ID.
- Prefer role, label, or test-id locators.
- Never add fixed sleeps, force clicks, or silent retries.
- Preserve assertion strength and test count.
- Verify with lint, typecheck, and the focused Chromium project.
Live references reduce stale duplication

Where supported, reference the owned requirement or test-standard file instead of pasting a second copy that can drift.

Steering is context, not a gate

A critical prohibition needs an executable check or review policy. Do not assume prose was loaded or followed correctly.

QA drill

Write one file-match steering document for your primary automation framework and identify the lint, test, or review check behind every critical rule.

1.4

EARS Requirements With Observable Acceptance

EARS patterns turn vague behavior into trigger, condition, system response, and measurable outcome while keeping policy ownership visible.

Use ubiquitous requirements for behavior that always applies, event-driven requirements for triggers, state-driven requirements for a condition, and unwanted-behavior requirements for failures and abuse. The template is a clarity tool, not a substitute for domain review.

For login lockout, define threshold, counting window, lock duration, response privacy, audit event, and recovery. Avoid implementation details such as database column names unless they are genuine constraints. Every requirement needs an observable oracle available to the test level that owns it.

requirements.md excerpt
### AUTH-LOCK-01 - Threshold
WHEN a known account receives five consecutive invalid-password attempts within ten minutes,
THE authentication service SHALL reject subsequent password attempts for fifteen minutes.

### AUTH-LOCK-02 - Privacy
IF an account is locked,
THEN the public response SHALL remain indistinguishable from the normal invalid-credential response.

### AUTH-LOCK-03 - Recovery
WHEN the lock period expires,
THE authentication service SHALL accept a valid credential without administrator action.
RequirementBoundaryObservable oracle
AUTH-LOCK-01Attempts 4, 5, and 6Status, session absence, lock timestamp
AUTH-LOCK-02Known vs unknown emailSame public status and message class
AUTH-LOCK-03Just before/at/after expiryValid login and audit transition
Numbers need owners

A model can draft thresholds, but security and product owners approve the actual policy. Record that decision in the requirement revision.

QA drill

Rewrite one vague authentication requirement in EARS form, then derive the exact before, at, and after boundary observations a test must prove.

Part 2 · Traceability

Turn Specs Into Test Evidence

Review the requirement-design-task chain, add example and property tests, and keep proof linked to the exact behavior and revision.

2.1

Feature Specs: Requirements, Design, and Tasks

A feature spec creates a linked set of artifacts. QA reviews the transitions between them for missing risks, untestable design choices, and tasks with no evidence.

Kiro stores a spec under .kiro/specs/<name>/. Review requirements.md before accepting design, and review design.md before accepting tasks. Regeneration can change meaning, so keep the files in Git and inspect diffs rather than relying on the current chat summary.

Design should expose test seams: clock injection for lock expiry, an audit sink, stable API responses, and isolated account state. Tasks should include the test or evidence work next to the implementation, not as an optional final cleanup item.

spec artifact tree
.kiro/specs/account-lockout/
  requirements.md
  design.md
  tasks.md

tests/auth/
  lockout.api.spec.ts
  lockout.e2e.spec.ts
  lockout.property.spec.ts
TransitionQA review questionReject when
Requirement -> designWhere is each oracle exposed?Critical behavior has no observable seam
Design -> taskWhich task creates each test/evidence item?Implementation can finish before verification
Task -> codeDoes the diff stay inside approved design?Unreviewed behavior or dependency appears
Code -> evidenceCan a clean checkout reproduce it?Only screenshots or agent narrative exist
Approve transitions, not file presence

Three generated files can still disagree. Trace identifiers and observable outcomes across every transition.

QA drill

Review a generated design and tasks file. Add one missing test seam, one evidence task, and one explicit owner for a requirement ambiguity.

2.2

Bugfix Specs: Current, Expected, and Unchanged Behavior

A bugfix spec preserves the observed defect, the intended correction, and adjacent behavior that must not regress.

Start with a reproducible observation, not the suspected code change. Record environment, data, exact command, actual result, and expected result. Then name unchanged behavior that a narrow fix could accidentally damage. Kiro's bugfix workflow can turn those sections into a focused plan and regression properties.

For a lockout reset defect, unchanged behavior includes generic error responses, valid login before the threshold, separate counters per account, and normal expiry. This prevents a fix that merely disables lockout or changes public messages.

bugfix.md excerpt
## Current behavior
After attempt 4 succeeds in failing, a page refresh resets the counter.
Reproduction: npx playwright test tests/auth/lockout-refresh.spec.ts

## Expected behavior
Refresh does not alter the server-owned failure count. Attempt 5 locks the account.

## Unchanged behavior
- Attempts 1-4 return the generic invalid-credential response.
- Another account keeps an independent counter.
- A valid password works after the approved lock period.

Regression properties

  • Refreshing the client never decreases a server-owned failure count.
  • No sequence shorter than the threshold creates a lock.
  • No sequence at or above the threshold creates a session during the lock window.
  • The public response does not reveal whether the account exists or is locked.
Preserve the original red proof

Do not overwrite the failing report after repair. The before/after pair demonstrates that the regression test can detect the defect.

QA drill

Create a bugfix spec from one reproducible defect. Add at least three unchanged behaviors that prevent an over-broad or security-weakening fix.

2.3

Traceability From Task to Playwright Evidence

Stable IDs and a small manifest connect the approved requirement and task to the test, command, report, and commit that provide evidence.

Put requirement IDs in test metadata or titles in a way your reporter can extract. Link tasks to those IDs and to the exact test command. A traceability check should fail when a critical requirement has no test, a test cites an unknown requirement, or a completed evidence task points to no report.

Traceability does not mean one test per sentence. One scenario may cover several related requirements, and a property test may cover a large state space. The important part is that a reviewer can follow the claim without asking the agent to reconstruct its reasoning.

Playwright annotation
test("AUTH-LOCK-01 locks on the fifth invalid attempt", {
  annotation: [
    { type: "requirement", description: "AUTH-LOCK-01" },
    { type: "risk", description: "SEC-P0-03" },
  ],
}, async ({ page }) => {
  // synthetic setup and observable assertions
});
evidence manifest
{
  "requirement": "AUTH-LOCK-01",
  "task": "4.2",
  "test": "tests/auth/lockout.e2e.spec.ts",
  "command": "npx playwright test tests/auth/lockout.e2e.spec.ts",
  "report": "artifacts/lockout/results.json",
  "commit": "<git-sha>",
  "result": "passed"
}
A link is not proof by itself

Validate that the report belongs to the recorded commit and command, and that the assertion actually observes the requirement outcome.

QA drill

Add requirement and risk annotations to two tests, generate a small manifest, and make a script fail when one critical requirement is missing.

2.4

Correctness Properties and Property-Based Testing

Example tests prove selected journeys. Properties express invariants across generated sequences and shrink a failure to a useful counterexample.

Kiro can derive candidate properties from EARS requirements. QA must review whether each property is observable, meaningful, and independent of the implementation. Pair properties with named examples; do not replace a critical user journey with an opaque generator.

For lockout, generate sequences of valid and invalid attempts, account identities, timestamps, and refresh events. Freeze the clock and isolate state so a failure is reproducible. Record the random seed and shrunk counterexample in the test report.

property sketch with fast-check
fc.assert(
  fc.property(fc.array(fc.boolean(), { maxLength: 12 }), async attempts => {
    const model = new LockoutModel({ threshold: 5 });
    const system = await createSyntheticAccount();

    for (const passwordIsValid of attempts) {
      const expected = model.attempt(passwordIsValid);
      const observed = await system.attempt(passwordIsValid);
      expect(observed.sessionIssued).toBe(expected.sessionIssued);
      expect(observed.publicMessage).toBe("Invalid email or password");
    }
  }),
  { seed: 20260715, numRuns: 100 }
);
PropertyGeneratorCounterexample value
No early lock0-4 invalid attemptsSmallest count that incorrectly locks
No session while lockedPost-threshold valid/invalid mixShortest sequence that issues a session
Account isolationTwo account IDs and interleaved attemptsMinimal cross-account contamination
Recovery at expiryBoundary timestampsExact time offset that disagrees
Shrinking is diagnosis evidence

Preserve the seed and minimal sequence. A rerun with new random data that passes does not close the original failure.

QA drill

Derive one invariant from an EARS requirement, define its generator and oracle, then explain how a shrunk counterexample would be preserved.

Part 3 · Automation and governance

Enforce and Integrate

Use hooks, browser tools, reusable Powers, and explicit permissions to make quality checks repeatable while keeping high-impact actions human-owned.

3.1

Hooks That Run Tests and Block Unsafe Work

Kiro hooks execute agent prompts or shell commands on lifecycle events. Command hooks provide deterministic enforcement when the trigger can block.

Current standalone hooks live in .kiro/hooks/*.json with a versioned schema. Use PostTaskExec to run a focused check after a task. Use a blocking trigger such as PreTaskExec, PreToolUse, or UserPromptSubmit when exit code 2 must prevent unsafe execution. A nonblocking post hook can report failure but cannot retroactively undo side effects.

Keep commands fast, deterministic, and repository-owned. A hook that invokes an agent to 'make tests pass' is not equivalent to a hook that runs the fixed test command. Commit hook files and review matcher breadth, timeout, environment, and secret access.

.kiro/hooks/auth-test-on-save.json
{
  "version": "v1",
  "hooks": [
    {
      "name": "auth-test-on-save",
      "trigger": "PostFileSave",
      "matcher": "^(src/auth|tests/auth)/.*\\.(ts|tsx)$",
      "action": {
        "type": "command",
        "command": "npx playwright test tests/auth --project=chromium"
      },
      "timeout": 120,
      "enabled": true
    }
  ]
}
TriggerQA useCan block?
PreTaskExecValidate clean state or protected pathsYes, with exit code 2
PostTaskExecRun focused tests after task completionNo; report and return work
PreToolUseDeny dangerous tool or argumentYes, with exit code 2
PostFileSaveRun lint or tests for matching filesNo
Match the trigger to the guarantee

Do not claim a post-event hook prevented an action. Use a pre-event blocking hook or an external protected-branch gate for prevention.

QA drill

Create a command hook for one focused test. State whether it reports or blocks, and demonstrate that its matcher does not run on unrelated documentation files.

3.2

Playwright MCP With a Constrained Browser Target

A browser MCP server can inspect and operate a UI, but the test oracle must still come from requirements and deterministic assertions.

Connect a reviewed Playwright MCP server only to a local or synthetic environment. Give the agent a dedicated test account and no payment, administration, or customer-data privileges. Record which tools are exposed before the session and remove any capability the scenario does not need.

Use browser exploration to collect accessible names, network behavior, and candidate reproduction steps. Convert accepted observations into version-controlled Playwright tests. The MCP transcript is useful investigation evidence, but it is not a stable regression suite.

  1. Start the synthetic target on a local port and reset its data.
  2. Review the MCP server package, command, arguments, and network scope.
  3. Allow navigation, snapshot, click, and input only for the exercise.
  4. Reproduce lockout and compare the browser observation with API and audit evidence.
  5. Encode the accepted flow as a deterministic test and rerun from a clean state.
ObservationDurable evidence
Button accessible nameRole locator assertion in source control
Fifth attempt deniedAPI/E2E test with frozen threshold state
Public message remains genericKnown/unknown account comparison test
Audit event emittedBackend contract or event assertion
Web content is untrusted

A page can contain instructions intended to redirect the agent. Treat page text as test data and keep tool permissions and task authority outside page content.

QA drill

Use a synthetic browser target to discover one locator and one network outcome, then replace the transcript with a repeatable Playwright assertion.

3.3

Powers, Tool Authority, and Supervised Execution

A Kiro Power packages reusable instructions and integrations. Reuse magnifies both good standards and excessive permissions, so ownership and versioning matter.

A Power can include a POWER.md, MCP configuration, steering, and hooks. Build a QA Power around a narrow outcome such as reviewing Playwright changes or collecting a test-failure evidence bundle. Keep its required tools minimal and document every side effect.

Review Powers like code dependencies: source, version, maintainer, requested tools, network access, secrets, and update path. Do not treat a friendly name or generated description as proof of safety. For high-impact actions, require explicit approval and an external branch or environment policy.

POWER.md outline
# Playwright Failure Review

## Purpose
Classify one failing Playwright test and prepare a bounded repair proposal.

## Inputs
- Requirement ID and revision
- Raw failure and trace
- Allowed test paths

## Allowed actions
- Read repository and reports
- Run the focused test and lint
- Propose a test-only diff

## Prohibited actions
- Product edits, secret access, deployment, test deletion, assertion weakening

## Completion
Evidence bundle plus human review; never auto-merge.

Power review checklist

  • Purpose and completion are narrower than the tool list.
  • All MCP packages and commands have reviewed provenance.
  • Secrets use least privilege and are absent from logs and prompts.
  • Hooks cannot publish, deploy, or mutate protected systems silently.
  • A maintainer and rollback path are named.
Reusable does not mean universally trusted

Re-evaluate the Power in each repository and data classification. The same browser tool is low risk locally and high risk against production administration.

QA drill

Draft a Playwright-review Power contract. Remove one tempting capability that is not necessary for diagnosis, verification, or evidence packaging.

3.4

Capstone: Specify and Verify Login Lockout

Carry one security-sensitive behavior from EARS requirements through design, tasks, example tests, properties, hooks, evidence, and human acceptance.

The capstone uses a synthetic authentication service. It locks a known account after five consecutive invalid attempts within ten minutes, keeps public responses generic, isolates counters per account, and recovers after fifteen minutes. A frozen clock and reset endpoint exist only in the local test harness.

Do not begin implementation until a reviewer accepts requirement thresholds and observability. Do not mark tasks complete until the focused example tests, property tests, trace check, and hook command pass from a clean checkout.

capstone artifact contract
.kiro/specs/account-lockout/
  requirements.md      # EARS IDs AUTH-LOCK-01..04
  design.md            # clock, counter, audit, response seams
  tasks.md             # implementation and evidence tasks
.kiro/steering/playwright-testing.md
.kiro/hooks/auth-test-on-save.json
tests/auth/lockout.api.spec.ts
tests/auth/lockout.e2e.spec.ts
tests/auth/lockout.property.spec.ts
artifacts/lockout/evidence.json

Acceptance sequence

  1. Review the EARS requirements with security and product owners.
  2. Trace every requirement to design and at least one evidence task.
  3. Prove the original defect or missing behavior where applicable.
  4. Run lint, typecheck, example tests, property tests, and traceability checks.
  5. Trigger the committed hook and preserve its output.
  6. Have another SDET reproduce the suite and record residual risks.
Task completion is not release approval

Kiro may update a task status after execution. The QA lead still reviews evidence, unresolved risks, environment limits, and the final diff.

QA drill

Submit the complete synthetic spec folder, steering and hook files, test suite, evidence manifest, trace report, and signed QA review.

Primary sources · reviewed July 2026

Verify the product before you trust the pattern.

These links support the product-specific behavior taught above. Recheck them before adopting the workflow in a regulated or high-impact environment.

Primary sourceWhat it supports
Kiro DocumentationCurrent product surfaces, concepts, and getting started.
Web SpecsFeature specs, bugfix specs, and Quick Plan.
CLI V3 SpecsRequirements, design, tasks, and CLI spec execution.
Quick PlanLightweight planning and when to use it.
Bugfix SpecsCurrent, expected, and unchanged behavior.
CorrectnessProperties, property-based testing, and counterexamples.
SteeringWorkspace guidance, inclusion modes, and AGENTS.md.
HooksStandalone hook schema, triggers, commands, and blocking behavior.
MCP SecuritySecurity review for MCP servers and tools.
PowersPackaged guidance, MCP configuration, and reusable capabilities.
Privacy and SecurityProduct privacy, data, and security controls.