principle-test-behavior-not-implementation
하는 일
좋은 테스트를 작성하고 유지하는 규칙을 에이전트에 제공합니다. 리팩터링마다 테스트가 깨지거나, 코드가 잘못되었는데도 테스트가 통과하는 문제로 고민하는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓테스트를 작성하거나, 바꾸거나, 그대로 유지할 때.
- ✓동작은 그대로인데 리팩터링할 때마다 테스트가 실패하는 경우.
- ✓동작을 일부러 깨뜨렸는데도 테스트가 계속 통과할 때.
스킬 링크
https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-test-behavior-not-implementation/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“리팩터링할 때마다 사용자에게 보이는 변화가 없어도 테스트가 깨집니다. 동작을 확인하도록 다시 작성해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 각 테스트를 두 가지 가상의 수정으로 점검합니다. 하나는 동작을 깨뜨리는 수정으로, 테스트가 잡아야 합니다. 다른 하나는 내부만 바꾸는 수정으로, 테스트가 살아남아야 합니다. 어느 점검이든 실패하는 테스트는 다시 쓰거나 삭제하며, 공개 인터페이스를 통해 코드를 실행합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Test Behavior, Not Implementation
A test is a claim about what the code does for its users: a caller, an end user, or another service. Behavior is what those users can observe through the interface they use. That includes return values, errors, state they can read back, and effects on systems outside the code, such as a request sent, a row written, or a message emitted. Implementation is what they cannot observe: private helpers, internal call order, intermediate data, and which internal collaborator did the work.
Judge each test against two imagined edits:
- Break the behavior. Make the code return a wrong value, skip an effect, or do the effect twice. If the test still passes, it proves nothing. The usual causes are an assertion looser than the contract, an expected value computed by the code under test, a restated constant or prompt string that never runs the code that reads it, and an assertion on data that the test built itself.
- Change the internals. Keep every observable result the same and restructure the code underneath. If the test now fails, it is pinned to the implementation. It will need a rewrite on every refactor and still catches no bug.
Keep a test that catches the first edit and survives the second. Rewrite or delete the rest. To write a test that does both, drive the code through its users' interface with a concrete input. Derive the expected value from the requirement, not from a run of the code. Assert what the contract promises, no less and no more.
The contract decides, not the shape of the assertion. When "an empty cart never charges" is the promise, an assertion that the payment client got no call is behavior. Pair it with a case where the charge happens, so that the test shows it can see a call. The payload that a mocked external service receives is behavior, because that service observes it. A call to an internal helper is implementation, because no user can see it. An empty list is the exact answer when no record matches, and a hollow check when the test only needs some result. An exact error message pins wording that no caller reads. The error type that callers branch on is the contract.
A test can pin an invariant instead of a call, such as a key that must exist in two tables or a compile-time type check. The invariant is the behavior.
자주 묻는 질문
동작이란 무엇인가요?
반환 값, 오류, 읽을 수 있는 상태, 보낸 메시지처럼 코드 사용자가 관찰할 수 있는 것입니다.
약한 테스트란 무엇인가요?
기대 값을 테스트 대상 코드가 계산하거나, 계약보다 느슨하게 검사하는 테스트입니다.
비공개 헬퍼를 검사해야 하나요?
아닙니다. 비공개 헬퍼와 내부 호출 순서는 구현 세부 사항이지 동작이 아닙니다.
상세 정보
작성자의 원본 설명
Apply when you write, change, or keep a test. Assert what the code's users can observe, so that the test fails when that behavior breaks and keeps passing when only the internals change.
repo: cursor/plugins
인기도
- GitHub 스타
- 15k
- 순위
- #10990
- 라이선스
- —
- 업데이트
- 2026. 10. 31.
댓글
- …
이 저장소의 다른 스킬
advisor
15k사용자가 켜 두면, 큰 결정 전이나 오류에 막혔을 때처럼 핵심 시점에 에이전트가 더 강력한 두 번째 모델에게 자문을 구하도록 합니다.
check-agent-compatibility
15kAI 코딩 에이전트가 저장소를 시작하고, 검증하고, 문서화할 수 있는지 전체 점검해, 하나의 호환성 점수와 주요 문제를 돌려줍니다.
cli-for-agents
15kAI 에이전트가 프롬프트 없이 실행할 수 있도록 명령줄 도구를 설계하거나 검토하며, 명확한 도움말과 예시를 담도록 에이전트를 가르칩니다.
continual-learning
15k과거 채팅을 검토하는 일을 전담 메모리 업데이터에게 맡겨서 AGENTS.md 메모를 최신 상태로 유지합니다.
비슷한 스킬
test-driven-development
311k에이전트가 기능이나 수정을 만들기 전에 실패하는 테스트를 먼저 쓰고, 그것을 통과시키는 가장 작은 코드를 작성하도록 가르칩니다.
verification-before-completion
311k에이전트가 작업, 수정, 빌드가 완료되었거나 통과했다고 말하기 전에 실제 점검을 실행하고 결과를 읽도록 가르칩니다.
migrate-to-shoehorn
310k테스트 파일의 위험한 타입 캐스팅을 shoehorn 라이브러리로 바꿔, 테스트가 일부 데이터만 써도 타입 검사를 통과하도록 돕습니다.