Demock & Silent-Fallback Guard
Eliminate phantom mocks on live paths, silent exception swallowing with dummy data, and fake persistence fallbacks.
Why This Skill Is Needed & Target State
AI code generators often insert silent fallbacks to make a broken system appear to work:
- Falling back to local SQLite or in-memory dictionaries when a database connection fails (hiding outages and creating data split-brain).
- Catch blocks that swallow exceptions and return dummy empty arrays or mock objects (
catch { return [{ id: 1, name: "Sample" }]; }). - Instantiating
Mock*orFake*doubles in non-test runtime modules. - Security/auth checks that return
truewhen credentials or tokens are missing.
The target state is fail-closed, honest engineering: production paths either execute their real dependencies or surface explicit, actionable failures with exact RFC 9457 error contracts.
Invariant Rules
- Fail-Closed by Default: External dependency outages must never be silently masked with dummy fallback objects. Fail closed or degrade gracefully with visible caller-facing status.
- Zero Test Doubles in Runtime:
Mock*,MagicMock,Fake*, and test framework doubles are strictly banned in production files. - No Auth Bypass: Missing credentials must return 401/403 or throw
AuthenticationError, never returntrue.
CLI Usage
# Scan git diff against base commit
bunx anti-slop-engineering demock --base HEAD
# Scan specific files or directories with JSON output
bunx anti-slop-engineering demock src/ --json --strict