Skip to content

charlieviettq/awesome-agent-skill / .claude/skills/algo-mfg-spc

"algo-mfg-spc"

Verified

"Implement Statistical Process Control charts to monitor production process stability. Use this skill when the user needs to detect process shifts, set control limits, or distinguish common cause from special cause variation — even if they say 'process monitoring', 'control chart', or 'is our process in control'.".

FileKindSize
SKILL.mdskill md4.3 KB
examples/sample_scenario.mdmarkdown5.5 KB
references/chart-constants.mdmarkdown7.7 KB
references/we-rules.mdmarkdown12.1 KB

examples/sample_scenario.md

View on GitHub
以下是完整的 `sample_scenario.md` 內容,請將它存為 `algo-mfg-spc/examples/sample_scenario.md`:

```markdown
# Example: 半導體封裝廠錫球高度製程管制

## Scenario

台中某半導體封裝廠(Packtech Co.)生產 BGA 封裝元件,品管工程師 Emily 負責監控錫球高度(Ball Height)。規格要求 300 ± 25 µm(即 275–325 µm)。

近期客戶抱怨部分批次焊接良率下降,Emily 懷疑製程有漂移。她收集了過去 6 週共 30 個抽樣子群(每群 5 個量測值,來自同一機台、同一班別),委託 Asgard 分析:「請幫我建立 X-bar/R 管制圖,判斷製程是否在管制狀態。」

原始資料(子群均值 X̄ 與全距 R,單位 µm):

| 子群 | X̄     | R  |
|------|-------|----|
| 1    | 300.2 | 8  |
| 2    | 299.8 | 6  |
| 3    | 301.1 | 9  |
| 4    | 300.5 | 7  |
| 5    | 299.6 | 10 |
| 6    | 300.9 | 8  |
| 7    | 301.3 | 11 |
| 8    | 300.1 | 6  |
| 9    | 299.4 | 9  |
| 10   | 300.7 | 8  |
| 11   | 301.0 | 7  |
| 12   | 300.3 | 6  |
| 13   | 301.5 | 9  |
| 14   | 301.8 | 10 |
| 15   | 302.2 | 8  |
| 16   | 302.6 | 11 |
| 17   | 303.1 | 9  |
| 18   | 303.8 | 10 |
| 19   | 304.2 | 12 |
| 20   | 304.9 | 11 |
| 21   | 305.1 | 10 |
| 22   | 305.5 | 13 |
| 23   | 306.0 | 11 |
| 24   | 306.4 | 12 |
| 25   | 306.9 | 10 |
| 26   | 307.2 | 14 |
| 27   | 307.8 | 12 |
| 28   | 308.1 | 13 |
| 29   | 308.6 | 11 |
| 30   | 309.0 | 12 |

---

## Analysis

### Phase 1: Input Validation

- 子群數量:30 ✓(≥25 門檻)
- 子群大小:5 ✓(標準 X-bar/R 適用範圍)
- 時間順序:依生產週序排列 ✓
- 量測系統:前次 Gauge R&R 報告顯示 %R&R = 7.3% ✓(< 10% 門檻)
- **Gate 通過**:可進行 Phase 2

---

### Phase 2: Core Algorithm

**基本統計量:**

```
grand mean (X̄̄) = (300.2 + 299.8 + ... + 309.0) / 30
               = 9,093.6 / 30
               = 303.12 µm

average range (R̄) = (8 + 6 + ... + 12) / 30
                  = 296 / 30
                  = 9.87 µm
