Food Production Schedule: AI Plans Around Allergen Changeovers

Coding Liquids tutorial cover featuring Sagnik Bhattacharya for Food Production Schedule: AI Plans Around Allergen Changeovers.
Coding Liquids tutorial cover featuring Sagnik Bhattacharya for Food Production Schedule: AI Plans Around Allergen Changeovers.

Group products by the allergens they contain, run the plainest recipe first and the highest-risk allergen last, book a cleaning window between each pair according to a changeover matrix, and size each batch to the shelf life your buyer requires. AI can draft the sequence; your allergen control plan decides which cleans are enough.

The reason a sequence matters is arithmetic as well as safety. Every deep clean costs line time, and two products that share their allergens need far less between them than two that don't. In the example below, ordering alone saves 55 minutes each time the five products run, and the same ordering reduces the chance that a trace of one product reaches another.

Follow me on Instagram@sagnikteaches

Three inputs the schedule needs before anyone sequences anything

An AI assistant can only order products sensibly if it has the facts a good planner would ask for. Collect these in one sheet first.

Connect on LinkedInSagnik Bhattacharya
  1. An allergen set for each product. If you do not have a matrix yet, building an allergen matrix from your recipes comes first, because the schedule is only as good as that table.
  2. Run rates and demand. Units per minute for each product, and the weekly demand by customer.
  3. Changeover rules. The clean required when moving from each product to each other product, as agreed in your allergen control plan, and the time each takes.

The third is the one that is often in someone's head. Write it as a matrix, and ask the person who signs off your cleaning to confirm it.

Subscribe on YouTube@sagnikteaches

The example: five products on one baking line

An illustrative small producer makes five products on one line, in a single 480-minute shift that starts at 06:00. Allergen sets (before any precautionary wording):

ProductAllergens in the recipeRun rateWeekly demandShelf life
P1 Plain oat barGluten (oats)20 a minute4,00012 weeks
P2 Milk chocolate oat barGluten, milk20 a minute3,00012 weeks
P3 BrownieGluten, milk, egg10 a minute2,40010 days
P4 Almond biscuitGluten, milk, egg, almondabout 13 a minute2,0008 weeks
P5 Peanut barGluten, peanutabout 11 a minute1,30010 weeks

Notice the nesting. P1's allergens are inside P2's, which are inside P3's, which are inside P4's. P5 sits apart, with peanut that no other product carries. That structure is the whole key to the schedule.

The Complete Excel Course with AI Integration thumbnail

The Complete Excel Course with AI Integration

From formulas and pivot tables to Power Query, DAX, VBA and AI with Copilot, ChatGPT and Claude — hands-on from the first lesson.

By Sagnik Bhattacharya and Virginia Thorn, Primetime Emmy Award winner

Buy now

The changeover matrix: what each move requires

A simple rule is used for planning: if the next product contains every allergen the previous one did, the previous product's residue cannot introduce a new allergen, so a shorter clean is usually enough. If the next product lacks any allergen the previous one had, residue could contaminate it, so a full clean with verification is needed. Your own allergen risk assessment and validation results decide whether that planning rule holds on your equipment; treat it as a starting position to confirm, not as a rule of the law. Published allergen guidance for manufacturers says the same thing more briefly: schedule products with no allergens first, add allergen-containing products as late as possible, and clean between products with different allergen profiles.

MoveAllergens droppedClean bookedMinutes
P1 to P2None (adds milk)Dry clean and check20
P2 to P3None (adds egg)Dry clean and check20
P3 to P4None (adds almond)Dry clean and check20
P4 to P5Milk, egg, almondFull wet clean and verification75
P5 back to P1PeanutFull wet clean and verification75
Any product, end of dayAllFull wet clean90

Recipe allergens are not the whole story. If the line also handles a product with a "may contain" statement, the sequence has to respect that too; the cross-contact risk log behind precautionary labelling is where those decisions live, and the schedule should follow them, never override them.

The weekly schedule for the five-product line

Making the week's 4,000 plain oat bars and 3,000 milk chocolate bars in one go would take 350 minutes of running, leaving no room for brownies in the shift, so P1 and P2 run twice a week at half their weekly demand. Brownies, with a ten-day shelf life, run twice a week at 1,200 for a reason covered below. The result:

