· Adventure · Coding
Clean Code Rescue: free coding game to learn refactoring
Skip's code works, barely. Rename, split and tidy it before the next feature breaks everything.
What is Clean Code Rescue?
Skip's Snack Club code works, but nobody can read it. Over four days, name what makes each short JavaScript snippet hard to read, then ship the rewrite that is clearer and still does exactly the same thing. One rewrite only looks tidier; another quietly changes the behaviour and turns the tests red.
Clean Code Rescue is a free coding game about refactoring. Skip's Snack Club code works, but it's full of vague names, bare numbers, copy-pasted lines, functions that do everything and ifs nested inside ifs. Each round shows a short JavaScript snippet: first name what makes it hard to read, then compare three rewrites and ship one.
The catch: only one rewrite is a real refactor, clearer and with exactly the same behaviour. One only looks tidier, and one quietly changes what the code does, so the tests go red and you lose a life. Every answer explains all three versions, so you learn the habits as you play, from named constants to early returns.
At a glance
- Category
- Adventure
- Difficulty
- Medium
- Play time
- 4–6 min
- Price
- Free, in your browser, sign-up optional
How to play
- Name the smell
- Vague names, a magic number, copy-paste, too many jobs in one function or deep nesting. +5 when you get it.
- Compare three rewrites
- Flip through versions A, B and C. The code was never broken: you're making it readable.
- Ship the clean one
- +10 for the clean refactor. One version only looks tidier (+0); one changes what the code does: the tests go red and you lose one of 3 lives.
- Four chapters
- Names, copy-paste, the pyramid of ifs, then a feature freeze with smaller traps. Finish with lives left for +5 per heart.
Scoring
Each snippet: +5 for naming the smell, +10 for shipping the clean rewrite. The rewrite that only looks tidier scores 0; the one that changes the behaviour turns the tests red and costs one of 3 lives.
12 snippets over four chapters. Finish with lives left for +5 per heart, up to 195 points.
What it trains
- Readable code
- Spotting vague names, magic numbers, copy-paste, long functions and deep nesting.
- Safe refactoring
- Changing the structure without changing the behaviour: every >, >= and ! has to survive the move.
- Code review
- Comparing three versions and explaining why one is better.
Strategy and tips
- The code already works
- This isn't bug hunting. You're looking for what slows a reader down, not for a crash.
- Names carry meaning
- count and unitPrice beat a and b. A name like data, thing or NUMBER is still vague.
- Name the reason, not the value
- MIN_PASSWORD_LENGTH explains 12; TWELVE doesn't.
- Copy conditions exactly
- When you move or flip a condition, check every > and >=, and every !.
- Guard order matters
- With early returns, the first check that matches wins, so keep the special cases first.
Why play Clean Code Rescue?
Code is read far more often than it is written. Refactoring, improving the structure without changing the behaviour, keeps a codebase easy to change: clear names, named numbers, one job per function, no copy-paste and flat logic. The hard part is doing it safely, and that's what the red-tests trap trains.
Frequently asked questions
Is Clean Code Rescue free?
Yes. It is free and runs in your browser, with no download. Signing up is optional.
Do I need to know how to code?
A little JavaScript helps, but every snippet is short and every answer is explained. Beginners pick up the vocabulary as they play.
How is it different from Bug Hunt?
In Bug Hunt the code is broken and you find the bug. Here the code works: you choose the rewrite that makes it readable without breaking it.
Is Snack Club a real app?
No. The app, the code and every name in it are made up for the game.