Not loaded · from aidlc
Establishes a TDD strategy for agentic systems using LLM client mocks (VCR-style), golden dataset evaluation (minimum 5 cases), and hypothesis-based property tests to control nondeterminism. Outputs a test plan at `.omao/plans/construction/test-plan.md` and runs in parallel with code generation.
Claude Code won't load this skill
It ships in aidlc at skills/, but Claude Code only loads skills/<name>/SKILL.md and folders listed under skills in plugin.json. Installing the plugin doesn't add it.
다음 상황에서 본 skill을 실행합니다.
component-design 승인 직후 TDD 기반으로 테스트를 먼저 작성하는 단계code-generation이 구현을 완료한 뒤 회귀 테스트·eval suite를 강화하는 단계다음 상황에서는 사용하지 않습니다.
.omao/plans/construction/design.md 존재 및 승인 완료.pytest, pytest-anyio, hypothesis 최신 안정 버전 설치.anthropic/openai SDK의 mock 기능 또는 vcrpy 카세트 레코딩 준비..omao/plans/construction/test-plan.md 쓰기 권한.Agentic 시스템은 4개 계층으로 테스트를 분리합니다.
| 계층 | 대상 | 도구 | LLM 호출 |
|---|---|---|---|
| Unit | Tool·Memory·Gateway의 결정적 함수 | pytest | 금지(mock 필수) |
| Contract | 인터페이스 서명·예외 계약 | pytest + typing | 금지 |
| Property | 비결정적 출력의 불변식 | hypothesis | 제한적 허용(mock 권장) |
| Eval | Golden dataset 기반 품질 측정 | pytest + ragas 또는 custom | 허용(오프라인 cassette) |
세 가지 방식 중 하나를 선택합니다.
unittest.mock.MagicMock으로 응답 고정. 가장 빠르며 CI 부담 없음.vcrpy로 실제 응답을 1회 녹화 후 반복 재생. 실제 API 스키마와 일치하는 응답 보장.예시 — anthropic.Anthropic 클라이언트 mock:
import pytest
from unittest.mock import MagicMock
from src.agents import QaAgent
@pytest.fixture
def mock_anthropic(monkeypatch):
fake = MagicMock()
fake.messages.create.return_value = MagicMock(
content=[MagicMock(text="mocked answer")],
)
monkeypatch.setattr("src.agents.Anthropic", lambda *a, **kw: fake)
return fake
def test_qa_agent_returns_mocked_answer(mock_anthropic):
agent = QaAgent()
assert agent.answer("hi") == "mocked answer"
tests/eval/golden/${component}.jsonl에 최소 5건의 샘플을 작성합니다. 각 샘플은 다음 필드를 포함합니다.
{
"id": "gold-001",
"input": "What is vLLM?",
"expected_contains": ["PagedAttention", "KV cache"],
"expected_excludes": ["internal_ip", "api_key"],
"max_tokens": 256,
"acceptance_criteria_ref": "US-042"
}
필드 설명:
expected_contains — 반드시 포함되어야 할 키워드 리스트expected_excludes — 출력에 나타나서는 안 될 토큰(PII, 내부 주소)acceptance_criteria_ref — Inception 단계 user-stories.md의 수락 기준 ID샘플 작성은 도메인 전문가가 검토합니다. 5건은 최소 임계이며 production agent는 100건 이상을 권장합니다.
LLM 출력의 불변식을 hypothesis로 검증합니다. 예: 입력 길이에 관계없이 출력이 max_tokens 이내, 출력에 PII 패턴이 포함되지 않음.
from hypothesis import given, strategies as st
from src.agents import SummaryAgent
@given(st.text(min_size=10, max_size=2000))
def test_summary_never_contains_email(input_text):
agent = SummaryAgent(llm=MockedLLM())
result = agent.summarize(input_text)
assert "@" not in result, "summary leaked email-like token"
불변식 카테고리(최소 3개 권장):
tests/eval/run.py를 작성하여 golden dataset을 순회하며 평가합니다.
import json, pathlib, sys
def evaluate(component: str) -> dict:
passes, fails = 0, []
golden = pathlib.Path(f"tests/eval/golden/{component}.jsonl").read_text().splitlines()
for line in golden:
case = json.loads(line)
output = call_component_with_mock(case["input"])
ok = all(k in output for k in case["expected_contains"]) and not any(k in output for k in case["expected_excludes"])
if ok:
passes += 1
else:
fails.append({"id": case["id"], "output": output})
return {"total": passes + len(fails), "pass": passes, "fails": fails}
if __name__ == "__main__":
result = evaluate(sys.argv[1])
json.dump(result, sys.stdout, indent=2)
sys.exit(0 if not result["fails"] else 1)
CI에서 python tests/eval/run.py ${component} 를 호출하고 실패 시 빌드를 차단합니다.
Eval regression 발생 시 복원 절차를 test-plan.md에 명시합니다.
.omao/plans/construction/rollback/${STAMP}/ 에서 마지막 통과 커밋의 파일을 복원git checkout main -- ${affected_path} 로 main 상태로 되돌림aidlc-docs/audit.md에 rollback 사유와 타임스탬프 기록.omao/plans/construction/test-plan.md를 다음 구조로 작성합니다.
Good — Unit test는 LLM을 호출하지 않고 mock으로 고정됩니다.
def test_tool_unit(mock_anthropic):
assert RetrievalTool().search("x", 3)[0].score > 0
Bad — Unit test가 실제 API를 호출하여 비결정적이고 비용이 발생합니다.
def test_agent():
agent = Agent(api_key=os.environ["ANTHROPIC_API_KEY"])
assert "answer" in agent.ask("hi") # 실제 호출
Good — Golden dataset 5건이 모두 user-story 수락 기준 ID와 연결되어 있습니다.
Bad — Golden dataset이 3건이고 출처가 불명확합니다.
Good — Property-based test가 출력 길이·금지 토큰·스키마 3축을 검증합니다.
Bad — 결정적 예제 한 건만 assert로 검증하여 edge case를 놓칩니다.
본 skill 실행 종료 직전 다음을 자동 검증합니다.
.omao/plans/construction/test-plan.md 존재tests/eval/golden/${component}.jsonl 최소 5건grep -r "anthropic.Anthropic()" tests/unit/가 비어 있음)tests/eval/run.py 또는 동등한 entry point 실행 가능What SKILL.md sets; muted values are Claude Code's defaults
claude-opus-4-7Three short reads, in order
tdd, llm-testing, golden-dataset, property-based-testing, vcr-mock
npx claudepluginhub aws-samples/sample-oh-my-aidlcops --plugin aidlc11 skills in this plugin
/code-generation승인된 design.md를 기반으로 스캐폴딩·인터페이스·데이터 모델·구현 코드를 단계별로 생성하고 모든 변경을 사람 승인 gate에 제출한다. 템플릿 기반 생성·롤백 스냅샷·계약 위반 감지로 안전성을 확보하며 auto-merge는 금지된다./component-designInception 아티팩트(requirements, user-stories, workflow-plan)를 입력으로 받아 agentic 시스템의 컴포넌트 경계·인터페이스 계약·데이터 모델을 설계하고 `.omao/plans/construction/design.md`를 생성한다. Agent·Tool·Memory·Gateway 경계를 명확히 나누고 후속 code-generation·test-strategy skill의 단일 진실원 역할을 한다./ontology-wiki생성 전(pre-generation) grounding 레이어. 온톨로지 엔티티(Spec/ADR/Deployment/Agent/Skill/Incident/Budget/Risk)를 작성하기 전에 지식 그래프를 질의해 기존 정의·enum·전례·결정 이유를 확인함으로써 drift를 소스에서 차단한다. adr-0001-graphify-knowledge-wiki 결정에 따라 Graphify(MIT)를 런타임 질의 substrate로 사용하며, Graphify 미가용 시 raw 스키마/docs 읽기로 graceful degradation 한다./quality-gatesAIDLC 각 phase 종료 시점에 필수 gate 체크리스트를 강제한다. Inception gate는 요구사항·사용자 스토리·워크플로우 계획 서명을, Construction gate는 설계·코드·테스트 전수 통과와 risk-discovery PASS를, Operations gate는 continuous-eval 24시간 green과 cost-governance budget OK를 요구한다. 미통과 시 `.omao/state/gates/<phase>.json`에 blocked 상태를 기록하고 다음 phase 진입을 차단한다./requirements-analysisAdaptive-depth requirements analysis for AIDLC Inception. Simple features produce a 1-paragraph brief; complex features produce structured REQ-001/REQ-002 functional and non-functional requirements with acceptance criteria and traceability to user stories./risk-discoveryConstruction 단계 실행 직전, Inception 아티팩트와 설계 문서를 교차 분석하여 12개 카테고리 기반 위험 체크포인트를 탐지한다. 비즈니스 연속성·보안·외부 통합·데이터 일관성·비용·성능·규제·가용성·장애 전파 반경·운영 복잡도·의존성 취약점·롤백 가능성을 각각 PASS/WARN/BLOCK으로 판정하고 BLOCK 항목은 다음 phase 진입을 차단한다.Other plugins' skills for the same job