subject specific ai

How to Teach Coding With AI

EduGenius Team··16 min read

Watch the EduGenius tutorials playlist

Feature walkthroughs, setup help, and practical learning workflows connected to this article.

Open Tutorials

How to Teach Coding With AI

Teaching coding with AI works best as a "use, modify, create" progression: AI generates finished code for students to run and study, then partially-working code for them to fix and extend, and only later do students write original programs from scratch — with AI drafting practice challenges at each stage, never writing the code a student submits as their own.

Quick Answer: Use AI to generate leveled "use, modify, create" coding challenges and pair-programming prompts scaled to a student's current skill stage — while keeping the actual writing, running, and debugging of original code entirely in student hands once they reach the "create" stage.

Why Coding Pedagogy Is Different From General CS Content

Teaching coding is narrower than teaching computer science broadly — it's specifically about building the skill of writing, running, and fixing programs, and that skill has a well-documented learning progression. Researchers Irene Lee and colleagues, in their 2011 paper "Computational Thinking for Youth in Practice" (published in ACM Inroads), formalized the Use-Modify-Create framework: students first use existing code to see what it does, then modify it to change behavior, and only later create original programs. Skipping straight to "create" is where most beginning coders stall out.

That progression matters for AI use specifically, because each stage calls for a different kind of AI-generated material:

  • At "use," students need finished, correct code to run and study.
  • At "modify," they need code with a clear entry point for change.
  • At "create," AI's role shrinks to generating the challenge itself — the actual code has to come from the student.

Pair programming, a practice researched extensively by Laurie Williams at North Carolina State University, has also found its way into K-12 classrooms with adaptations recommended by CSTA:

  • Driver — the student typing, focused on the immediate code
  • Navigator — the student reviewing, catching errors and suggesting direction

AI can generate the discussion prompts that structure that review, without ever writing the code either partner submits.

Older students, particularly by Grade 8-9, are also increasingly likely to encounter AI coding assistants on their own outside of class — tools built directly into modern code editors that suggest or complete lines of code as a programmer types. That reality is worth addressing directly rather than pretending it doesn't exist.

A short, explicit classroom conversation about when an AI suggestion helps versus when it short-circuits the learning a specific assignment is trying to build tends to land better than a blanket ban a curious student will find a way around anyway.

StageWhat Students NeedWhere AI Fits
UseFinished, correct code to run and studyAI generates the working example, at a reading level students can follow
ModifyCode with a clear, findable point to changeAI generates a partial program with a specific modification target
CreateA well-scoped challenge, not a finished answerAI generates the challenge prompt and constraints; the code is the student's

A Framework: Match the AI-Generated Material to the Learning Stage

The single rule that keeps this honest: what AI generates should shrink as students move from "use" toward "create." Full working examples early, partial code with gaps in the middle, and only challenge prompts — no code at all — once students are ready to build original programs.

Use Stage: Worked Examples to Study

For a class just meeting loops for the first time, AI can generate a short, fully working Scratch or Python example — a simple counting loop — along with guided "trace the code" questions: what does this variable equal after each pass, and why? Students run it, predict its output, then verify.

  • Worked examples with trace questions — a complete, correct program plus questions asking students to predict output line by line
  • Annotated code walkthroughs — the same example with plain-language comments explaining each line, leveled to the grade
  • "Spot the pattern" comparisons — two similar working programs, asking what's different and why that changes the result

Modify Stage: Guided Debugging and Extension

Say you teach Grade 6 and your class has a working Scratch animation. You could ask AI to generate three modification challenges — "make the sprite change color when it touches the edge," "add a second sprite that reacts to a key press" — each requiring students to change existing code rather than start from a blank canvas. This is also where AI-generated debugging challenges fit: a script with one deliberate error for students to locate and fix.

Create Stage: Scoped Challenges, No Code Provided

Once students reach the "create" stage, AI's job narrows to generating the challenge prompt and constraints — a project brief, not example code. "Build a program that asks for a student's name and age, then tells them what year they'll graduate" gives students a clear target without handing them the solution.

Step-by-Step: Building an AI-Assisted Coding Progression

  1. Identify where your students actually are in the use-modify-create progression for the concept you're teaching — don't assume everyone is ready for "create."
  2. For new concepts, generate a worked example with trace-the-code questions, and have students run and predict before writing anything themselves.
  3. Move to modification challenges — AI-generated partial code with a specific, findable change to make.
  4. Layer in debugging practice — AI-generated scripts with one deliberate, grade-appropriate bug.
  5. Introduce pair programming for modify-stage work, using AI-generated discussion prompts to structure the "driver and navigator" roles.
  6. Move to create-stage projects only once students are comfortable modifying similar code independently — AI generates the brief, not the solution.
  7. Verify every generated example actually runs before handing it to students; a worked example that silently fails teaches the wrong lesson.

