Skip to content
v0.1.3latest release121 skills4 categories6 sub-categories247 tested scripts397 reference docsContact us
scripts/charter_check.py
#!/usr/bin/env python3
"""Review a DMAIC project charter for the mistakes that sink Six Sigma projects.

Charter JSON keys: title, business_case, problem_statement, goal_statement, customer_ctq,
primary_metric {name, unit, baseline, target, direction: lower|higher}, secondary_metric,
scope {in, out}, champion, process_owner, belt, team (list), phases {define, measure, analyze, improve,
control: due dates YYYY-MM-DD}, financial_benefit

Checks:
  CH001 high    problem statement contains a cause or a solution (because, due to, lack of, implement ...)
  CH002 high    problem statement has no magnitude or time frame (numbers and when)
  CH003 high    goal statement has no target number or no date
  CH004 high    primary metric missing baseline / target, or target not better than baseline
  CH005 medium  scope in / out not both defined
  CH006 medium  no champion or no process owner
  CH007 medium  phase dates missing or out of order; longer than --max-months
  CH008 medium  business case without money or strategic link
  CH009 low     no secondary (counter-balance) metric
  CH010 low     no customer CTQ

Usage:
    python charter_check.py charter.json [--max-months 6]

Exit codes: 0 no high findings, 1 high findings, 2 read or JSON error.
"""

import argparse
import datetime as dt
import json
import re
import sys

CAUSE = re.compile(r"\b(because|due to|caused by|as a result of|lack of|insufficient|poor|not enough)\b", re.I)
SOLUTION = re.compile(r"\b(implement|install|introduce|buy|purchase|automate|we need|need to|should|by adding|new system)\b", re.I)
NUM = re.compile(r"\d")
TIME = re.compile(r"\b(19|20)\d\d\b|\b(q[1-4]|month|week|year|since|between|ytd|last \d+|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)", re.I)
PHASES = ["define", "measure", "analyze", "improve", "control"]


def check(c, max_months):
    f = []
    ps = str(c.get("problem_statement") or "")
    gs = str(c.get("goal_statement") or "")
    if not ps:
        f.append(("CH001", "high", "no problem statement"))
    else:
        m = CAUSE.search(ps) or SOLUTION.search(ps)
        if m:
            f.append(("CH001", "high", f"problem statement contains '{m.group(1)}': describe the gap, not its cause or a solution"))
        if not (NUM.search(ps) and TIME.search(ps)):
            f.append(("CH002", "high", "problem statement needs magnitude and time frame (what, how much, since when, where)"))
    if not (NUM.search(gs) and TIME.search(gs)):
        f.append(("CH003", "high", "goal statement needs a target number and a date (reduce X from A to B by DATE)"))
    pm = c.get("primary_metric") or {}
    b, t = pm.get("baseline"), pm.get("target")
    if not pm.get("name") or b is None or t is None:
        f.append(("CH004", "high", "primary metric needs name, unit, baseline and target"))
    else:
        lower = str(pm.get("direction", "lower")).lower() == "lower"
        if (lower and t >= b) or (not lower and t <= b):
            f.append(("CH004", "high", f"target {t} is not better than baseline {b} ({'lower' if lower else 'higher'} is better)"))
    sc = c.get("scope") or {}
    if not (sc.get("in") and sc.get("out")):
        f.append(("CH005", "medium", "define scope in AND out (process start/stop, products, sites)"))
    if not (c.get("champion") and c.get("process_owner")):
        f.append(("CH006", "medium", "name a champion (removes barriers) and a process owner (keeps the gains)"))
    ph = c.get("phases") or {}
    dates = []
    for p in PHASES:
        try:
            dates.append(dt.date.fromisoformat(str(ph.get(p))[:10]))
        except ValueError:
            f.append(("CH007", "medium", f"phase '{p}' has no valid due date"))
            dates = None
            break
    if dates:
        if any(b2 < a2 for a2, b2 in zip(dates, dates[1:])):
            f.append(("CH007", "medium", "phase dates are out of order"))
        start = c.get("start")
        try:
            s = dt.date.fromisoformat(str(start)[:10]) if start else dates[0] - dt.timedelta(weeks=3)
            months = (dates[-1] - s).days / 30.4
            if months > max_months:
                f.append(("CH007", "medium", f"project runs {months:.0f} months (> {max_months}): narrow the scope or split it"))
        except ValueError:
            pass
    bc = str(c.get("business_case") or "")
    if not (re.search(r"[$€£]|\b(usd|eur|gbp|k|m)\b|\d", bc, re.I) and bc) and not c.get("financial_benefit"):
        f.append(("CH008", "medium", "business case needs money (COPQ, savings) or a named strategic objective"))
    if not c.get("secondary_metric"):
        f.append(("CH009", "low", "add a counter-balance metric (e.g. cycle time or OTD must not get worse)"))
    if not c.get("customer_ctq"):
        f.append(("CH010", "low", "state the customer CTQ the project protects"))
    return f