DaySequence with timesOutput
Monday06:00 start-up and pre-op check (20 min); P1 06:20 to 08:00; dry clean (20); P2 08:20 to 09:35; dry clean (20); P3 09:55 to 11:55; end-of-day wet clean (90) to 13:252,000 P1, 1,500 P2, 1,200 P3
Tuesday06:00 start-up (20); P4 06:20 to 08:50; full clean and verification (75); P5 10:05 to 12:05; end-of-day wet clean (90) to 13:352,000 P4, 1,300 P5
WednesdayNo production: packing, stock check, planned maintenance, cleaning records reviewNone
ThursdayAs Monday2,000 P1, 1,500 P2, 1,200 P3
FridaySpare slot for catch-up, rework decisions or a rush order, plus a full cleanFlexible

Monday's two changeovers total 40 minutes. Compare a sequence chosen by convenience, say P4, P1, P5, P2, P3. P4 to P1 drops milk, egg and almond (75 minutes); P1 to P5 only adds peanut, so 20; P5 to P2 drops peanut (75); P2 to P3 adds egg (20). That is 190 minutes against 135 for the planned order across the same five products, 55 minutes lost purely to ordering each time the range runs, and with peanut run in the middle of the sequence rather than last. At 20 bars a minute, 55 minutes is about 1,100 bars you could have made.

Sizing batches to shelf life

Shelf life drives how often each product must run. Take the brownie, with a ten-day life and a retailer who wants six days remaining on delivery. Ten minus six leaves four days from baking to delivery. A Monday bake can supply deliveries on Monday to Thursday (days 0 to 3), and a Thursday bake supplies Friday to Monday (days 1 to 4). One weekly bake could not do that, which is why brownies appear twice in the schedule at 1,200, half the weekly demand each time.

For the long-life bars the logic reverses. A 12-week life with six weeks required at delivery leaves six weeks, so there is no need to bake weekly to protect freshness. The only reasons to run P1 twice are line capacity and stock cover. If you wanted fewer changeovers, you could make P1 and P2 in larger, less frequent batches, trading changeover time against the cash tied up in stock and the risk of date-code waste. That's a decision for you, and the schedule just makes both costs visible.

Prompting an assistant to draft the sequence

Give the assistant the tables, the rule and a clear instruction to explain itself so you can check it.

You are helping me schedule a small food production line. Use ONLY the data below.
Products with allergen sets, run rates, weekly demand and shelf life: [paste table]
Changeover rule: if the next product contains every allergen of the previous one, book the short clean (20 min); otherwise book the full clean (75 min). End each day with a full wet clean (90 min). Shift is 06:00 to 14:00. Start-up takes 20 minutes.
Task:
1. Propose a Monday to Friday schedule that meets weekly demand, sequencing so allergens are only added, never dropped, wherever possible.
2. Put the highest-risk allergen (peanut) last in the day before the end-of-day clean.
3. For each changeover, say which allergens are dropped and which clean you booked. Flag any changeover where you were unsure.
4. Show start and end times for each run and check the day fits the shift.
5. Do not shorten any clean to fit. If a day does not fit, say what to move.
Return a table, then a list of assumptions.

A realistic first reply gets the Monday sequence right and then misplaces P5. For instance, it might put the peanut bar on Monday after P3 "because it is a similar run rate", with a short clean booked on the basis that both contain gluten. That breaks the rule (milk and egg are dropped) and a careful reviewer catches it by checking the "allergens dropped" column the prompt asked for. The fix is to reply with the specific line, "P3 to P5 drops milk and egg, so this needs the full clean and verification; redo Monday", rather than a vague correction. The explanation requirement is what makes the draft checkable.

What the assistant must not decide

  • Whether a clean is adequate. That comes from your validation and verification (a check that surfaces are visibly clean, ATP or protein swabs, or allergen-specific test kits, as your plan specifies), not from a model's idea of a good time.
  • Whether two products can share a line at all. A decision about gluten-free claims or a product with a free-from claim needs your plan and testing, not a schedule tweak.
  • Label and rework rules. Rework containing allergens can only go into products that declare the same allergens (the "like into like" rule); this sits in your procedures and the HACCP plan you maintain and verify.