Concrete Coding Activities by Progression Stage

Use: Trace-the-Code Worksheets

For a Grade 4 class new to Scratch loops, generate a short working script and a worksheet asking students to predict the sprite's position after each iteration, then run it to check. This builds the mental model of what a loop actually does before students write one themselves.

Modify: Guided Extension Challenges

For a Grade 7 Python class, generate a working calculator program and three extension challenges of increasing difficulty — add a new operation, handle a division-by-zero case, add input validation. Each challenge requires reading and changing real code, not writing from nothing.

Create: Scoped Project Briefs

For a Grade 8-9 unit, generate a project brief with clear constraints: "Build a simple quiz program with at least three questions and a final score" — specific enough to guide the work, open enough that no two student solutions look identical.

StageBest AI-Generated SupportKeep Fully Student-Driven
UseWorked examples, trace-the-code questionsRunning and predicting the code's behavior
ModifyPartial code with a modification target, debugging challengesMaking the actual change and testing it
CreateProject briefs with clear constraintsWriting, running, and testing the original program

Setting Ground Rules for AI Coding Assistants With Older Students

By middle school, some students will have already seen or used an AI coding assistant, and pretending the technology doesn't exist tends to backfire. A short, direct classroom policy works better than silence.

  1. Name the tool explicitly. Tell students what AI coding assistance is, where they might encounter it, and why the classroom rule exists — this isn't the same as being unaware of it.
  2. Draw the line at "create" stage work. For a "create" assignment meant to demonstrate independent understanding, an AI-suggested solution defeats the purpose the same way copying a classmate's answer would.
  3. Allow it explicitly for exploration, if you choose. Some teachers permit AI-assisted exploration during unstructured tinkering time, since the goal there is curiosity rather than assessed skill — make that distinction clear rather than leaving it ambiguous.
  4. Tie the conversation back to the use-modify-create framework. Students who understand why the "create" stage matters for their own skill-building tend to buy into the boundary more than those who only hear it as an arbitrary rule.

The goal isn't to eliminate every trace of AI from a coding classroom — it's to be explicit about which parts of the learning process depend on students doing the thinking themselves, and to make sure that boundary is taught, not assumed.

Tools Teachers Actually Use for Teaching Coding

Most coding teachers combine a dedicated coding platform with a general content generator, rather than expecting one tool to cover the whole progression.

  • Scratch (MIT Media Lab) — the standard block-coding environment for the "use" and "modify" stages in elementary and early middle school
  • MIT App Inventor — a natural next step for older students moving toward more complex, project-based "create" work, particularly for students interested in building something they can use on an actual phone or tablet
  • Code.org — structured curricula (CS Discoveries, CS Principles) that already sequence use-modify-create style progressions
  • EduGenius — can generate worked examples with trace questions, modification challenges, debugging sets, and scoped project briefs matched to a class profile's grade level, then export them as printable materials
  • A general-purpose chatbot (teacher-supervised) — useful for drafting explainer text or brainstorming project brief ideas, but should never be the source of a program a student submits as original create-stage work

The practical split: Scratch, App Inventor, and Code.org are where students actually write and run code; a generator like EduGenius supplies the leveled materials that structure practice at each stage.

Handling a Classroom Spread Across All Three Stages at Once

Most coding classrooms don't have every student at the same stage on the same concept — some are still tracing loops, others are ready to extend a working program, and a few are ready to build something original. Treating the whole class as one stage produces bored advanced students and lost beginners in the same period.

A workable structure: run a short whole-class "use" demonstration for a new concept (five minutes, one worked example everyone traces together), then split into stage-matched stations for the bulk of the period.

  • Station one (use): students still building comfort with the concept work through additional worked examples and trace questions
  • Station two (modify): students ready to extend work through AI-generated modification challenges at their own pace
  • Station three (create): students who've already demonstrated the concept move to an open project brief

AI's role here is generating three parallel sets of materials for the same underlying concept — a trace worksheet, a modification challenge, and a project brief — from one prompt specifying the concept and the three stages, rather than a teacher building three versions by hand. Students can move between stations as they demonstrate readiness, rather than being locked into one track for the whole unit.

Assessing Coding Skill Without Just Grading the Final Program

A finished program tells a teacher less than it seems to. Two students can submit similar-looking final projects while one understood every line and the other patched together something that happened to work. Process-based checkpoints catch that difference; a single final-product grade usually doesn't.

Assessment TypeWhat It CapturesAI's Role
Trace-the-code exit ticketsWhether a student can predict behavior before running codeGenerating short trace prompts tied to the day's concept
Debugging logsSystematic problem-solving process, not just the fixGenerating the buggy starter code
Explain-your-code walkthroughsGenuine understanding versus copied or borrowed code(Teacher-led; AI can generate the guiding questions)
Peer code review notesAbility to read and reason about someone else's codeGenerating a review checklist scaled to the concept