def main():
    ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
    ap.add_argument("charter", help="charter JSON, or - for stdin")
    ap.add_argument("--max-months", type=float, default=6)
    a = ap.parse_args()
    try:
        c = json.load(sys.stdin if a.charter == "-" else open(a.charter, encoding="utf-8"))
        if not isinstance(c, dict):
            raise ValueError("charter JSON must be an object")
    except (OSError, ValueError) as e:
        print(f"error: {e}", file=sys.stderr)
        return 2
    f = check(c, a.max_months)
    print(f"Charter: {c.get('title', '(untitled)')}")
    for code, sev, msg in f:
        print(f"{code} [{sev}] {msg}")
    print(f"\n{len(f)} issue(s)" if f else "Charter is ready for the champion's sign-off.")
    return 1 if any(x[1] == "high" for x in f) else 0


if __name__ == "__main__":
    sys.exit(main())
More in Quality Management & ISO 9001

8d-problem-solving-report-writer

Write and review 8D problem-solving reports for customer complaints and serious nonconformities (automotive and aerospace practice: Ford Global 8D, VDA, GM, Stellantis formats): D0 emergency response, D1 cross-functional team and champion, D2 problem description with 5W2H and is / is-not and no cause in the statement, D3 interim containment within 24 hours with verification and clean point, D4 verified occurrence and escape (non-detection) root causes plus systemic cause, D5 permanent corrective actions for each cause verified before implementation, D6 implementation, validation with production data and removal of containment, D7 PFMEA, control plan and read-across to similar products, D8 closure and recognition. Checks an 8D discipline by discipline for missing content, human-error root causes, missing escape cause or action, late containment and dates out of order.

acceptance-sampling-plan-selector

Select and evaluate acceptance sampling plans for incoming, in-process and final inspection: ANSI/ASQ Z1.4 / ISO 2859-1 single sampling under normal inspection (code letter from lot size and inspection level I, II, III, S-1 to S-4; sample size, Ac and Re from AQL, following the table's arrows to the correct plan; 100% when n reaches the lot size; AQLs above 10 per 100 units), operating characteristic curves (Pa at any quality, producer's quality level, indifference point, LTPD, AOQ and AOQL, binomial or hypergeometric), plans designed from producer and consumer risk, and c = 0 zero-acceptance plans. Covers AQL choice by defect class, switching rules between normal, tightened and reduced inspection, when sampling is not appropriate, and random sampling.

approved-supplier-list-manager

Manage and audit an approved supplier list (ASL) / external provider register for ISO 9001 8.4.1, IATF 16949 8.4 and AS9100 8.4.1: supplier status (approved, conditional, probation, pending, disqualified), scope of approval by commodity and process, risk class, certification and expiry, re-evaluation intervals by risk, conditions with end dates, single-source contingency, approver and customer-directed sources. Audits the list for expired or expiring certificates, overdue re-evaluations, conditional or probation status past its decision date, high-risk suppliers without the required certification, single-source suppliers without backup and missing approvers, and checks purchase orders for suppliers that are off-list, disqualified or pending, or buying outside the approved scope. Covers ERP blocks, PO requirements, off-list and emergency purchases.

apqp-phase-planner

Plan and track Advanced Product Quality Planning (AIAG APQP 3rd edition, IATF 16949) for a new or changed automotive part: back-schedule the five phases (plan and define, product design, process design, product and process validation, launch and feedback) from the start-of-production date by program complexity, with overlap, PPAP lead and safe-launch period; list the deliverables and gate for each phase (DFMEA, DVP&R, feasibility, process flow, PFMEA, control plans, MSA, Ppk, run at rate, PPAP, safe launch, lessons learned); adjust for build-to-print suppliers; flag compressed timelines and late or untracked deliverables against a status list. Covers gate reviews, red/yellow/green status reporting, run at rate and safe-launch exit criteria.

as9100-gap-analyzer

Run an AS9100D / EN 9100:2018 gap analysis for aviation, space and defence suppliers on the requirements added to ISO 9001: on-time delivery and conformity focus, management representative, ethics and human-factors awareness, operational planning and operational risk management, configuration management, product safety, counterfeit-part prevention, special requirements, critical items and key characteristics, external provider register and flow-down, FOD prevention, tooling and NC program control, special process validation, first article inspection (AS9102), traceability, in-service data and nonconforming product control. Generates and scores a worksheet, grades missing core controls as major, and checks invalid n/a claims. Covers AS9101/AS9104, OASIS, AS9102 FAI forms, counterfeit standards (AS5553, AS6174, AS6081), NADCAP and the planned IA9100 transition.

audit-report-writer

Write internal, supplier and pre-certification audit reports with the content ISO 19011:2018 6.5 expects: audit objectives, scope, criteria with revisions, dates, team and auditees, method and sampling statement, specific strengths, findings table and three-part finding details (requirement, evidence, statement), conclusion on the degree of fulfilment of criteria, diverging opinions, follow-up deadlines and distribution. Builds a Markdown report from a JSON audit record, generates the conclusion from the findings (major / minor / none) and flags reports missing required content or findings without clause or evidence. Covers conclusion wording, closing meetings, response expectations and verifying corrective actions.