Four situations that break a neat weekly pattern

A rush order for the plain oat bar on Tuesday

Tuesday ends with the peanut bar and a full wet clean. Adding P1 after P5 would drop peanut, so a full clean (75) is needed first. If the order is 600 bars, 30 minutes of running, the cost is 105 minutes to make 600 bars, and Tuesday would end at about 15:20 after the closing wet clean, well past the 14:00 end of shift. Putting P1 first on Tuesday instead (a short clean before P4, which contains gluten too) costs 50 minutes, twice Tuesday's 25-minute buffer. The realistic options are Thursday's P1 run, Friday's spare slot, or overtime priced into the quote. The schedule's value is showing the cost of the shortcut before you agree to it.

A new product with sesame

A seed bar adds an allergen that nothing else on the line carries. Like peanut, it sits apart, so the scheduler needs it at the end of a day or on its own day, and the matrix grows by a row and a column. Add the product to the matrix first, then regenerate the schedule. This is where an assistant saves real time: it will redraw the week in seconds once the data is right.

A supplier changes an ingredient

If a supplier alters a specification and an ingredient now contains a new allergen, the product's set changes and the sequence may no longer hold. Catching supplier specification changes before they reach the floor keeps the matrix true.

A machine breakdown mid-sequence

Monday's P2 run stops at 09:05 with 900 bars made. After the repair, finish P2's remaining 600 before starting P3: jumping ahead to P3 and coming back for P2 would drop egg and need the full clean. Ask the assistant to replan the rest of the day from the current state, giving it the new start time, and compare with your own judgement.

When the printed schedule and the line disagree

An illustration of a failure mode. A producer builds a good schedule, then lets the sequence in the file drift: someone swaps P4 and P3 on a Thursday "to use up almond paste", the printed schedule on the wall still shows the old order, and the pre-op check ticks a box for the wrong product's allergens. The line is clean for the order written, not the order run. The fix is procedural: the schedule shows the date and a version, any change goes through the person responsible for allergens, and the pre-op check lists the first product by name from that day's schedule. The software only drafts; the controls make it real.

Linking the schedule to costs and records

Changeovers are a cost: the 155 minutes of between-product cleaning in the planned week (40 on Monday, 75 on Tuesday, 40 on Thursday) are line time that makes nothing, plus the labour of whoever cleans. They belong in the batch costing sheet, since a product that forces a full clean after every run costs more than the recipe suggests. The schedule should also feed your batch records, so each run has a date, product, batch code, start and end times and the clean that preceded it. Those records are what let you trace a product quickly if you ever need to, which a mock recall exercise will test.

The one-page schedule sheet, filled in

A schedule on a wall works best as a single page that a supervisor can sign. An illustrative Monday sheet for the example above, as it might be printed:

OrderProductAllergens declaredPlanned startPlanned endClean beforeClean signed by
1P1 Plain oat barGluten06:2008:00Start-up check[initials]
2P2 Milk chocolate oat barGluten, milk08:2009:35Dry clean, 20 min[initials]
3P3 BrownieGluten, milk, egg09:5511:55Dry clean, 20 min[initials]
EndWhole lineAll11:5513:25Wet clean, 90 min[initials]

Add a column for the verification result (pass or fail and the method used) and one for the actual start and end. When actuals differ from plan, the sheet is the first place a pattern shows: if P3 regularly finishes 20 minutes late, your run rate is wrong and next week's schedule should say so.

Turning the plan into numbers you can defend

Keep a small table of productive time per day: the shift minutes, less start-up, less cleaning, equals run minutes. For Monday, 480 minus 20, 40 and 90 leaves 330 minutes, of which 295 were booked to production, so there is a 35-minute buffer. On Tuesday the same arithmetic gives 480 minus 20, 75 and 90, leaving 295, of which 270 are booked, a buffer of 25. Share of the shift spent on non-production time is 150 of 480 minutes on Monday (31%), and 185 of 480 on Tuesday (39%). Seeing that figure each week tells you whether adding a sixth product is realistic: each new allergen set that can't nest into the existing chain adds a full clean to some day.

