Testmuai iconTestmuaiSep 25, 2026 ~8 min source read

How to Run a Terminal TDD Workflow: Red, Green, Refactor from the Command Line

Use test-runner exit codes, a file watcher, and git to run TDD entirely from the terminal. This brief explains the loop, common pitfalls, concrete commands for JavaScript and Python, and how to prove tests catch bugs before gating commits and CI.

How to Perform Test-Driven Development From the Command Line

Share this story

Send the public story page.

Useful takeaways from this story.

Drive TDD with test-runner exit codes: confirm a failing test exits non-zero, then implement until it exits zero, and use watch mode to rerun on save.

Coverage alone is insufficient: add mutation testing (Stryker) or equivalent to ensure tests catch behavioral changes.

Gate commits and CI with pre-commit hooks (pre-commit or husky) so a red test suite blocks commits and CI rechecks the same exit codes.

The useful part

How to Perform Test-Driven Development From the Command Line | TestMu AI (Formerly LambdaTest) New: Join the waitlist Power Your Software Testing with AI Agents and Cloud The Native AI-Agentic Cloud Platform to Supercharge Quality Engineering. Start free with Google Start free with Email TestMu AI (Formerly LambdaTest) / Blog / How to Perform Test-Driven Development From the Command Line Automation Testing Coding.

How it works

  • You write one failing test and confirm it exits 1 on an assertion, write the least code that exits 0, then refactor while watch mode reruns the suite.
  • It finds changes through git, so outside a git or hg repository it exits 1 and suggests --watchAll.
  • AI agent gate: A Claude Code Stop hook that exits 2 while the unit suite is red keeps the agent working instead of letting it finish.
  • How to Set Up a Terminal TDD Workflow A terminal TDD workflow needs three things: a runner that exits non-zero when an assertion fails, a watcher, and git.
  • A test you wrote and watched fail is the check that still holds when AI writes the rest.

What to take from it

Right-reason red: A Jest test that imports a missing module exits 1 while reporting "Tests: 0 total", so no assertion ran. A stub that returns undefined turns it into a real failure: "Expected: 12, Received: undefined". The ptw command reruns pytest on every save and passes flags such as -x --lf --nf straight through.

Example or evidence

  • Commit and CI gate: husky for JavaScript and pre-commit for Python run the unit suite on every commit and block a red one.
  • Acceptance test first: A Playwright spec and a Kane CLI _test.md written before the feature pass on TestMu AI's Selenium Playground sum form, fail on the empty local page, and pass once the form exists.
  • Agent-built feature: a Kane CLI _test.md written before the feature goes red, Claude Code implements until kane-cli testmd run --agent exits 0, and replays guard the refactor.
  • DevOps report found 59.6% of respondents whose job includes writing tests rely on AI for it, at least in part, while 39.2% report little (27.3%) or no trust (11.9%) in code.

Details worth keeping

Git hooks and CI enforce the same exit codes. Jest's watch mode reruns the tests related to each saved file. With thresholds.break set to 90, the resulting score of 87.50 exits 1.

More context around this story.

Factory Office Automation Bots
Freelancer iconFreelancerSep 13, 2026

Factory Office Automation Bots

I need multiple bots to automate various tasks in my factory office. The bots will be crucial for: - Product Database Management - Task Management - Production Management - Sales and Quotation Management... (Budget: ₹12500 - ₹37500 INR, Jobs: Accounting, Automation, C# Programming, ERP, Inventory Management, PHP, Proce

Loading more related stories...

Keep reading in the app

Open the app view to save this story, compare related coverage, and continue from the same source.

Open in app