The Debugging Iron Rule: Log First, Then Fix
When AI hits an error, its first instinct is to guess a cause and try a fix, then guess another if it fails. This section establishes the most fundamental rule: no guesswork fixes. The two demos below let you compare the two bug-fixing paths hands-on.
No guesswork fixes. When the root cause cannot be confirmed, you must first validate your hypothesis through logs, breakpoints, or test scripts. "Let me just try changing this and see" is forbidden. Backend logs go to the terminal; frontend logs go to the browser Console. For any problem, the first step is always: add logs.
Click a path to observe the fix process. The counters on the right track the number of rounds and cumulative lines changed.
Guesswork Fix · Results
Log First, Then Fix · Results
The rule requires answering three questions before fixing any bug. Open each question in order — only after reading all three will the "Start Fix" button unlock.
Pre-fix research complete — proceed. After fixing, there is one last step: declare the impact scope so everyone knows what to regression-test.
No Mock to Bypass Real AI Interfaces
For any feature involving AI model calls, confirm the interface is truly accessible before delivery. If the user has not provided an API Key, stop and ask for it — hardcoding fake responses or local mocks to bypass the real call is forbidden. Once the key is in place, send a test request to verify it works before continuing development.
No Delivery Without Passing Unit Tests
Cover core business logic, API interfaces, data processing functions, and edge cases. Test files go in tests/, named test_{module_name}.py; Python projects use pytest. Temporary scripts used for debugging must be deleted after use.
Evidence first. The 2 minutes spent adding logs saves three rounds of guesswork rework and prevents the root cause from being buried. After fixing, declare the impact scope in the format ⚡ Impact scope: XXX, YYY, ZZZ, and pass both the real interface check and unit tests before delivery.