AI/ML · Prompt engineering · 3 min read

Composed Prompts for Personalized Drills

Five drill types now teach the same lesson to the same learner, instead of five unrelated ones.

At Eklan, I replaced one shared drill-generation prompt with prompts composed per drill type from the learner's profile, a scenario, a shared lesson focus and type-specific rules, behind feature flags, doubling items per drill and cutting answer-position bias.

My role
I designed and built the prompt composer, the cached lesson-focus service, the scenario templates for a 25-topic by 14-unit matrix, and the feature-flagged rollout.
Context
Founding AI Engineer, Eklan
Period
Sep 2026 – present
Status
Eklan · Founding AI Engineer
Platform
Drill generation in a Next.js web app

Eklan · Founding AI Engineer

  • 12 → 20vocabulary items per drill
  • 10 → 20fill-in-the-blank items per drill
  • 10/10 → 7/20drills with the correct answer in the first slot
  • 25 × 14topics × units covered by scenario templates
  • TypeScript
  • Prompt engineering
  • Next.js
  • MongoDB
  • Feature flags

Roles: AI/ML Engineer · Software Engineer · TA / Instructor.

The problem

Eklan generates five types of practice drill for each learner every week. They all came from one shared prompt, so each drill type picked its own vocabulary and its own situation. A learner could get five drills that had nothing to do with each other or with what they had studied, and the multiple-choice drills almost always put the right answer first.

Who it was for

Learners, who should practise one lesson from several angles, and tutors, who want the week’s drills to match the week’s class.

My role

I designed and built the prompt composer, the cached lesson-focus service, the scenario templates for a 25-topic by 14-unit matrix, and the feature-flagged rollout.

What I built

  • Prompts composed from blocks

    Each drill type's prompt is built by a pure function from five blocks (the learner, the scenario, the lesson focus, the drill-type instructions and the competencies) under a 9,500-character budget with a fixed order for what gets dropped first.

  • One lesson across five drill types

    One cached LLM call per learner picks a shared phrase bank and pronunciation targets, so vocabulary, fill-in-the-blank and the other drill types all reinforce the same lesson. A database lock with stale-lock reclaim stops two runs from doing it twice.

  • Scenario templates

    I wrote scenario templates for a matrix of 25 topics by 14 units, so a drill reads like a situation from that unit rather than a list of words.

  • Chained drill types

    Vocabulary output feeds fill-in-the-blank generation, so the second drill practises the words the first one taught.

  • Practice from live lessons

    Tutors record what a learner got wrong in a live lesson on that learner's week page and generate a targeted drill set for the same learner and week.

  • A safe rollout

    Everything sits behind feature flags. With the flags off, the generated prompts stayed byte for byte identical to the old ones, so turning the change on and off was safe.

The learner block carries more than a level. It includes the weaknesses recorded for that learner, from grading and from tutors’ notes, so the drills lean towards what that person actually gets wrong. The scenario block places the drill in a situation from the learner’s current unit, and the lesson-focus block names the phrases and sounds the whole week should repeat. The drill-type block is the only part that differs between, say, a vocabulary drill and a fill-in-the-blank drill.

The budget matters because a learner with a long history can produce a very large context. Instead of letting the prompt grow without limit, the composer has a fixed order for what is dropped first when the 9,500-character budget is reached, and unit tests cover each block and each drop.

How it works

For each drill type, a pure composer assembles the prompt from five blocks under a character budget. A cached lesson-focus call makes every drill type share the same phrases and pronunciation targets, and the composed prompt then goes to generation.

A pure composer builds each drill type's prompt from five blocks under a character budget; a cached lesson-focus call makes all five drill types share one lesson, and flags keep the old output byte for byte when off. Relationships: Learner block to Scenario block; Scenario block to Lesson focus; Lesson focus to Drill-type rules; Drill-type rules to Composer; Composer to Five drill types.

The lesson-focus call is cached per learner, so it runs once and every drill type reads the same result. A lock in the database, with a way to reclaim a lock left behind by a crashed run, makes sure two requests never pick two different focuses for the same learner.

Decisions that mattered

  • I chose a pure composer function with a character budget over one long shared prompt edited by hand because a pure function can be unit-tested block by block, and a fixed drop order decides in advance what gives way when a learner's context is large

  • I chose a cached lesson-focus call per learner over letting each drill type pick its own focus because five independent choices produced five unrelated drills; one shared focus makes the set teach one lesson

  • I chose byte-identical output with the flags off over shipping the new prompts directly because it proved the change did nothing until switched on, so rollout and rollback were a flag flip

Hard problems I solved

  • ProblemThe model put the correct answer in the first option every time.

    FixType-specific rules in the composed prompts spread the answers; the correct answer landed in the first slot 7 times in 20 instead of 10 in 10.

  • ProblemDrills were short and generic.

    FixThe scenario and lesson-focus blocks gave the model enough material to write longer, connected drills, doubling the items per drill.

  • ProblemWhile tracing the old prompt path I found defects nobody had reported.

    FixI documented them for the team to prioritise (a template lookup that never matched, translations fixed to one language, and multi-learner batches collapsing into one) rather than fixing them silently inside this change.

Tech stack

Generation
App and data

Outcome

Drill generation before and after composed prompts
MeasureBeforeAfter
Vocabulary items per drill1220
Fill-in-the-blank items per drill1020
Correct answer in the first slot10 of 107 of 20

The trade-off is size: composed prompts use about 47% more tokens than the old shared prompt, which I reported along with the gains.

Because the flags kept the old prompts byte for byte when switched off, the change could go to staging dark, be compared there, and be switched on without a second deploy.

What I learned

Treat a prompt like code: compose it, budget it, test it, and ship it behind a flag.

Once the prompt was a function of named blocks, the questions changed from “is the wording right” to “which block is missing for this learner”, which is a much easier question to test.

What I’d do next

Measure whether learners retain the shared lesson better across a week, not only whether the drills are longer and less biased.