A fair question is whether a second shift or a second line would be cheaper than more clever sequencing. Work it out with the numbers: if a small separate area for the peanut bar removed Tuesday's mid-shift full clean, you would gain 75 minutes a week, but you'd also pay for the equipment and its cleaning. The sheet lets you try the case on paper before you spend.

Using the assistant for what-ifs on the matrix

Once the base schedule exists, an assistant is good at quick variations if you keep the rules attached. Three prompts worth saving:

  1. "Add product P6 (seed bar, gluten and sesame, 10 a minute, 800 a week, 12-week life). Show where it fits and what each placement costs in minutes of cleaning."
  2. "Retailer A now requires seven days remaining on brownies at delivery. Recalculate how often P3 must be made and show the new Monday and Thursday."
  3. "P4 fell behind and finished 40 minutes late on Tuesday. Replan the rest of the week with no clean shortened."

For each answer, read the reasoning, not only the table. The failure to look for is a plausible schedule that quietly reuses a shortened clean to make a day fit. A written line in the prompt, "do not shorten any clean", helps, and checking the minutes column catches the rest.

A smaller operation: one oven, two products

Not every producer has five products. Say a two-person bakery makes a nut-free loaf and a walnut loaf on one oven and one bench. The rule still gives the answer: run the nut-free loaf first, then the walnut loaf, then clean the bench, tins and tools thoroughly. Reversing the order would mean a full clean and a verification step before the nut-free loaf, and the first loaves of the day would carry the most risk. Even this one decision, written on a card above the bench, is a schedule. The assistant's job at this scale is small: turn the card into a weekly rota and a pre-op checklist, with the walnut loaf's day marked clearly so labels and ingredients are laid out in the right order.

How to check the schedule before it goes on the wall

  1. Walk through every changeover and write the allergens dropped. If any is not "none" and the booked clean is the short one, correct it.
  2. Add up each day's times and confirm the day ends before the shift does, with at least 15 minutes spare.
  3. Check weekly output against demand, product by product.
  4. Check each product's shelf-life logic: maximum age at delivery within the retailer's requirement.
  5. Have the person responsible for allergen control sign the schedule, and keep the signed version with the batch records.

If you'd like to map your own line and set this up with someone, that's what my AI implementation consultation covers.

Questions small food producers ask about scheduling

Why run low-allergen products first?

Residue from one product can carry into the next. Running the plainest recipe first, and the product with the highest-risk allergen last before a full clean, means fewer products are exposed to that risk and fewer deep cleans are needed. Your own allergen risk assessment decides what counts as highest risk.

How long should a changeover clean take?

There is no universal time. It depends on your equipment, the allergen and how your cleaning has been validated. Use the times your procedure and verification results support, and keep them on a matrix the scheduler reads. Never shorten a clean to fit a schedule.

Can ChatGPT or Claude make the schedule?

It can draft a good sequence if you give it the allergens, run rates, clean times and demand, and it can explain its choices. Treat it as a first draft. A person who knows the line checks each changeover against the allergen control plan before the schedule is issued.

How do I size batches to shelf life?

Work back from the retailer's minimum remaining life at delivery. Shelf life minus that requirement is the longest a product can wait between production and delivery, and that sets how often you must make it. Then batch size is the demand for that interval.

What if a rush order breaks the sequence?

Price it with the extra clean included, or fit it into the next slot where the allergens line up. A schedule that bends silently to every rush order will eventually produce a mislabelled or cross-contacted batch.

Further reads

Sources: allergen-management guidance on production scheduling (an allergen bureau's production-scheduling guide; a dairy-industry allergen guide covering like-into-like rework and visual cleaning checks) and a law firm's summary of a food regulator's draft allergen-programme guidance (ATP swabs, protein swabs, allergen test kits), all checked 5 November 2026. Run rates, clean times and allergen sets in the example are illustrative; your allergen control plan and your regulator's guidance decide yours.

Want a schedule your cleaning plan can defend?

On a 1:1 call we'll look at your products, allergens and line times, set up a changeover matrix the schedule reads from, and decide where AI drafts and where a person signs off.

Book a 1:1 call with me