Split Work Into Small Tasks

Your escape-room builder says whether a team can finish a room. For The Smuggler’s Cellar, it says the room cannot be finished and then stops. It doesn’t say which puzzles a team can never reach, and that’s the next step in your plan. You could hand your agent that step in one request. However, asking for a whole feature leaves many decisions to the agent, and you get them back as one large change.

In this lesson, you’ll split that step into small tasks, each one a change you can check and commit, and keep them in a file your agent works through. You’ll also learn to tell when a task is too big for one agent run. Start with what goes wrong when the whole step is one task.

Spot a Task That’s Too Big

In this course, you’ll continue work on the escape-room builder, either your own version or the reference version from the course download. If you’re starting here, read the download’s docs/brief.md and docs/map.md first. The lessons rely on a few habits:

  • Context: Your agent works only from what’s in its session and the files it reads, so decisions live in the brief, the plan, the instruction file, and the map.
  • Permissions: Your agent’s settings decide which commands it runs without asking you.
  • Checkpoints: Every job starts from a clean git status and ends in its own commit. git restore takes changed files back to the last commit, and git clean -f removes new files once git clean -n has listed them.
  • Plan first: The agent builds from docs/plan.md, a plan you reviewed against the brief before any code.

The plan’s next step is one line: name each puzzle a team can never reach. Say you paste that line into your agent as it stands. The agent has to decide where to build the list, what the command prints, whether a puzzle that’s stuck only because another one is stuck counts too, and whether to explain what blocks each puzzle. It makes most of those choices without asking you first, and its summary at the end may not mention all of them.

The longer the agent runs, the more its context fills with its own steps, so it can also drift from the plan. What comes back is a big diff, the added and removed lines across every changed file. Later lessons show you how to read one. For now, look at its size. This one touches the checker, the command, the tests, and maybe new test rooms, all at once.

A change that size is hard to review honestly in one sitting. If one part is wrong, you either fix it inside everything else or throw the whole change away.

A task, in this course, is one change you can check and commit: a behavior you can try or a test that passes, and a diff you can read properly in one sitting. A small task fails small. If it goes wrong, going back to the last commit costs you one task’s work, not the feature’s.

Three signs tell you a task is too big for one agent run:

  1. Its description needs “and”. “Find the unreachable puzzles and print them with the reason each one is stuck” is at least two tasks.
  2. It touches unrelated parts. A task that changes the checker’s logic and also tidies up the command’s error messages mixes two reviews in one diff.
  3. You can’t say how you’ll check it. “Improve the report” has no test that passes and no output you can look at, so you can’t tell when it’s done.

You can judge a task from what it touches and how you’ll check it, without reading any code. Try the three signs on your own plan’s next step first. Then use the button below, which opens Code Mentor with the question filled in. Paste the step from your plan under the question, and Code Mentor applies the three signs to what you pasted:

Slice Through Every Part

Once a step is too big, the first split that comes to mind is often by part. Naming the unreachable puzzles touches three parts of the project: the test rooms that show the problem, the checker that works it out, and the command that prints the result. A split by part gives you three layers:

  1. Write every test room the report needs.
  2. Write all of the checking logic.
  3. Write all of the output.

Watch out: splitting by layer looks tidy, but you can’t try the complete report end to end until the output is connected. A mistake in how the parts fit together turns up late, after the other layers are built on it.

A vertical slice cuts the other way. Each task is a thin piece of the feature that runs through every part it needs and ends in a check and a commit. It’s the same idea as the walking skeleton your project started from, with each part connected and working but doing very little. That skeleton already runs end to end, so each task adds one small behavior to it. Here’s the same step as three such tasks, in the order the reference version uses:

  1. The checker returns the ids of the puzzles that no path reaches: none for The Lighthouse Keeper’s Study, and the iron strongbox and the trapdoor for The Smuggler’s Cellar.
  2. The command prints those puzzles’ names after the “cannot be finished” verdict.
  3. Each unreachable puzzle says which of its needs nothing reachable provides, such as “needs the iron key, which nothing unlocks”.

Isn’t task 1 the checking logic layer you set aside? The difference is scope. That layer builds all of the report’s logic, the reasons included, before any output is connected.

Task 1 is one behavior with its own observable result: the ids the checker returns, which a test compares with the answers above. It isn’t an end-to-end slice yet, since the command prints nothing new, but task 2 connects it to the command before any more logic gets written. Here are both splits side by side:

