Skip to content
v0.1.3latest release121 skills4 categories6 sub-categories247 tested scripts397 reference docsContact us
scripts/manual_check.py
#!/usr/bin/env python3
"""Review a quality manual (Markdown or plain text) against ISO 9001:2015 expectations.

Checks:
  QM001 high    no scope statement (4.3) naming products/services
  QM002 high    a clause is declared not applicable without a justification, or one that cannot be excluded
  QM003 high    no quality policy, or no reference to where it is
  QM004 medium  no description of processes and their interaction (4.4)
  QM005 medium  no revision / approval block
  QM006 medium  ISO 9001:2008 leftovers: management representative, preventive action procedure, 'quality
                manual' as a mandatory document, six mandatory procedures, ISO 9001:2008
  QM007 low     parrots the standard ('the organization shall'): a manual should say what *we* do
  QM008 low     unresolved placeholders (TODO, [Company], XXX, lorem ipsum)
  QM009 low     no mention of climate change in context (ISO 9001:2015/Amd 1:2024)

Usage:
    python manual_check.py quality-manual.md
    python manual_check.py manual.txt --json

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

import argparse
import json
import re
import sys

MAY_NOT_APPLY = {"7.1.5", "8.3", "8.5.3", "8.5.5"}
LEGACY = [
    (r"management representative", "'management representative' was removed in 2015; assign the responsibilities in 5.3"),
    (r"preventive action", "preventive action is replaced by risk-based thinking (6.1); drop the separate procedure"),
    (r"six (mandatory|documented) procedures", "the six mandatory procedures no longer exist"),
    (r"ISO\s*9001\s*:\s*2008", "references ISO 9001:2008"),
    (r"quality manual (is|shall be) (required|mandatory)", "a quality manual is not mandatory since 2015"),
]
PLACEHOLDER = re.compile(r"\bTODO\b|\[company\]|\bXXX\b|lorem ipsum|<insert", re.I)
EXCL = re.compile(r"(not applicable|excluded?|exclusion|does not apply)", re.I)
CLAUSE = re.compile(r"\b(\d{1,2}(?:\.\d+){1,2})\b")


def check(text):
    low = text.lower()
    f = []
    if not re.search(r"\bscope\b", low) or not re.search(r"(product|service)", low):
        f.append(("QM001", "high", "no scope statement naming products/services and sites (4.3)"))
    for line in text.splitlines():
        if not EXCL.search(line):
            continue
        for c in CLAUSE.findall(line):
            if c.split(".")[0] not in {"4", "5", "6", "7", "8", "9", "10"}:
                continue
            if c not in MAY_NOT_APPLY and not c.startswith(("8.3.", "7.1.5.")):
                hint = " (7.3 was design in ISO 9001:2008; design is 8.3 now)" if c == "7.3" else ""
                f.append(("QM002", "high", f"clause {c} declared not applicable; it cannot be excluded{hint}: {line.strip()[:90]}"))
            elif len(EXCL.split(line, 1)[-1].split()) + len(line.split(c, 1)[-1].split()) < 8:
                f.append(("QM002", "high", f"clause {c} excluded without a convincing justification: {line.strip()[:90]}"))
    if "quality policy" not in low:
        f.append(("QM003", "high", "no quality policy and no reference to where it is (5.2)"))
    if not re.search(r"interaction|process map|turtle|sequence", low):
        f.append(("QM004", "medium", "processes and their sequence/interaction are not described (4.4)"))
    if not re.search(r"revision|rev\.|issue \d|approved by", low):
        f.append(("QM005", "medium", "no revision or approval block (7.5.2)"))
    for pat, msg in LEGACY:
        if re.search(pat, text, re.I):
            f.append(("QM006", "medium", msg))
    shall = len(re.findall(r"the organization shall", low))
    if shall >= 3:
        f.append(("QM007", "low", f"'the organization shall' appears {shall} times; describe what the company does, "
                                  "in its own words"))
    holes = len(PLACEHOLDER.findall(text))
    if holes:
        f.append(("QM008", "low", f"{holes} unresolved placeholder(s) (TODO, [Company], XXX)"))
    if "climate" not in low:
        f.append(("QM009", "low", "context section does not say whether climate change is a relevant issue (Amd 1:2024)"))
    return f


def main():
    ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
    ap.add_argument("manual", help="Markdown or text file, or - for stdin")
    ap.add_argument("--json", action="store_true")
    a = ap.parse_args()
    try:
        text = sys.stdin.read() if a.manual == "-" else open(a.manual, encoding="utf-8").read()
    except OSError as e:
        print(f"error: {e}", file=sys.stderr)
        return 2
    findings = check(text)
    if a.json:
        print(json.dumps([dict(zip(("code", "severity", "message"), x)) for x in findings], indent=2))
    else:
        for code, sev, msg in findings:
            print(f"{code} [{sev}] {msg}")
        high = sum(x[1] == "high" for x in findings)
        print(f"\n{len(findings)} finding(s), {high} high" if findings else "No findings: manual covers the expected content.")
    return 1 if any(x[1] == "high" for x in findings) 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.