A short "explain your code" conversation is particularly hard to fake — a student who doesn't understand their own program usually can't answer a simple "why did you write it this way?" question convincingly, even if the code itself looks correct. Building this into even a few projects a semester catches understanding gaps a rubric focused only on functionality would miss.

Pro Tips for Teaching Coding With AI

  • Match the AI-generated material to the stage, not just the grade. A Grade 8 student encountering a brand-new concept still needs "use" and "modify" support, regardless of their usual skill level.
  • Always run generated code before handing it to students. A worked example or debugging challenge only teaches the right lesson if it behaves exactly as described.
  • Use AI-generated discussion prompts to structure pair programming, rotating driver and navigator roles so both students engage with the code, not just one.
  • Never let AI generate the code for a "create" stage project a student submits. That's the exact point in the progression where the skill has to become genuinely the student's own.
  • Build a reusable bank of trace-the-code and debugging challenges by concept (loops, conditionals, functions), so you're not regenerating from scratch every unit.
  • Address AI coding assistants directly with older students rather than assuming they haven't encountered one — a clear, explicit policy holds up better than silence.

What to Avoid

  1. Don't let AI write the code for a create-stage project a student turns in. This is the clearest way AI assistance in coding class crosses into work that isn't the student's own.
  2. Don't skip the "use" and "modify" stages for a new concept, even with advanced students. Jumping straight to "create" without worked examples is where students most often stall or get frustrated.
  3. Don't hand out a generated worked example without running it yourself first. Silent errors in a "correct" example teach the mistake right alongside the concept.
  4. Don't treat pair programming as unstructured "sit together" time. Without a clear driver/navigator structure and rotation, one student tends to do all the work.
  5. Don't leave AI coding assistants as an unaddressed gray area. By middle school, silence on the topic tends to produce inconsistent, unspoken student assumptions rather than actual clarity.

Key Takeaways

  • The Use-Modify-Create framework (Lee et al., 2011) should determine what kind of AI-generated material fits at each point in a coding unit — worked examples, then partial code, then challenge prompts only.
  • AI's generated content should shrink as students progress — full code at "use," partial code at "modify," no code at all at "create."
  • Pair programming, researched extensively by Laurie Williams (NC State University) and adapted for K-12 by CSTA-aligned practice, benefits from AI-generated discussion prompts structuring the driver/navigator roles.
  • Debugging challenges remain one of the highest-value AI-generated activities at the "modify" stage.
  • Always verify generated code actually runs before it reaches a worksheet or challenge.
  • Tools split by role: Scratch, App Inventor, and Code.org are where students build; a generator like EduGenius supplies the surrounding leveled materials.
  • Stage-matched stations let one classroom serve students at different points in the use-modify-create progression without abandoning a shared unit concept.
  • A short "explain your code" conversation is one of the hardest assessments to fake, and catches understanding gaps a functionality-only rubric would miss.

Frequently Asked Questions

What is the "use, modify, create" framework in coding education?

It's a learning progression, formalized by Irene Lee and colleagues in a 2011 ACM Inroads paper, where students first run and study existing code, then modify it to change behavior, and only later create original programs. It's widely used to sequence K-12 coding instruction.

Can AI write code for students to turn in as their own work?

No. AI can generate worked examples, modification challenges, and project briefs to support learning, but code a student submits for a "create" stage assignment needs to be genuinely their own — using AI to generate that code defeats the purpose of the assignment.

How does pair programming work in a K-12 coding classroom?

Two students share one computer, with one "driving" (typing) while the other "navigates" (reviewing and suggesting), then switching roles. AI can generate discussion prompts that structure the review conversation, but the actual coding stays with the students.

What's the best free tool for teaching coding at different skill levels?

Scratch (MIT Media Lab) works well for elementary "use" and "modify" stages, while Code.org's structured curricula and MIT App Inventor support older students moving into "create" stage projects. A generator like EduGenius, with free starting credits, complements these by producing the leveled practice materials in between.

How do I manage a classroom where students are at different coding stages at once?

Run a brief whole-class demonstration for a new concept, then split into stage-matched stations — use, modify, and create — with AI-generated materials prepared for each. Students move between stations as they demonstrate readiness, rather than staying locked into one pace for the whole unit.

Should I let older students use AI coding assistants like autocomplete tools?

Set an explicit policy rather than leaving it unaddressed — most teachers draw the line at "create" stage assignments meant to demonstrate independent skill, while allowing more flexibility during unstructured exploration time where curiosity, not assessment, is the goal.


Teaching coding well ultimately depends on giving students the right kind of practice at the right stage. AI's role is to keep that practice supply flowing, never to do the coding itself.

For the bigger picture of how AI supports instruction across every K-9 subject, see Teaching Every Subject With AI: A 2026 Practical Guide.

#teachers#ai-tools#curriculum