mcpbeat Sign in

Algo Sc Safety Stock Agent Skill

Calculate safety stock levels to buffer against demand and lead time uncertainty. Use this skill when the user needs to set inventory buffers, determine service level trade-offs, or optimize safety stock across SKUs — even if they say 'how much buffer inventory', 'stockout prevention', or 'service level calculation'.

8k tokens
context cost
the whole folder, loaded on every use
5
files
ships runnable scripts
0
copies elsewhere
how many repositories repackaged it
223
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/asgard-ai-platform/skills --skill algo-sc-safety-stock

What comes with it

29 294 bytes besides the instruction
examples/sample_input.json
references/intermittent-demand.md
references/multi-echelon.md
scripts/safety_stock.py

The instruction itself

15 sections, as written by the author

Safety Stock Calculation

Overview

Safety stock is buffer inventory held to protect against demand and lead time variability. Formula: SS = z × √(LT × σ²_d + d² × σ²_LT) where z=service factor, LT=lead time, σ_d=demand std dev, d=avg demand, σ_LT=lead time std dev. Directly trades inventory cost against stockout risk.

When to Use

Trigger conditions:

  • Setting inventory buffers for variable-demand items
  • Choosing target service levels and computing required safety stock
  • Optimizing safety stock across a portfolio of SKUs

When NOT to use:

  • When demand is deterministic (use EOQ without safety stock)
  • For one-time purchase decisions (use newsvendor model)

Algorithm

IRON LAW: Safety Stock Is a TRADE-OFF, Not a Target
More safety stock = fewer stockouts but higher holding cost.
The relationship is non-linear: going from 95% to 99% service level
roughly DOUBLES safety stock. Going from 99% to 99.9% doubles it
again. Always quantify the cost of each service level increment.
z-values: 90%→1.28, 95%→1.65, 99%→2.33, 99.9%→3.09.

Phase 1: Input Validation

Collect: historical demand data (weekly/monthly), lead time data (average and variability), target service level, unit cost and holding rate.

Gate: Minimum 12 periods of demand data, lead time estimates available.

Phase 2: Core Algorithm

  • Compute demand statistics: average demand (d), demand standard deviation (σ_d)
  • Compute lead time statistics: average LT, LT standard deviation (σ_LT)
  • Compute combined variability: σ_combined = √(LT × σ²_d + d² × σ²_LT)
  • Look up z for target service level
  • Safety stock = z × σ_combined
  • Reorder point = d × LT + SS

Phase 3: Verification

Simulate: using historical demand, would the computed SS have prevented stockouts at the target service level?

Gate: Simulated service level matches target (±2%).

Phase 4: Output

Return safety stock with cost impact and service level analysis.

Output Format

{
  "safety_stock": 250,
  "reorder_point": 850,
  "service_level": 0.95,
  "annual_holding_cost": 5000,
  "metadata": {"avg_demand_weekly": 120, "demand_cv": 0.3, "avg_lead_time_weeks": 5}
}

Examples

Sample I/O

Input: Weekly demand: avg=100, σ=30. Lead time: avg=4 weeks, σ=1 week. Target: 95%.

Expected: σ_combined = √(4×900 + 10000×1) = √(3600+10000) = √13600 = 116.6. SS = 1.65 × 116.6 = 192 units.

Edge Cases

| Input | Expected | Why |

|-------|----------|-----|

| Zero demand variability | SS from LT variability only | σ_d = 0, only lead time risk remains |

| Zero lead time variability | SS from demand variability only | σ_LT = 0, standard formula simplifies |

| Very long lead time | High SS | More uncertainty accumulates over longer periods |

