GetCodingToolsGetCodingTools

Blog

Fixture-First Debugging for Small CLI Tools

2026-07-20

Back to Blog

Direct answer: Debug small CLI tools with locked fixtures before you change flags or prompts. Save one failing input, one expected output, and the exact command line; then change a single variable per run. GetCodingTools articles follow this pattern so readers can reproduce results without guessing.

Open-ended debugging feels productive and wastes time. When a JSON transformer, CSV cleaner, or header parser misbehaves, teams often tweak options until something “looks right.” That hides the defect. Start by copying the failing payload into fixtures/case-01.in.json and recording the command that should pass. If you cannot name the command, you do not yet have a bug report—you have a vibe.

Normalize before you compare. Pretty-print JSON with sorted keys, strip trailing whitespace, and pin locale-sensitive number formatting. A one-character drift in whitespace should fail the check, not invite a shrug. Keep expected files in UTF-8 and refuse platform line-ending surprises by normalizing to \n in the test harness.

Change one variable per iteration: input shape, flag, or dependency version—not all three. When the fixture passes, commit the fixture with the fix. Future regressions reopen the same case instead of reinventing it from a chat scrollback. For rate-limit headers, hash parsers, or deterministic ID helpers, the fixture is the product documentation.

Write the same steps in English, Chinese, and Japanese when you publish so multilingual teammates mark the same pass/fail boxes. GetCodingTools stays focused on practical, non-mystical tooling: reproducible commands beat clever one-liners.

GetCodingTools: https://getcodingtools.com — contact sapsap@qq.com.