Skip to content
zero2vibecodelearn vibe coding
Level 0 · A habit tracker, start to finish 9 min Reviewed by the author · Oct 22, 2026

Streaks, deleting, and a style pass

Three more turns turn a working page into one worth opening every day: a seven-day view with a streak, a safe way to delete, and styling that works on a phone.

Level 0 · 0 / 4 lessons0%
In this lesson

No hands-on task in this lesson — just read it through and answer the questions.

The page works and remembers. Now three turns make it worth using: seeing a week at a glance, getting rid of a habit, and looking like something you would open every morning. Same rhythm as before: run it, read the diff, commit it.

Step 4: the last seven days and a streak

Show the last seven days for each habit, oldest first, each with its own checkbox, so I can tick a day I forgot. Next to the name, show the current streak: the number of days in a row it was done, ending today, or ending yesterday if today is not ticked yet.

The “or ending yesterday” part is the detail that makes it feel right. Without it, your streak drops to zero every morning until you tick the day, which reads as a punishment for being awake.

Run it

You do not have to wait a week to test this. Tick the three days before today: the streak says 3. Untick the middle one: it drops to 1. Tick today: it goes up by one. Now untick everything except a day five days ago: the streak is 0, because the run does not reach today or yesterday.

Read the diff

Find the function that counts the streak. It should walk backwards one day at a time from today, or from yesterday, and stop at the first day that is not ticked. Two things to look for:

  • Going back a day. Subtracting a day with the date’s own day-setting function handles the end of a month correctly. Hand-made arithmetic on day numbers or on milliseconds is where month boundaries and clock changes go wrong.
  • Labels on the checkboxes. Seven identical checkboxes in a row are meaningless to a screen reader. Each one should say which habit and which day it is.

Checkpoint: step 4 in the reference repository. It also redraws the page when you switch back to the tab, because a tab left open overnight would otherwise still think it is yesterday. Your agent may not think of that on its own. If it did not, that is a fair one-line follow-up turn before you commit.

Quick check

Today is not ticked yet, but the four days before it are. What should the streak say?

Step 5: deleting, and the empty state

Add a Delete button to each habit that asks for confirmation first, and show “No habits yet” when the list is empty.

Run it

Delete a habit and cancel the confirmation: nothing changes. Delete it and confirm: it is gone, and stays gone after a reload. Delete the last one: the empty message appears.

Read the diff

Check that deleting also saves. A delete that only changes what is on screen comes back on the next reload, which looks like the button is broken. In the reference version the order is: ask, remove, save, redraw.

Checkpoint: step 5 in the reference repository.

Step 6: the style pass

Add a style.css. Make it readable on a phone first: one column, comfortable tap targets for the day checkboxes, and today’s column highlighted. Follow the system’s light or dark setting. Do not touch app.js.

Styling comes last for a reason: it is the change least likely to break behaviour, and the one you will want to redo most. Keeping it in its own commit means you can redo it without touching anything that works.

Run it

Narrow the browser window as far as it goes, or open the file on your phone. The seven days should still fit on one line, and you should be able to tick each one without zooming. Switch your system to dark mode and back.

Read the diff

Look at the list of changed files first. It should be style.css, new, and index.html, with one added line that links the stylesheet and maybe a wrapper element. If app.js changed, ask why before you accept it.

Checkpoint: step 6 in the reference repository. The JavaScript is untouched.

When the agent offers more

Where you are

Six commits, each one a working state. The app does everything the README promised. One step left, and it is the one that turns a folder into a project: putting it online.

How many turns should these three steps take?

Often more than three. A step that needs a follow-up turn, for an edge case or a fix you spotted in the diff, is normal. What matters is that each commit is a working state, not that each step was one prompt.

Should I write the CSS myself?

If you enjoy it, yes. There is no rule that the agent types everything. Styling is also a safe place to learn, because a mistake there changes how the page looks, not what it does.

Check your understanding

Answered 0/3
Mode:

How do you check the streak logic without waiting a week?

The style prompt says "do not touch app.js". What do you check in the diff?

Why does the delete button ask for confirmation?

Finish the task in the terminal and answer the questions to complete the lesson.

📝 My notes

Saved automatically in this browser · shows up on the Notes page.

Lesson Q&A

How do you check the streak logic without waiting a week?

Tick past days in the seven-day row and watch the count change, including unticking a day in the middle — Being able to tick a past day is a feature for users and a test harness for you. Three days in a row, then a gap, tells you whether the counting is right.

The style prompt says "do not touch app.js". What do you check in the diff?

That only style.css and index.html changed — An instruction in a prompt is a request, not a guarantee. The list of changed files is the one-second check that it was followed.

Why does the delete button ask for confirmation?

Deleting a habit also deletes its whole history, and there is no undo — The cost of a confirmation is one extra click. The cost of a mis-tap without one is weeks of streak, gone.

Today is not ticked yet, but the four days before it are. What should the streak say?

That is exactly the case the prompt spelled out. If your version says 0 here, the edge case got lost, and the fix is a turn that quotes that sentence of the prompt back.

Move between lessons with ← → · search with ⌘K

Written and reviewed by Mikhail Kuzmitskii