Gotchas

  • Normal distribution assumption: Formula assumes normally distributed demand. Highly intermittent demand (many zeros) needs different approaches (Poisson, negative binomial).
  • Demand forecast error, not demand variability: If you use a forecast, SS should buffer forecast ERROR (σ_error), not raw demand variability.
  • Service level definition: Cycle service level (probability of no stockout per cycle) ≠ fill rate (fraction of demand met from stock). Companies often mean fill rate but calculate cycle SL.
  • Lead time data quality: Lead time variability is often poorly tracked. Underestimating σ_LT leads to insufficient safety stock.
  • ABC segmentation: Don't apply the same service level to all SKUs. A-items (high revenue) deserve 99%; C-items may be fine at 90%.

Scripts

| Script | Description | Usage |

|--------|-------------|-------|

| scripts/safety_stock.py | Compute safety stock and reorder point with combined demand/lead-time variability | python scripts/safety_stock.py --help |

Run python scripts/safety_stock.py --verify to execute built-in sanity tests.

References

  • For multi-echelon safety stock optimization, see references/multi-echelon.md
  • For intermittent demand methods, see references/intermittent-demand.md

Other skills for the same job

different authors, same section of the catalogue
Invoice Organizer
by frostant
×5

Automatically organizes invoices and receipts for tax preparation by reading messy files, extracting key information, renaming them consistently, and sorting them into logical folders. Turns hours of manual bookkeeping into minutes of automated organization.

3k tokens
Backtest Expert
by BaggaT236
×3

Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating quantitative trading strategies. Covers "beating ideas to death" methodology, parameter robustness testing, slippage modeling, bias prevention, and interpreting backtest results. Applicable when user asks about backtesting, strategy validation, robustness testing, avoiding overfitting, or systematic trading development.

15k tokens scripts
Analyzing Financial Statements
by anthropics
vendor ×2

This skill calculates key financial ratios and metrics from financial statement data for investment analysis

8k tokens scripts
Creating Financial Models
by anthropics
vendor ×2

This skill provides an advanced financial modeling suite with DCF analysis, sensitivity testing, Monte Carlo simulations, and scenario planning for investment decisions

8k tokens scripts
Earnings Calendar
by nicepkg
×2

This skill retrieves upcoming earnings announcements for US stocks using the Financial Modeling Prep (FMP) API. Use this when the user requests earnings calendar data, wants to know which companies are reporting earnings in the upcoming week, or needs a weekly earnings review. The skill focuses on mid-cap and above companies (over $2B market cap) that have significant market impact, organizing the data by date and timing in a clean markdown table format. Supports multiple environments (CLI, Desktop, Web) with flexible API key management.

17k tokens scripts
Agentic Wallet
by coinbase
vendor ×2

Crypto wallet operations via the awal CLI — sign in, check balances, send USDC/ETH/POL/SOL, trade tokens, fund the wallet, and use the x402 payment protocol to discover paid services, pay for API calls, monetize an API, or query onchain data. Use whenever the user mentions signing in, login, authentication, wallet status, balance, address, sending money, paying someone, transferring tokens, ENS names, swapping/trading/converting tokens, funding/topping up/onramp, USDC, ETH, POL, SOL, the x402 bazaar, paid APIs, monetizing an endpoint, or querying onchain data on Base.

14k tokens
Alpha Vantage
by christophacham
×2

Access real-time and historical stock market data, forex rates, cryptocurrency prices, commodities, economic indicators, and 50+ technical indicators via the Alpha Vantage API. Use when fetching stock prices (OHLCV), company fundamentals (income statement, balance sheet, cash flow), earnings, options data, market news/sentiment, insider transactions, GDP, CPI, treasury yields, gold/silver/oil prices, Bitcoin/crypto prices, forex exchange rates, or calculating technical indicators (SMA, EMA, MACD, RSI, Bollinger Bands). Requires a free API key from alphavantage.co.

13k tokens
Braintree Automation
by christophacham
×2

Braintree Automation: manage payment processing via Stripe-compatible tools for customers, subscriptions, payment methods, and transactions

2k tokens needs MCP

How to use it

Copy the folder

Take asgard-ai-platform/algo-sc-safety-stock from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.