.claude/skills/sagerstack-code-qa/SKILL.md
Code QA validation skill for the builder team's QA agent. Provides AC-driven validation, test execution, coverage verification, code quality checks, flexible UAT, granular failure mapping, and QA report generation. Zero-trust validator that never modifies source code. Operates in read-only mode with Bash for running tests and inspecting outputs.
npx skillsauth add sagerstack/agentic-sdlc sagerstack:code-qaInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
<essential_principles>
These principles ALWAYS apply when validating implementation quality.
Every validation starts from the user story's Acceptance Criteria table. Parse each AC independently and validate against the codebase.
Parsing Process:
docs/phases/epic-{NNN}-{desc}/stories/story-{NNN}-{desc}.md| AC Type | Validation Method | |---------|-------------------| | Functional - Happy Path | Run corresponding test, verify expected outcome | | Functional - Failure Scenario | Run corresponding test, verify error handling | | Functional - Edge Case | Run corresponding test, verify edge behavior | | Functional - Error Handling | Run corresponding test, verify error response | | Functional - Integration | Run integration test with real or mocked services | | Functional - End-to-End | Run E2E test via docker-compose + curl | | Technical - Performance | Run performance test, verify threshold | | Technical - Security | Run security scan, verify no vulnerabilities | | Technical - Reliability | Run reliability test, verify SLA |
poetry run pytest {test_file}::{test_function} -vAC Validation Report (per AC):
### AC-{N}: {Description from Then column}
- **Status**: PASS / FAIL
- **Validates**: {FR/TR IDs from Validates column}
- **Evidence**:
- Test: {test_file}::{test_function}
- Result: {pass/fail with output excerpt}
- Notes: {observations, warnings, or context}
Re-run ALL tests independently. Never trust developer assertions or prior test results.
Test execution order:
poetry run pytest tests/ -vpoetry run pytest --cov=src --cov-report=term-missing --cov-fail-under=90Zero-trust rules:
docker-compose up -d --buildRun ALL checks sequentially. If a check fails, note it and continue to remaining checks. Report ALL failures together.
| # | Check | Command | Threshold | Failure Action |
|---|-------|---------|-----------|----------------|
| 1 | Full Test Suite | poetry run pytest tests/ -v | All pass | Report failures |
| 2 | Coverage | poetry run pytest --cov=src --cov-report=term-missing --cov-fail-under=90 | >= 90% | Report uncovered lines |
| 3 | Type Checking | poetry run mypy src/ --strict | Zero errors | Report type errors |
| 4 | Linting | poetry run ruff check src/ tests/ | Zero violations | Report lint issues |
| 5 | Formatting | poetry run ruff format --check src/ tests/ | All formatted | Report unformatted files |
| 6 | Security | poetry run bandit -r src/ | No high/critical | Report vulnerabilities |
| 7 | Docker Build | docker-compose build | Builds successfully | Report build errors |
| 8 | CHANGELOG | Verify entry exists for this story | Entry present | Report missing entry |
| 9 | Git Status | git status | Clean working tree | Report uncommitted changes |
Notes:
docker-compose.yml exists. Note in report.Detect the application's execution model and test accordingly.
Detection Logic:
docker-compose.yml or docker-compose.yaml in project root
main.py, FastAPI app, etc.)
UAT via Docker:
# 1. Build and start with latest code
docker-compose up -d --build
# 2. Wait for health check (30 second timeout)
for i in $(seq 1 30); do
curl -sf http://localhost:{port}/health && break
sleep 1
done
# 3. Run E2E scenarios from impl plan
# For each AC of type "Functional - End-to-End":
response=$(curl -s http://localhost:{port}/{endpoint})
status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:{port}/{endpoint})
# 4. Assert expected outcomes
test "$status" = "200" || echo "FAIL: Expected 200, got $status"
# 5. Tear down
docker-compose down
UAT via Local Process:
# 1. Start application in background
poetry run python -m src.main &
APP_PID=$!
# 2. Wait for startup
sleep 3
# 3. Run test scenarios (same curl assertions as Docker UAT)
# 4. Stop application
kill $APP_PID
Read project memory BEFORE validation. Write findings AFTER validation.
Before validation (READ):
docs/project_notes/bugs.md -- Check if known bugs are being reintroduceddocs/project_notes/decisions.md -- Verify code follows established architectural decisionsAfter validation (WRITE):
docs/project_notes/bugs.md -- Write bugs found (date, issue, root cause, solution, prevention)docs/project_notes/issues.md -- Log story completion (date, story ID, status, description)Integration during validation:
When failures are found, map each failure back to specific implementation plan tasks. This enables targeted remediation instead of broad rework.
Failure Mapping Process:
Mapping sources:
[X.0][CATEGORY] taskFailure Report Entry:
| Failure | Source | Impl Plan Task | Remediation |
|---------|--------|----------------|-------------|
| AC-2 test failure | src/orders/domain/order.py:23 | [5.0][FR-1] subtask [5.2] | Fix validation logic for empty cart |
| Coverage gap | src/orders/infrastructure/repo.py:45-62 | [7.0][FR-3] subtask [7.3] | Add tests for repository error paths |
| UAT: endpoint 500 | src/orders/api/routes.py:15 | [8.0][AC-2] subtask [8.1] | Fix endpoint handler exception |
Generate comprehensive QA reports. Two formats: PASS and FAIL.
Report location: docs/phases/epic-{NNN}-{desc}/qa/story-{NNN}-{desc}-qa-report.md
FAIL Report Format:
# QA Report: Story {N} - {Story Title}
## Summary
- **Overall Status**: FAIL
- **AC Results**: {X}/{Y} passed
- **Coverage**: {N}%
- **Quality Checks**: {X}/9 passed
- **UAT**: PASS / FAIL / SKIPPED
## AC Results
| AC ID | Description | Status | Evidence |
|-------|-------------|--------|----------|
| AC-1 | {desc} | PASS | test_file::test_func |
| AC-2 | {desc} | FAIL | test_file::test_func - AssertionError: ... |
## Quality Check Results
| Check | Status | Details |
|-------|--------|---------|
| Test Suite | PASS | 45/45 tests pass |
| Coverage | FAIL | 87% (target: 90%). Uncovered: src/orders/infrastructure/repo.py:45-62 |
| Type Check | PASS | 0 errors |
| Linting | PASS | 0 violations |
| Formatting | PASS | All formatted |
| Security | PASS | 0 issues |
| Docker Build | PASS | Build successful |
| CHANGELOG | PASS | Entry present |
| Git Status | PASS | Clean tree |
## UAT Results
| Scenario | Status | Details |
|----------|--------|---------|
| Health check | PASS | 200 OK |
| Create order | FAIL | Expected 201, got 500. Response: {"error": "..."} |
## Failure-to-Task Mapping
| Failure | Source | Impl Plan Task | Remediation |
|---------|--------|----------------|-------------|
| AC-2 test failure | src/orders/domain/order.py:23 | [5.0][FR-1] subtask [5.2] | Fix validation logic |
| Coverage gap | src/orders/infrastructure/repo.py:45-62 | [7.0][FR-3] subtask [7.3] | Add error path tests |
## Remediation Tasks (for Team Lead)
1. Fix validation logic in order domain - relates to [5.0][FR-1]
2. Add repository error path tests - relates to [7.0][FR-3]
PASS Report Format:
# QA Report: Story {N} - {Story Title}
## Summary
- **Overall Status**: PASS
- **AC Results**: {Y}/{Y} passed (100%)
- **Coverage**: {N}% (>= 90%)
- **Quality Checks**: 9/9 passed
- **UAT**: PASS
## AC Results
| AC ID | Description | Status | Evidence |
|-------|-------------|--------|----------|
| AC-1 | {desc} | PASS | test_file::test_func |
| AC-2 | {desc} | PASS | test_file::test_func |
## Quality Check Results
All 9 checks passed.
| Check | Status |
|-------|--------|
| Test Suite | PASS ({N}/{N}) |
| Coverage | PASS ({N}%) |
| Type Check | PASS (0 errors) |
| Linting | PASS (0 violations) |
| Formatting | PASS |
| Security | PASS (0 issues) |
| Docker Build | PASS |
| CHANGELOG | PASS |
| Git Status | PASS |
## UAT Results
All scenarios passed.
## Recommendation
Story is ready for merge. All acceptance criteria validated, quality standards met.
</essential_principles>
<intake>The QA agent requires the following context from the Team Lead:
docs/phases/epic-{NNN}-{desc}/stories/story-{NNN}-{desc}.md (for AC parsing)docs/phases/epic-{NNN}-{desc}/plans/story-{NNN}-{desc}-plan.md (for failure mapping)Before starting validation, QA MUST:
| Validation Scope | Workflow |
|------------------|----------|
| Full story validation (first pass) | workflows/validate-story.md |
| UAT-only validation | workflows/run-uat.md |
| Re-validation after remediation | workflows/remediation-check.md |
<workflow_steps>
For each AC in priority order (P1 first):
poetry run pytest {test_path}::{test_func} -vRun all 9 checks sequentially. Record every result regardless of pass/fail.
Verify architectural standards by reading source code:
If applicable (docker-compose exists or app entry point found):
docs/phases/epic-{NNN}-{desc}/qa/story-{NNN}-{desc}-qa-report.md</workflow_steps>
<reference_index>
All in references/:
AC Parsing:
Quality Standards:
Cross-Agent Validation:
UAT Patterns:
</reference_index>
<workflows_index>
All in workflows/:
| File | Purpose | |------|---------| | validate-story.md | Full story validation: AC + quality + UAT + report | | run-uat.md | UAT-only validation: Docker or local process testing | | remediation-check.md | Re-validation after developer fixes: targeted scope |
</workflows_index>
<verification>After every QA validation, verify:
docs/phases/epic-{NNN}-{desc}/qa/story-{NNN}-{desc}-qa-report.mddevelopment
Interactive UAT verification skill. Walks the user through acceptance criteria one at a time, records pass/fail/skip results, generates UAT report, and routes remediation gaps to /sagerstack:builder. Solo skill (no agent team).
development
Python code architecture with Vertical Slice + DDD and Clean Architecture. Use when designing Python projects, structuring code, creating domain models, defining bounded contexts, or reviewing architecture. Enforces strict domain purity, CamelCase naming, and proper layer separation.
data-ai
SDLC planning skill that spawns a 4-member agent team to plan one epic at a time from project-context.md. Produces epics, user stories with FR/TR/AC, implementation plans, and critical analyses. Use when planning an epic for full SDLC execution with agent teams.
testing
Testing infrastructure, local environment simulation, and deployment scripts. Use when setting up pytest fixtures, Docker Compose, LocalStack, mocking external services, or creating local deployment scripts. Focuses on HOW to test and run locally, not coding principles (TDD is in software-engineering).