Skip to content

Mazes Don't Need an AI: How I Decide What Goes to Claude and What Stays in Code

← Back to the Blog Menu

This week I built a prototype for a printable puzzle shop: you give it a children’s book, and it produces a bundle of mazes and word searches, an Etsy listing, and a launch email. The first plan I was handed had eight AI agents, including one that would ask an image model to draw the mazes.

The version I built has three Claude agents, and the mazes are drawn by about fifty lines of plain Python. It’s cheaper, faster, and the answer pages are always right.

The rule that got me there is simple.

If a task has one correct answer, write code. If it needs judgement or words, use Claude. Then let code check Claude’s work.

That’s it. Most agent systems I see get expensive and flaky because they skip the first half and send everything to the model.

A maze has a right answer: there is exactly one path from start to finish, and you can prove it. An image model can draw something that looks like a maze, but it can’t promise the maze is solvable, and it certainly can’t draw a matching answer page. Code can do both, every time, for free:

def make_maze(width, height, seed):
rng = random.Random(seed) # same seed, same maze
cells = [[0] * width for _ in range(height)]
stack, seen = [(0, 0)], {(0, 0)}
while stack:
x, y = stack[-1]
options = [d for d in (N, S, E, W) if inside(x, y, d) and step(x, y, d) not in seen]
if not options:
stack.pop()
continue
d = rng.choice(options)
nx, ny = step(x, y, d)
cells[y][x] |= d # knock down the wall on both sides
cells[ny][nx] |= OPPOSITE[d]
seen.add((nx, ny))
stack.append((nx, ny))
return cells

The answer page is a breadth-first search over the same grid. A test proves every maze is solvable. The same goes for word searches: placing words in a grid and filling the gaps is a puzzle with rules, not a creative task.

Claude got the jobs that need judgement or language:

  • Planning the bundle: which puzzles suit ages 4 to 7, how many easy versus medium, and page titles that use the book’s own characters.
  • Writing the Etsy listing: a title and description a parent would click on.
  • Writing the launch: a short newsletter and three social posts.

None of those has a single right answer, which is exactly where a model earns its cost.

Here’s the half people forget. Etsy has hard limits: a title of up to 140 characters and exactly 13 tags of up to 20 characters each. A listing that breaks them gets rejected.

So the Listing agent’s output goes through a plain function before anything else happens. If it breaks a rule, Claude gets one retry with the exact problems listed (“tag ‘printable puzzle activity pack’ is 31 characters; the limit is 20”). If it still fails, the pipeline stops and says why, instead of quietly publishing something broken.

Claude’s answers are also forced into a fixed shape with structured outputs, so the code never has to guess what came back.

The prototype stops twice for a yes: once after the bundle plan, before anything is built, and once after the listing, before anything goes public. Agents do the work between those two gates. That’s the same pattern I use for my own Upwork pipeline, and it’s the cheapest insurance there is.

Before I give any step to an agent, I ask:

  1. Is there one correct answer? Write code.
  2. Can I check the answer with rules? Let Claude write it, and let code check it.
  3. Does it need taste or judgement with no rule to check? That’s Claude’s job, with a human gate before it goes out.
  4. Does it cost money or carry someone’s name? A human approves it.

Eight agents became three, the image API bill became zero, and the part that has to be right always is.