Skip to content

tdd-guard UX: better errors for stale test.json and shallow test coverage #35

Description

@Jaggerxtrm

Background

From observing tdd-guard in a real session, two quality gaps emerged:

Problem 1: Stale test.json gives a misleading block

When tests haven't been run yet (or were run from a subdirectory before the VitestReporter wrote the file), tdd-guard blocks with:

"No failing test found"

This is factually correct but misleading — the failing tests exist in the test file, they just haven't been flushed to test.json yet. The developer has to debug why before realizing they just need to run the test suite first.

Proposed fix: Detect when test.json is missing or older than the test files, and surface a specific message:

"test.json is missing or stale — run your test suite first to flush results (e.g. npx vitest run)"

This could be a timestamp comparison between test.json mtime and the newest *.test.* file mtime in the project.

Problem 2: TDD enforcement raises the floor but not the ceiling

tdd-guard correctly enforces "write a failing test before implementing." But it doesn't nudge toward testing edge cases — malformed input, missing fields, error paths. In practice, developers write one happy-path test to satisfy the gate, then implement.

The result: tests cover the happy path but not:

  • Malformed stdin / missing hook_event_name
  • Case sensitivity edge cases
  • Error handling paths

Proposed fix: After the implementation passes its first test, tdd-guard's AI prompt could check whether the passing tests cover only the happy path and suggest (not require) an edge case test before closing the TDD loop. This would be opt-in via config (tdd-guard: suggest-edge-cases: true) to avoid being annoying on trivial changes.

Problem 3: "File created successfully" with no file on disk

Separate from tdd-guard: the Write tool reported success for a stub file that didn't appear on disk. This cost a full debug cycle. Likely a hook interaction (tdd-guard bridge returned exit 2 after the Write tool reported success, and the file was rolled back silently). The user-visible message should distinguish "write attempted but blocked by hook" from "write succeeded."

This may be a Claude Code issue rather than a project issue — worth investigating whether the hook's exit code is being handled correctly in the bridge.

Priority

P2 — quality of life improvements, not blockers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions