AI Code Growth Demands Clean Codebases

▶ Watch (0:18)

GitHub saw a billion commits in 2025, its most active year. In 2026, the rate is accelerating: 275 million commits per week, projecting 14 billion by year end. A growing share are co-authored by AI agents. A Stanford study of 120,000 developers found that AI boosts productivity only when codebases are clean. Unchecked AI amplifies entropy. One team saw PRs increase but code quality drop, netting only 1% effective output gain. Clean code – good test coverage, type coverage, documentation – is the prerequisite.

Why Unit Test Coverage Falls Short

▶ Watch (4:54)

Traditional TDD overindexes on unit tests and code coverage. Tests tied to implementation details break when methods are renamed, even if functionality stays correct. AI-generated tests often become self-affirming: the suite passes but behavior is unvalidated. The solution is to test functionality, not internals. Playwright automates end-to-end browser interactions, simulating real user flows. It tests stable contracts like APIs or module exports, surviving refactors.

Playwright with AI Agents for Behavior-Driven TDD

▶ Watch (8:09)

Mhangami demoed a toy store scenario: a developer receives a feature request for search and filter. Using GitHub Copilot CLI with the Playwright MCP server, the agent first examined the codebase, then wrote failing Playwright tests (red phase). Next, it generated code to pass those tests (green phase). Finally, the developer refactors the agent’s output. In the demo, the agent ran the tests live – typing searches, clicking filters – and all passed. The process shifts the trigger from adding a method to receiving a feature request.

Best Practices for AI-Assisted Testing

▶ Watch (16:11)

Mhangani recommended three practices: attach Playwright screenshots to PRs for visual verification; run tests in headless mode to avoid browser windows; commit code before the agent makes changes so it can track history. She also advised generating one test per feature. For complex state management, she suggested using Playwright agents (planner, generator, healer) which include specialized instructions for handling state.

Q&A

How to handle complex state management in tests? Use Playwright agents with their built-in instructions, or test APIs directly if available. ▶ Watch (18:01)

Can Playwright test different screen sizes like desktop vs mobile? Yes, it supports mobile and desktop viewports. It is currently browser-based only. ▶ Watch (18:51)

Notable Quotes

does AI actually make developers more productive? Marlene Mhangami · ▶ Watch (2:22)

clean code bases amplify AI gains and AI productivity while unchecked AI in a codebase is going to amplify entropy. Marlene Mhangami · ▶ Watch (3:03)

the agent is going to understand what the codebase is going to look like and then going to write the tests for it. Marlene Mhangami · ▶ Watch (14:11)

all of our tests pass. Marlene Mhangami · ▶ Watch (15:49)

Key Takeaways

  • Clean codebases are prerequisite for AI productivity gains.
  • Playwright tests validate behavior, not implementation details.
  • AI agents can generate and run Playwright tests for feature-level TDD.