Daeseon Yoo
Back to project
·Tech retro·2 min

Expanded 202 concept code snippets from one-liners to verified worked examples

The Concept Atlas and AI Camp code fields averaged 2.9 lines — sketches, not something you could learn the mechanism from. A generate-then-verify workflow rewrote all 202 into complete worked examples (avg 27 lines), each independently correctness-checked, then integrated with html.unescape and template-literal escaping.

The owner kept saying the Concept Atlas (/concepts) and AI Camp (/ai) were thin, and the measurement backed him: 136 concept + 66 AI-concept code fields averaged 2.9 lines. They were illustrative one-liners — fine as a glance, useless for actually seeing how the thing works. He wanted real code on every card.

A workflow generated a complete worked example for each of the 202 cards (Java for code/algorithm/backend, SQL for data, YAML/CLI for infra, TS/Python for frontend and AI), chunked seven at a time, and a second agent reviewed each chunk strictly for correctness — real APIs, correct syntax, no bugs, and that the snippet actually demonstrates that concept. Fifty-eight agents in total.

Integration was where the care went. Three things had to be right:

  1. Unescape first. Agent output is HTML-escaped, so the code came back full of <, >, &. Writing that straight to source would put literal < in every for loop. So every snippet goes through html.unescape before anything else.
  2. Escape for the template literal. The code lands inside a TS backtick string, so after unescaping, backslash, backtick, and ${ get escaped — otherwise a Java generic or a shell $VAR would break the file.
  3. Replace safely. For each card, find id: "x", then the code: backtick block bounded to before the next id:, and apply all replacements right-to-left so byte offsets stay valid as the file grows.

Result: average 26.9 lines per snippet (min 14, max 47), zero HTML entities left, tsc clean.

Two false starts worth recording, because both will recur. First, the workflow's args arrived empty in the script — passing a 17 KB array as args didn't take, so the data array got inlined directly into the script instead. Second, generating that script via a Python heredoc corrupted the JS: escaped backticks and \n came out wrong. The fix was to emit every embedded string through json.dumps, which always produces a valid JS string literal. After that the script parsed and ran clean.