# Statistical Process Control

> >-

- **Type:** Skill
- **Install:** `agentstack add skill-jskherman-engg-skills-statistical-process-control`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [jskherman](https://agentstack.voostack.com/s/jskherman)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [jskherman](https://github.com/jskherman)
- **Source:** https://github.com/jskherman/engg-skills/tree/main/skills/statistical-process-control

## Install

```sh
agentstack add skill-jskherman-engg-skills-statistical-process-control
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Statistical Process Control

## Overview

Pure-Python SPC helpers:

- Individuals chart (I-MR) with control limits from the moving range.
- X-bar / R chart with constants from the standard SPC tables.
- Cp and Cpk capability indices.

The chart constants (A2, D3, D4, d2, etc.) are public-domain values widely
republished in textbooks; verify against your quality system's standard
before regulated reporting.

## Prerequisites

1. `uv` available.

## When to Use

- Computing control limits for a new chart.
- Estimating Cp / Cpk for a stable process with bilateral spec limits.
- Sanity-checking a vendor SPC report.

## Don't use for

- Autocorrelated process data (`time-series-process-data-analysis` first).
- Left-censored or interval-censored measurements
  (`censored-regression`).
- Attribute (count / defective) charts (p, np, c, u charts not
  implemented).
- Multivariate SPC (Hotelling T², MEWMA — not implemented).

## Utility Scripts

- `uv run scripts/spc.py individuals --values "12.3,12.5,12.1,12.4,12.6,12.2" --output /tmp/i.json`
- `uv run scripts/spc.py xbar-r --subgroups "12.3,12.5,12.1|12.4,12.6,12.2|12.2,12.4,12.3" --output /tmp/xr.json`
- `uv run scripts/spc.py capability --values "12.3,..." --usl 13 --lsl 11 --output /tmp/cap.json`

## Procedure

1. Confirm the process is stable (no obvious shifts, trends, autocorr).
2. Pick chart type:
   - Individuals (I-MR) for one measurement per sample.
   - X-bar / R for rational subgroups of 2-10.
3. Compute control limits from a stable baseline window (Phase I); apply
   in real time (Phase II).
4. For capability, ensure the process is centred between spec limits;
   compute Cp and Cpk.
5. Flag out-of-control signals: points beyond 3-sigma, runs of 7+ on the
   same side of the centre line, etc. (Western Electric rules).

## Pitfalls

- Computing Cp / Cpk on a process that is not in statistical control
  (Phase I diagnostics first).
- Using a one-sigma limit ("99.7% will be in tolerance") when the
  underlying distribution is not normal.
- Mixing Phase I (limit estimation) and Phase II (limit application) data.
- Treating Cpk as Cp when only one spec limit applies.
- Ignoring the moving-range constant d2 = 1.128 for n = 2.
- Computing X-bar / R with unequal subgroup sizes (the chart constants
  assume equal n).
- Applying control limits to data with strong autocorrelation; the limits
  become too tight or too wide.
- Reporting Cp / Cpk with too few data points (< ~30 ideally).

## Fallback Strategies

- If autocorrelation is suspected, use `time-series-process-data-analysis`
  to compute ACF; if significant, apply a pre-whitening filter (e.g. ARIMA
  residuals) before SPC.
- If censoring is suspected, see `censored-regression`.

## Verification

- Run the listed script with representative inputs and an `--output` file when a deterministic calculation is available.
- Confirm the JSON result contains `ok: true`, expected units, and no unhandled warnings.
- Check result magnitudes against the stated assumptions, references, and a hand calculation or known operating range before reporting them.

## References

- `references/control_charts.md` — chart constants and formulas.
- Montgomery, *Introduction to Statistical Quality Control*.

## Anti-Patterns

- Reporting "process out of control" from a single point beyond 3-sigma
  without checking measurement quality.
- Computing Cpk on visibly bimodal data.
- Using SPC limits to decide on a process change instead of as a
  monitoring tool.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [jskherman](https://github.com/jskherman)
- **Source:** [jskherman/engg-skills](https://github.com/jskherman/engg-skills)
- **License:** Apache-2.0

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-jskherman-engg-skills-statistical-process-control
- Seller: https://agentstack.voostack.com/s/jskherman
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
