# KnitPurrCode: teaching programming with yarn blocks, with the teacher in the loop 🧶🐱

> Source: <https://dev.to/juniorgpglitch/knitpurrcode-teaching-programming-with-yarn-blocks-with-the-teacher-in-the-loop-415m>
> Published: 2026-11-29 10:06:19+00:00

**Recommendation:** Pair tutor prompts with a code-level output filter that rejects any response containing the solution, since prompting alone failed to prevent answer leakage.
More in the playbook "Verifying model output": <https://wpnews.pro/playbooks/output-verification>

**Programming is like knitting: stitch by stitch, with your teacher by your side.**

🌐 **Live demo:** [https://knitpurrcode.vercel.app](https://knitpurrcode.vercel.app)

💻 **Code:** [https://github.com/juniorgp-glitch/KnitPurrCode](https://github.com/juniorgp-glitch/KnitPurrCode)

We're **Alba and John**, two Industrial Electronics and Automation Engineering students at Universitat Rovira i Virgili (URV). At **HackEPS 2026** we took on the **JetBrains "No code / Low code" challenge**: help people learn programming without writing code from scratch, *with the teacher in the loop*.

## 
  
  
  The problem 🤔

Most AI tools for learning to code are a 1:1 chatbot that gives students the answer, as if the teacher didn't exist. But real teaching happens in a classroom. A good teacher notices that half the class is stuck on the same point, explains it again in a different way, and knows who needs a push and who needs help.

So we asked ourselves: **how do we make the teacher a better teacher, not just the student a faster copier?**

## 
  
  
  What we built 🧶

**KnitPurrCode** is a Moodle-style virtual classroom with two sides.

### 
  
  
  For students: yarn blocks that are real code

- A **block editor shaped like yarn** . Every block*is* real code, in**C, C++, Python and JavaScript** , with the same blocks and colours in all four.
- Blocks are tied to the program with a **yarn thread** , nested blocks braid into their parent, and errors show up as**knots** 🪢.
- Blocks and code are always the same program: switch views at any time and see exactly what you built.
- Real execution: an interactive terminal, automatic grading with hidden tests and a **step-by-step debugger** with breakpoints.
- 
**MichiCode** 🐱, a crocheting-cat AI tutor that**teaches without solving** : progressive hints, never the answer. Ask it for the solution and it gets angry, and your
teacher finds out.

### 
  
  
  For teachers: watching the class live

- A red **"Online" button** shows who is coding right now.
- One click opens a **live mirror of the student's screen** , with the lines they just wrote highlighted in green.
- When a student leaves, the teacher gets a notice and moves straight to their **git-style version history** : every submission compared with the previous one, so you
see*how* they got there.
- A **teacher assistant** answers questions like "who is stuck?" or "most common errors" from real class data. It gives the teacher a read on the class, not a decision
already made.

## 
  
  
  How it works under the hood ⚙️

- 
**Our own code engine** in Python: a lexer, parser, checker and interpreter for C/C++, written during the hackathon. Python and JavaScript are*parsed* (with`ast` and`esprima` ) into the same block tree and run in a sandbox with step, output and recursion limits.
- 
**Live supervision:** the student's editor sends its state to`POST /api/live` (debounced, plus a 15-second heartbeat). The server compiles it and saves it, and**Supabase Realtime** pushes the change**only to that class's teacher** , enforced by**Row Level Security** . When the student closes the page, a`keepalive` request
tells the teacher within seconds.
- 
**AI with guardrails:** prompting alone wasn't enough to stop the tutor from giving away answers. So there's an**input filter** (prompt injection, harmful requests,
insults, requests for the solution) and an**output filter written in code** that discards any answer containing the solution.
- More than **300 automated tests** , plus end-to-end tests with Playwright against production.

## 
  
  
  Keeping ourselves in the loop 🤖

We built KnitPurrCode in **PyCharm with JetBrains Air**, working with AI coding agents while we reviewed, steered and rejected their changes. Our app keeps the teacher in the loop, and we tried to keep ourselves in the loop with the agents in the same way.

We also ran a small experiment: **Claude Agent, Codex and Junie** got the same five tasks on our own codebase (explain the code, find bugs, write a test, give a student a hint *without* the fix, review accessibility). Then we **ran every claim they made**:

- All **10 moderation bugs** they reported were real, so we fixed them and added regression tests.
- None of them gave the "student" the solution, but one came close. That confirmed our design: the "don't solve it" rule has to be enforced in code, not just asked for
in the prompt.
- One agent couldn't even run Python in its session and still sounded completely sure of itself. **Checking what the agents say is our job.**

Full report: [`docs/model-comparison.md` ([https://github.com/juniorgp-glitch/KnitPurrCode/blob/main/docs/model-comparison.md](https://github.com/juniorgp-glitch/KnitPurrCode/blob/main/docs/model-comparison.md))

## 
  
  
  What we learned 📚

- "Teach, don't solve" is a **design constraint** , not a prompt: it shapes the UI, the hints, the filters and the teacher's view.
- Realtime + Row Level Security works really well for classrooms.
- Keeping blocks and code in sync is much easier when both views come from the same syntax tree.

## 
  
  
  What's next 🚀

- 📱 **Mobile and desktop apps** on the same backend, with offline practice.
- 🧠 Tutoring with **memory across sessions** , and error patterns across the whole class.
- 🔌 A **JetBrains IDE plugin** to go from blocks to a real IDE.
- 🏫 Pilots in real schools.

## 
  
  
  Try it! 🐾

👉 [https://knitpurrcode.vercel.app](https://knitpurrcode.vercel.app)

- Teacher: `marta.vidal@knitpurrcode.com`
- Student: `aina.costa@knitpurrcode.com`
- Password: `Demo1234`

Open each one in a different browser tab and watch the live view work. We'd love your feedback! 💬

*Made with 🧶 and lots of ☕ by Alba De Vicente Companys & John Jairo Gutierrez Posada at HackEPS 2026.*
