/tdd-guard
TDD edit-limit hook (advisory). Triggers: tdd guard, test-first hook, untested edits, snapshot/golden carve-out.
$ golems-cli skills install tdd-guardUpdated 1 week ago
Hook-carried skill. The enforcing artifact is hooks/tdd-guard.py
(PreToolUse on Write|Edit); this page is its contract and verification guide.
Scope
A PreToolUse hook on Write/Edit. The limits apply to implementation files.
Contract
- Implementation files (
.ts,.tsx,.kt,.swift,.py) are tracked per session. - Existing implementation files edited 1-2 times without a matching test emit a warning.
- Existing implementation files edited 3+ times without a matching test get a
TDD ADVISORYinhookSpecificOutput.additionalContext(the channel the model reads;systemMessageis the human's copy). Never a block (GO-5 E2): a block made the model retry, and the name-based lookup misses tests that live elsewhere. - Test files, docs/config/generated paths, hooks, scripts, skills, and skipped path segments are not classified as implementation.
Snapshot/golden carve-out
Snapshot, golden, and approval artifacts are test data, not implementation.
hooks/tdd-guard.py excludes:
__snapshots__/viaSKIP_PATH_SEGMENTS- Dotted marker filenames via
is_snapshot_file():.snap.,.golden.,.snapshot.,.approved.,.received., plus files ending in.snap
The marker match is intentionally precise. Names such as golden_retriever.ts
and snapshot_service.ts remain implementation files and still hit the recall
gate when edited 3+ times without a test.
Full SKILL.md source — includes LLM directives, anti-patterns, and technical instructions stripped from the Overview tab.
Hook-carried skill. The enforcing artifact is hooks/tdd-guard.py
(PreToolUse on Write|Edit); this page is its contract and verification guide.
Scope
A PreToolUse hook on Write/Edit. The limits apply to implementation files.
Contract
- Implementation files (
.ts,.tsx,.kt,.swift,.py) are tracked per session. - Existing implementation files edited 1-2 times without a matching test emit a warning.
- Existing implementation files edited 3+ times without a matching test get a
TDD ADVISORYinhookSpecificOutput.additionalContext(the channel the model reads;systemMessageis the human's copy). Never a block (GO-5 E2): a block made the model retry, and the name-based lookup misses tests that live elsewhere. - Test files, docs/config/generated paths, hooks, scripts, skills, and skipped path segments are not classified as implementation.
Snapshot/golden carve-out
Snapshot, golden, and approval artifacts are test data, not implementation.
hooks/tdd-guard.py excludes:
__snapshots__/viaSKIP_PATH_SEGMENTS- Dotted marker filenames via
is_snapshot_file():.snap.,.golden.,.snapshot.,.approved.,.received., plus files ending in.snap
The marker match is intentionally precise. Names such as golden_retriever.ts
and snapshot_service.ts remain implementation files and still hit the recall
gate when edited 3+ times without a test.
Tests
hooks/tests/test_tdd_guard.py pins:
- snapshot/golden/approval artifacts are allowed after three edits
- a real
Service.tsimplementation file is still flagged after three untested edits - marker words embedded inside real implementation filenames are not carved out
Run:
$(brew --prefix)/bin/python3 -m pytest hooks/tests/ -qNot yet evaluated on current models
Results will appear here once runs with a recorded model are published.
Changelog entries are derived from skill version updates. Full cascading changelog (Phase 4D) coming soon.
- +Initial release to Golems skill library