Skill: Test Architect
Designs and generates production-quality tests that pass quality gates from the first attempt.
Prerequisites: scripts/test-auditor-engine.py (SPEC-055), target spec or source file
Decision Checklist
- Is the input a spec, source file, or bug report? -> Determines test types needed
- What language is the target? -> Selects framework from matrix below
- Does the project have existing tests? -> Follow patterns for consistency
- Is this a BATS validation test? -> Apply auditor-optimized template
- Does the target touch auth, payments, or PII? -> Add security test cases
Abort Conditions
- No clear target (no spec, no source, no bug) -> Ask for clarification
- Language not in the 16 supported packs -> Warn and use closest match
Test Type Selection Matrix
| Input Type |
Primary Test Types |
Secondary |
| Spec (feature) |
Unit + Integration + E2E |
Contract, Property-based |
| Spec (API) |
Unit + Contract + Integration |
Security, Load |
| Source (script) |
Validation (BATS) |
Regression |
| Source (service) |
Unit + Integration |
Mutation |
| Bug report |
Regression + Unit |
E2E |
| Rule/config |
Validation (BATS) |
Snapshot |
| UI component |
Unit + Visual regression |
Accessibility, E2E |
| Pipeline |
Pipeline + Integration |
- |
BATS Generation Protocol (Auditor-Optimized)
For BATS tests, follow references/bats-template.md exactly:
- Header: shebang + SPEC reference + strategy comment
- Variables: SCRIPT/HOOK path to target
- setup(): mktemp -d for isolation
- teardown(): rm -rf cleanup
- C1: Target exists and is executable
- C2: Safety flags verified (set -uo pipefail)
- C3: 5+ positive scenario tests
- C4: 4+ negative scenario tests (error/fail/missing/invalid keywords)
- C5: 3+ edge case tests (empty/boundary/zero/nonexistent keywords)
- C8: Spec doc existence test
- C9: Mix assertion types throughout
Post-generation: run python3 scripts/test-auditor-engine.py <file> .
If score < 80: identify failing criteria, add missing patterns, re-verify.
Non-BATS Generation Protocol
For all other languages, apply the 8 excellence patterns:
- Isolation: Use framework's setup/teardown (BeforeEach, setUp, etc.)
- Positive paths: 3+ happy-path tests with distinct scenarios
- Negative paths: 2+ error-handling tests (invalid input, missing deps)
- Edge cases: Empty collections, null/nil, boundary values, max limits
- Assertions: Use framework-native assertion libraries (FluentAssertions, assertj)
- Coverage: Test 60%+ of public API surface
- Documentation: Test names explain WHAT and WHY, not HOW
- Determinism: No sleep, no random, no external service dependencies
Test Naming Convention
| Language |
Pattern |
Example |
| BATS |
Descriptive sentence |
"validates JSON output format" |
| C#/xUnit |
Method_Scenario_Expected |
CreateUser_WithInvalidEmail_ThrowsValidationError |
| Java/JUnit |
@DisplayName |
"should reject duplicate orders" |
| Python/pytest |
test_scenario_expected |
test_calculate_tax_with_zero_amount_returns_zero |
| Go |
TestFunction_Scenario |
TestParseConfig_EmptyInput |
| JS/TS |
describe+it |
it('should return 404 for missing user') |
Quality Verification
BATS (automated)
python3 scripts/test-auditor-engine.py <generated-test.bats> .
# Must output: "certified": true, "total": >= 80
Non-BATS (checklist)
References
references/bats-template.md — Golden BATS template (score 90+)
scripts/test-auditor-engine.py — SPEC-055 auditor engine
docs/rules/domain/language-packs.md — 16 language frameworks
docs/rules/domain/coverage-scripts.md — Coverage patterns
.opencode/agents/test-engineer.md — Complementary agent (execution)
1---2name: test-architect3description: "Skill: Test Architect"4---56# Skill: Test Architect78Designs and generates production-quality tests that pass quality gates from the first attempt.910**Prerequisites:** `scripts/test-auditor-engine.py` (SPEC-055), target spec or source file1112---1314## Decision Checklist15161. Is the input a spec, source file, or bug report? -> Determines test types needed172. What language is the target? -> Selects framework from matrix below183. Does the project have existing tests? -> Follow patterns for consistency194. Is this a BATS validation test? -> Apply auditor-optimized template205. Does the target touch auth, payments, or PII? -> Add security test cases2122### Abort Conditions23- No clear target (no spec, no source, no bug) -> Ask for clarification24- Language not in the 16 supported packs -> Warn and use closest match2526---2728## Test Type Selection Matrix2930| Input Type | Primary Test Types | Secondary |31|------------|-------------------|-----------|32| Spec (feature) | Unit + Integration + E2E | Contract, Property-based |33| Spec (API) | Unit + Contract + Integration | Security, Load |34| Source (script) | Validation (BATS) | Regression |35| Source (service) | Unit + Integration | Mutation |36| Bug report | Regression + Unit | E2E |37| Rule/config | Validation (BATS) | Snapshot |38| UI component | Unit + Visual regression | Accessibility, E2E |39| Pipeline | Pipeline + Integration | - |4041## BATS Generation Protocol (Auditor-Optimized)4243For BATS tests, follow `references/bats-template.md` exactly:44451. **Header**: shebang + SPEC reference + strategy comment462. **Variables**: SCRIPT/HOOK path to target473. **setup()**: mktemp -d for isolation484. **teardown()**: rm -rf cleanup495. **C1**: Target exists and is executable506. **C2**: Safety flags verified (set -uo pipefail)517. **C3**: 5+ positive scenario tests528. **C4**: 4+ negative scenario tests (error/fail/missing/invalid keywords)539. **C5**: 3+ edge case tests (empty/boundary/zero/nonexistent keywords)5410. **C8**: Spec doc existence test5511. **C9**: Mix assertion types throughout5657Post-generation: run `python3 scripts/test-auditor-engine.py <file> .`58If score < 80: identify failing criteria, add missing patterns, re-verify.5960## Non-BATS Generation Protocol6162For all other languages, apply the 8 excellence patterns:63641. **Isolation**: Use framework's setup/teardown (BeforeEach, setUp, etc.)652. **Positive paths**: 3+ happy-path tests with distinct scenarios663. **Negative paths**: 2+ error-handling tests (invalid input, missing deps)674. **Edge cases**: Empty collections, null/nil, boundary values, max limits685. **Assertions**: Use framework-native assertion libraries (FluentAssertions, assertj)696. **Coverage**: Test 60%+ of public API surface707. **Documentation**: Test names explain WHAT and WHY, not HOW718. **Determinism**: No sleep, no random, no external service dependencies7273## Test Naming Convention7475| Language | Pattern | Example |76|----------|---------|---------|77| BATS | Descriptive sentence | `"validates JSON output format"` |78| C#/xUnit | Method_Scenario_Expected | `CreateUser_WithInvalidEmail_ThrowsValidationError` |79| Java/JUnit | @DisplayName | `"should reject duplicate orders"` |80| Python/pytest | test_scenario_expected | `test_calculate_tax_with_zero_amount_returns_zero` |81| Go | TestFunction_Scenario | `TestParseConfig_EmptyInput` |82| JS/TS | describe+it | `it('should return 404 for missing user')` |8384## Quality Verification8586### BATS (automated)87```bash88python3 scripts/test-auditor-engine.py <generated-test.bats> .89# Must output: "certified": true, "total": >= 8090```9192### Non-BATS (checklist)93- [ ] setup/teardown present94- [ ] 3+ positive cases95- [ ] 2+ negative cases96- [ ] Edge cases covered97- [ ] No external dependencies without mock/container98- [ ] Deterministic (no timing, no random)99- [ ] Test names are self-documenting100- [ ] Strategy comment in file header101102## References103104- `references/bats-template.md` — Golden BATS template (score 90+)105- `scripts/test-auditor-engine.py` — SPEC-055 auditor engine106- `docs/rules/domain/language-packs.md` — 16 language frameworks107- `docs/rules/domain/coverage-scripts.md` — Coverage patterns108- `.opencode/agents/test-engineer.md` — Complementary agent (execution)