Blog / Build with AI /

Building a to-do list app with AI

The to-do list is the “hello world” of web apps, and for good reason. It’s small enough to finish in an afternoon, and it touches almost everything a real app needs: input, display, editing, deleting, saving and a bit of design.

If you’re learning to build with an AI assistant, it’s an ideal first project. Here’s a path that gets you a working version, and teaches you something at each step.

The finished thing

A single web page where you can add a task, tick it off, edit or delete it, filter by “all”, “active” and “done”, and have everything still there after you reload the page.

Step 0: decide the scope in writing

Before you ask for code, write down what’s in and out. A good first scope:

In: add, complete, delete, edit, filter, save in the browser.
Out for now: accounts, syncing between devices, due dates, reminders, drag and drop.

Pasting this list into the prompt stops the assistant from adding things you didn’t ask for, and stops you from drifting. If you want help turning a bigger idea into pieces like this, how to break a big idea into tasks AI can do is worth a read.

Step 1: the first prompt

Build a to-do list web app using plain HTML, CSS and JavaScript in a single file. Features: add a task with an input and an Add button (also when pressing Enter), mark a task complete with a checkbox, delete a task, edit a task by double-clicking it, and filter between All, Active and Done. Show a count of remaining tasks. Don’t allow empty tasks. Keep the code readable with comments. No libraries.

Run it. Add a few tasks. Break it on purpose: add an empty task, add a very long one, add one with <b>bold</b> in it. This is where you learn what the assistant missed.

Step 2: understand the data

Under the surface, a to-do app is a list of objects, each like this:

{ id: 1722000000000, text: "Buy bread", done: false }

The page is a drawing of that list. When the list changes, the page is redrawn. If you understand this one idea, you understand a lot of web apps. Ask the assistant: “Explain how this code stores tasks and how it updates the page, in plain words.” Read the answer against the code.

The id matters. Using the position in the list as an identifier will break the moment you delete or filter items, because positions shift. A timestamp or a counter is safer.

Step 3: save the tasks

Right now, reload the page and everything vanishes. Browsers offer a simple place to store small amounts of data: localStorage. Ask:

Save the task list to localStorage whenever it changes, and load it when the page opens. Handle the case where nothing is saved yet, and the case where the saved data is corrupted.

The second sentence matters. Corrupted or missing data is the first thing that crashes simple apps.

Be aware of what this means: the tasks live in this browser on this device, and clearing site data erases them. That’s fine for a first version, and it’s a useful limit to understand. If you later want syncing, you’ll need a server or a service, and a whole new set of problems, including privacy. Privacy-first tools: keeping user data local argues for staying local as long as you can.

Step 4: put the text on the page safely

A subtle bug: if you insert the task text into the page as HTML, someone can type markup or script and it will run. For an app only you use this is harmless; for anything others touch it’s a security hole. The fix is to insert text as text (textContent), not as HTML (innerHTML).

Test it: add a task that says <img src=x onerror=alert(1)>. It should appear as plain words. If an alert pops up, ask the assistant to fix it.

Step 5: make it pleasant to use

Small touches that make the app feel real:

  • Focus returns to the input after adding a task.
  • A task being edited can be saved with Enter or cancelled with Escape.
  • Done tasks look different (crossed out, lighter), but still readable.
  • An empty state: “Nothing to do. Add something above.”
  • A “clear completed” button.
  • Keyboard accessibility: tab through the controls, and make sure checkboxes have labels. Empty states, errors and the small details that build trust explains why these matter.

Step 6: test on a phone

Open the page on a phone. Can you tap the buttons? Is the text readable? Does the keyboard cover the input? Most to-do lists are used on phones, and layout problems show up quickly. Ask the assistant to make the layout work from narrow screens up.

Step 7: keep a copy

Before the next round of changes, commit a snapshot or save a dated copy. When you ask an assistant to add features, it sometimes breaks the ones that worked. Undo buttons for builders: versions and backups shows the safety net.

What goes wrong

Everything disappears. You forgot to save, or you saved before the final change. Save after every change.

Tasks duplicate. Two event listeners got attached, usually because the code that draws the list also adds listeners each time. Ask the assistant to find it, with the symptom described exactly.

Editing breaks filtering. State lives in two places. Keep one list as the source of truth and draw everything from it.

Dates and times. Adding a due date is where complexity creeps in: time zones, formats, overdue logic. Leave it for version two.

Taking it further

Once the basic app works, pick one extension at a time:

  1. Due dates and sorting.
  2. Categories or tags.
  3. Drag and drop to reorder.
  4. Export and import as a file.
  5. A Chrome extension version. Building a Chrome extension with AI: the complete beginner’s guide covers that route.

And ask whether you need your own at all. Plenty of good task managers exist (task managers: Todoist, Things, TickTick and simple lists compares some). Building your own is worth it when you want to learn, or when you need something particular that they don’t do.

Key takeaways

  • Write the scope first: what’s in, what’s out.
  • A to-do app is a list of objects and a function that draws them.
  • localStorage saves data in this browser only; handle empty and corrupted cases.
  • Insert user text as text, never as HTML.
  • Test with bad input and on a phone, and keep a snapshot before each change.

What would make a to-do app you’d actually use daily? Write the one feature on a note and build only that next.