SESSION 4 · ~65M

Build: safety-stock calculator

Build a real tool end to end — demand and lead-time variability in, service-level-targeted safety stock out — and learn to validate it without reading the code.

Now we build something you'd actually use: a safety-stock calculator. The classic King's formula sets safety stock as the service-level z-score times the standard deviation of demand over the lead time. Your spec: inputs are demand history, lead time, and a target service level; output is the safety-stock number and a short explanation.

The formula, in words

Safety stock equals z times sigma times the square root of L, where z is the service-level multiplier (about 1.65 for 95%), sigma is the standard deviation of period demand, and L is the lead time in matching periods. The square root matters: it's why halving lead time cuts buffer by about 29%, not 50%.

  • Prompt for inputs: a CSV paste of demand, a lead-time number, a service-level percentage.
  • Ask for outputs: the safety-stock value, the z-score used, and a one-line interpretation.
  • Specify constraints: service level between 90% and 99.9%; reject empty or non-numeric demand; handle a single-period edge case.

Validate without reading code. Hand the tool a known case (demand you fabricated with a known standard deviation, lead time of 1) and check the output by hand against the formula. If it matches on simple cases, you can trust it on complex ones — no code-reading required.

Iterate via bug-report prompts. When the output looks wrong, don't open the code — describe the symptom precisely ('for this input the result is negative, which is impossible') and let the model diagnose and fix. This bug-report loop is the core vibe-coding workflow for non-programmers.

TRY IT

Run your calculator on demand of [10, 12, 9, 11, 10, 13], lead time of 2 periods, service level of 95%. Compute sigma by hand or in a spreadsheet, apply the formula, and confirm the tool's answer matches. You've now verified a tool you can't fully read.

CHECK YOUR UNDERSTANDING

In the King formula for safety stock, what is the role of the square root of L (lead time)?

How does the module recommend validating a vibe-coded tool you can't read?

What is the z-score for a 95% service level in the safety stock formula?

NOTEBOOKLM

Connect your notebook

Paste a NotebookLM share link to embed your notebook for this module.

Answer the 3 questions above to unlock
Streak
0-day streak
Today's fact
Progress
25% to next milestone