```

**查表:n=5 的管制圖常數**

| 常數 | n=5 值 |
|------|--------|
| A₂   | 0.577  |
| D₃   | 0 (LCL_R 取 0) |
| D₄   | 2.114  |

**X-bar 管制圖界限:**

```
UCL_X̄ = X̄̄ + A₂ × R̄ = 303.12 + 0.577 × 9.87 = 303.12 + 5.70 = 308.82 µm
CL_X̄  = 303.12 µm
LCL_X̄ = X̄̄ - A₂ × R̄ = 303.12 - 5.70 = 297.42 µm
```

**R 管制圖界限:**

```
UCL_R = D₄ × R̄ = 2.114 × 9.87 = 20.86 µm
CL_R  = 9.87 µm
LCL_R = D₃ × R̄ = 0 (n=5 時 D₃=0)
```

---

### Phase 3: Verification — Western Electric 判讀

**X-bar 圖逐點檢核:**

| 規則 | 觸發點 | 說明 |
|------|--------|------|
| 點超出管制界限 (±3σ) | 子群 29 (308.6)、子群 30 (309.0) | 超出 UCL_X̄ = 308.82 |
| 連續 7 點遞增趨勢 | 子群 14–22(X̄ 從 301.8 持續上升至 306.0) | 8 點單調遞增,觸發趨勢規則 |
| 連續 7 點同側 | 子群 16–30(所有點均在中心線上方) | 15 點連續偏高,觸發偏移規則 |

**R 圖:**

- 所有全距均在 [6, 14] µm,遠低於 UCL_R = 20.86 µm
- R 圖在管制內,表示組內變異穩定 → 問題是系統性均值漂移,非隨機散佈增加

**IRON LAW 確認:**

雖然子群 1–20 的均值仍在規格內(275–325 µm),但製程在第 14 子群起已進入失控狀態。管制界限(±3σ from process mean)≠ 規格界限。必須先處理失控問題,再評估製程能力。

---

## Result

```json
{
  "chart": {
    "type": "xbar_r",
    "center_line": 303.12,
    "ucl": 308.82,
    "lcl": 297.42,
    "r_bar": 9.87,
    "ucl_r": 20.86,
    "lcl_r": 0.0
  },
  "signals": [
    {
      "subgroup": 14,
      "rule": "trend_7_consecutive_increasing",
      "value": 301.8,
      "note": "子群 14 起連續 8 點遞增,至子群 22 (306.0)"
    },
    {
      "subgroup": 16,
      "rule": "run_7_same_side",
      "value": 302.6,
      "note": "子群 16 起連續 15 點均在中心線以上"
    },
    {
      "subgroup": 29,
      "rule": "point_beyond_ucl",
      "value": 308.6
    },
    {
      "subgroup": 30,
      "rule": "point_beyond_ucl",
      "value": 309.0
    }
  ],
  "stability": "out_of_control",
  "metadata": {
    "subgroups": 30,
    "subgroup_size": 5,
    "estimated_shift_start": 14,
    "direction": "upward"
  }
}
```

**工程師行動建議:**

1. **立即停機確認**(子群 29–30 已超出 UCL):檢查錫膏印刷機的刮刀壓力或錫膏厚度設定是否自第 7 週起異常
2. **追溯子群 14 前後的製程紀錄**:換班交接、模具清洗、錫膏批號更換是最常見的漸變起因
3. **R 圖穩定是好訊息**:組內變異未擴大,代表量測系統正常,且漂移原因很可能是單一系統性因素(非隨機)
4. **修正後重新建立基準**:排除異常批次後,以新的穩定子群重新計算管制界限,勿沿用本次含漂移資料的界限
```

---

幾個設計決策說明:

- **資料設計**:子群 1–13 刻意設計為穩定期(均值在 299–302 µm),子群 14 起呈持續上漂,子群 29–30 突破 UCL——同時觸發三條 Western Electric 規則,展示多訊號共存的真實情況
- **R 圖故意穩定**:強調「均值漂移 ≠ 散佈增加」,這是 X-bar/R 圖最常見的誤解
- **IRON LAW 段落**:明確說明製程在子群 14 就已失控,但那時仍在規格內,呼應「管制界限 ≠ 規格界限」的核心鐵律
- **行動建議**:從 R 圖穩定這個線索推導出「單一系統性原因」,示範如何用 SPC 結果縮小調查範圍
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexUnverifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall