> ## Documentation Index
> Fetch the complete documentation index at: https://developer.watson-orchestrate.ibm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Inventory check skill

The `inventory-check` skill retrieves stock data for a product, computes its health status, and provides reorder recommendations when needed. It covers the skill definition, two scripts for stock analysis and reorder calculation, and the inventory guide reference the agent consults for threshold definitions and escalation rules.

Allowed tools: `check_inventory`

For the tool source code, see [Tools](/agent_skills/multi/tools). For the agent YAML that loads this skill, see [Operations assistant](/agent_skills/multi/agent). To see this skill execute a request end-to-end, see the [Sample query walkthrough](/agent_skills/multi/sample_query).

***

## Skill definition `SKILL.md`

```yaml YAML theme={null}
---
name: inventory-check
description: Check inventory levels and stock health for a product. Use when a user asks whether a product is in stock, needs reordering, or wants days-of-supply metrics.
allowed-tools: check_inventory
---

# Inventory Check

You are an inventory analyst. You help users understand stock levels and take the right action.

## Instructions

### Step 1 Retrieve Stock Data
Call `check_inventory(product_id=<id>)` to get the current stock level and average daily demand.

The tool returns:
- `current_stock` (integer): units currently in stock
- `daily_demand` (number): average daily demand

### Step 2 Compute Stock Health
Run the stock analysis script check_stock.py with the retrieved values:
args={"product_id": "<product_id>", "current_stock": <current_stock>, "daily_demand": <daily_demand>}

The script returns:
- `status` (string): one of `out_of_stock`, `critical`, `low`, `healthy`, `overstocked`
- `days_of_supply` (number): how many days of stock remain at current demand
- `reorder_needed` (boolean): true if days_of_supply < 14

### Step 3 Interpret Results
For threshold definitions, escalation rules, and seasonal adjustment guidelines, read: INVENTORY_GUIDE.md

Quick status guide:
- `out_of_stock` — zero units; emergency action needed
- `critical` — < 3 days of supply; urgent reorder
- `low` — 3–14 days of supply; reorder soon
- `healthy` — 14–60 days of supply; no action needed
- `overstocked` — > 60 days of supply; review purchasing plan

### Step 4 Recommend Actions
- Always report the `days_of_supply` value and the `status` to the user.
- If `reorder_needed` is true, present the `reorder_qty` and `reorder_point` from the calc_reorder script
  (run via the Inventory Guide instructions in Step 3) as the recommended order size.
- For escalation contacts and who to notify, refer to the Inventory Guide you already read in Step 3.
```

***

## Script `scripts/check_stock.py`

Computes the stock health status and days-of-supply metric from raw inventory data.

```python theme={null}
def run(product_id: str, current_stock: int, daily_demand: float = 10.0) -> dict:
    if daily_demand <= 0:
        daily_demand = 10.0

    days_of_supply = current_stock / daily_demand if daily_demand > 0 else float("inf")

    if current_stock == 0:
        status = "out_of_stock"
    elif days_of_supply < 3:
        status = "critical"
    elif days_of_supply < 14:
        status = "low"
    elif days_of_supply < 60:
        status = "healthy"
    else:
        status = "overstocked"

    return {
        "product_id":    product_id,
        "current_stock": current_stock,
        "days_of_supply": round(days_of_supply, 1),
        "status":        status,
        "reorder_needed": days_of_supply < 14,
    }
```

**Return values**

| Field            | Type    | Description                                                        |
| ---------------- | ------- | ------------------------------------------------------------------ |
| `days_of_supply` | Number  | Days of inventory that remains at current demand                   |
| `status`         | string  | One of `out_of_stock`, `critical`, `low`, `healthy`, `overstocked` |
| `reorder_needed` | Boolean | `true` when `days_of_supply` is below 14                           |

***

## Script `scripts/calc_reorder.py`

Computes the reorder point, suggested order quantity, and safety stock. Run this script when `reorder_needed` is `true`.

```python theme={null}
def run(product_id: str, daily_demand: float, lead_time_days: int = 7, safety_days: int = 3) -> dict:
    safety_stock  = daily_demand * safety_days
    reorder_point = (daily_demand * lead_time_days) + safety_stock
    reorder_qty   = reorder_point * 2

    return {
        "product_id":      product_id,
        "reorder_point":   round(reorder_point),
        "reorder_qty":     round(reorder_qty),
        "safety_stock":    round(safety_stock),
        "lead_time_days":  lead_time_days,
    }
```

**Return values**

| Field           | Type    | Description                                 |
| --------------- | ------- | ------------------------------------------- |
| `reorder_point` | Integer | Minimum stock level that triggers a reorder |
| `reorder_qty`   | Integer | Suggested quantity to order                 |
| `safety_stock`  | Integer | Buffer stock to cover demand variability    |

***

## Reference `references/INVENTORY_GUIDE.md`

```markdown theme={null}
# Inventory Guide

## Stock Status Thresholds

| Status       | Days of Supply | Meaning |
|--------------|---------------|---------|
| out_of_stock | 0 days         | No inventory; sales halted |
| critical     | < 3 days       | Near-zero; risk of stockout within hours |
| low          | 3–14 days      | Insufficient buffer; reorder urgently |
| healthy      | 14–60 days     | Adequate buffer for normal demand |
| overstocked  | > 60 days      | Excess inventory; review purchasing plan |

## Reorder Quantity Calculation

When `reorder_needed` is true, compute the exact reorder point and suggested order quantity by running the calc_reorder script with:
args={"product_id": "<product_id>", "daily_demand": <daily_demand>, "lead_time_days": 7, "safety_days": 3}

The script returns:
- `reorder_point` (integer): minimum stock level that triggers a reorder
- `reorder_qty` (integer): suggested quantity to order
- `safety_stock` (integer): buffer stock to cover demand variability

Present the `reorder_qty` to the user as the recommended order size.

## Escalation Rules

| Status              | Action |
|---------------------|--------|
| out_of_stock        | Notify procurement manager immediately; explore emergency sourcing |
| critical            | Alert supply chain team; request expedited shipment |
| low                 | Submit standard reorder; flag for daily monitoring |
| overstocked > 90 days | Request review from merchandising team; consider promotions |

## Seasonal Adjustments

During peak seasons (Q4 holiday, back-to-school), adjust thresholds:
- Treat `low` as `critical` (demand spikes reduce effective days-of-supply)
- Add 20% to the safety stock calculation
```

***

## Next steps

* See [Order placement skill](/agent_skills/multi/order_placement) for the companion skill that handles order submission.
* See [Agent configuration](/agent_skills/multi/agent) for how both skills are attached to the agent.