Built in layers (test rooms, checking logic, output), the report is first tried at the end. Built in three slices (puzzle ids, names, reasons), each task ends in a check and a commit.
A Late Check With Layers, an Early One With Vertical Slices

The order matters too. Put the piece the others depend on first, and the uncertain part early. Both point at task 1.

Tasks 2 and 3 build on the list task 1 returns, and task 1 is also the part you’re least sure of. Does the checker catch the trapdoor, which is stuck only because the strongbox is? If the approach is wrong, you find out after one task instead of three. The wording of the output is the safe part, so it comes later.

Keep the Task List in the Repository

A split that lives in your head or in one chat is gone when the session ends. A new session starts with an empty context, so the list needs to be a file, like the brief and the plan. Keep it in docs/tasks.md, with a checkbox and a check for each task. Commit each task separately.

This is the reference version’s list, as an example of the shape:

Language: Markdown Text Filename: docs/tasks.md
# Tasks: Name the Unreachable Puzzles

From docs/plan.md: name each puzzle a team can never
reach. One task at a time, each in its own commit.

- [ ] 1. The checker returns the ids of the puzzles no
  path reaches.
  Check: npm test, with a test that expects no ids
  for The Lighthouse Keeper's Study, and strongbox and
  trapdoor for The Smuggler's Cellar.
- [ ] 2. The command prints those puzzles' names after
  the "cannot be finished" verdict.
  Check: npm start -- rooms/the-smugglers-cellar.json
  names the iron strongbox and the trapdoor.
- [ ] 3. Each unreachable puzzle says which of its needs
  nothing reachable provides.
  Check: the strongbox's line says it needs the iron
  key, which nothing unlocks. npm test passes.

Each task names one change and says how you’ll know it works. You’ll give your agent one task at a time. When a task’s check passes and you’ve read its diff, tick its box, - [x], and commit the task’s changes along with the updated list. Then your agent in a fresh session, or you next week, can open the file and see where the feature stands.

Now write your own. Open your docs/plan.md, find the step that names the puzzles a team can’t reach, and split it into docs/tasks.md in your own words. Your plan may word the step differently, or your project may already do part of it, so your list can differ from the reference’s. As you write, check that:

  • Each task is one behavior you can check, with a diff you can read in one sitting. It can touch the checker, the command, and the tests when they all serve that behavior. An “and” is a cue to look for unrelated work to split off.
  • Each task ends in a test or a command you can run, not a layer that waits for the next task.
  • The piece the others depend on and the part you’re least sure of come first.

You won’t run your agent in this lesson, because deciding the split is your job. You’ll hand task 1 to your agent after the exercise that follows, in Write a Finishable Task. When your list is ready, paste the plan’s step and your docs/tasks.md into Code Mentor for a review of the size, the checks, and the order:

Make the changes you agree with, then commit the list on its own:

Language: Shell
$ git add docs/tasks.md
$ git commit -m "Add task list for the unreachable-puzzle report"

Run git status afterward. Apart from your agent’s settings folder, it should show nothing to commit.

Check Your Understanding

Answer these before you open the answers:

  1. A task reads: “Make the command print the unreachable puzzles, and clean up the message for a room file that doesn’t exist.” Is it the right size for one agent run? If not, how would you split it?
  2. Your list has the task “Make the report better for designers.” What’s wrong with it, and how could you fix it?
  1. It’s too big. Its description needs “and”, and it mixes two unrelated changes: the report and the error message for a missing file. Split it into two tasks, each with its own check and commit: print the unreachable puzzles’ names and clean up the command’s message for a missing room file. You check each one by running the command.
  2. You can’t say how you’d check it, so there’s no point where it’s done. Name one change and its check, such as “Each unreachable puzzle says which need nothing reachable provides. Check: the strongbox’s line names the iron key.”

You now have a committed list of small tasks for your unreachable-puzzle report, with the uncertain part first. Next comes the course’s first coding exercise. You’ll read a task list for the escape-room builder, flag the tasks that won’t fit one agent run, and split one of them.

Exercise: Split an Oversized Task runs in your browser and doesn’t involve your agent. You edit the file in the editor, then click Run Tests for automated feedback. If a test fails, read its message for a clue, change your answer, and run the tests again. Full screen gives you more room, and the exercise’s Contents tab explains the rest.

Become a Member to join the conversation.