Building a Habit Tracker With AI Agents: An Infinite Loop, a Wrong Date and a False Alarm
We asked AI agents to build a habit tracker in Node.js with no dependencies. It needed daily check-ins, streaks that understand weekday schedules, a calendar heatmap, and data saved to disk. Every change went through a
We asked AI agents to build a habit tracker in Node.js with no dependencies. It needed daily check-ins, streaks that understand weekday schedules, a calendar heatmap, and data saved to disk.
Every change went through a release gate. The team's tests had to pass on the exact commit, the AI review of the real diff had to have no open high or critical findings, and a person had to approve.
The result: 50 of 50 tests. The review caught a real hang before it shipped. A person found two bugs no test could see and made the call on one false alarm.
Three parts, each one small
- Part 1, the core. Date helpers that are safe across time zones and daylight saving, the streak rules, and a habit store. The ticket named every file and every rule.
-
Part 2, the server and storage. Atomic writes, a corrupt file set aside instead of crashing, a 16 KB body limit, and proper
405,409and413responses. -
Part 3, the page. Static files with a strict Content Security Policy, the HTML, the styles and the script, started fresh from
main.
An infinite loop, caught before it shipped
Part 1 came back at 15 of 18 tests, and the gate held it. The AI review found something worse than the failing tests:
HIGH reliability:
previousScheduledmay loop indefinitely ifdaysarray is empty
A habit with no valid days would hang the streak calculation forever. That's a real bug, and it was caught before it reached main.
A wrong date in the tests
We ran it locally. The streak logic was right; three tests had the wrong expectations. One assumed March 12, 2023 was a Friday. It was a Sunday.
The follow-up gave the exact corrections, plus the guard for the hang. 20 of 20, release ready. Approved and merged.
A bug the tests couldn't see: the data file path
Part 2 passed its tests. Then we ran it by hand. Point DATA_FILE at an absolute path, and it quietly saved inside the project folder instead. Neither the tests nor the review could see that.
One follow-up fixed it, with tests. The server now refuses anything that isn't a .json file path.
A false alarm, decided by a person
After that, the review kept flagging the data file path as a security risk. A person looked at it. That setting comes from whoever starts the server, never from a request, so there is nothing for an attacker to control.
The finding was marked as a false positive. That decision is on the record with who made it, and the gate went green. Review findings are leads, and a person makes the final call.
A bug only a person could find: the Add button did nothing
Part 3's static files passed 50 of 50 on the first try. Then came the script, and we opened it on a phone-sized screen. You couldn't add a habit at all.
The script read checkboxes named days, but the page names them day. Every test passed, because no test clicks the button.
One follow-up covered everything we found:
- the checkbox name;
- friendly error messages;
- the heatmap styles;
- the review's suggestion to load each habit's history in parallel.
Now it works on the phone. You can check in, tap past days on the heatmap, and get a plain-English message for a duplicate habit name. 50 of 50, release ready, no blocking findings. Approved and merged, then checked again locally on Node 22.
What made this work
- The AI review caught a real hang before it shipped.
- The gate went by the real test results, and held every change until they passed.
- A person ran the app. That found two bugs the tests couldn't see, and settled a false alarm with a recorded decision.
For anything with a user interface, passing tests aren't the finish line. Open it, use it, and turn what you see into the next test.
The code is on our Forgejo server: https://nforge.dev/aicodeops-dev/habit-tracker
AI CodeOps works with GitHub, GitLab, Bitbucket, Gitea and Forgejo, including self-hosted. It's free during the open beta, and free forever for non-commercial open-source projects: https://aicodeops.dev
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.