Skip to content

K-Dense-AI/scientific-agent-skills / skills/iso-standards-readiness

iso-standards-readiness

Verified

Prepares and structurally reviews readiness evidence for ISO management-system and laboratory-competence standards - ISO 13485 medical device QMS, ISO 14971 device risk management, ISO/IEC 17025 testing and calibration laboratories, and ISO 15189 medical laboratories. Use when organizing declared scope, controlled documents, risk-management files, scope of accreditation, traceability, CAPA, external-provider controls, or bounded local evidence manifests, and when separating ISO certification from laboratory accreditation, FDA QMSR inspection, CLIA certification, MDSAP, and EU MDR/IVDR evidence boundaries. Not for legal applicability, compliance, certification, or accreditation decisions; contains no clause text.

FileKindSize
SKILL.mdskill md17.9 KB
assets/templates/capa-record-template.jsonconfig2.9 KB
assets/templates/document-register-template.jsonconfig2.1 KB
assets/templates/evidence-manifest-template.jsonconfig2.0 KB
assets/templates/laboratory-scope-intake-template.jsonconfig3.3 KB
assets/templates/medical-laboratory-scope-intake-template.jsonconfig3.5 KB
assets/templates/procedures/CAPA-procedure-template.mdmarkdown6.4 KB
assets/templates/procedures/document-control-procedure-template.mdmarkdown6.8 KB
assets/templates/qmsr-transition-template.jsonconfig9.4 KB
assets/templates/quality-manual-template.mdmarkdown9.2 KB
assets/templates/scope-intake-template.jsonconfig2.9 KB
assets/templates/supplier-controls-template.jsonconfig4.2 KB
assets/templates/traceability-matrix-template.jsonconfig4.3 KB
references/assurance-lanes.mdmarkdown7.1 KB
references/evidence-architecture.mdmarkdown13.3 KB
references/gap-analysis-checklist.mdmarkdown19.0 KB
references/iso-13485.mdmarkdown12.0 KB
references/iso-14971.mdmarkdown9.3 KB
references/iso-15189.mdmarkdown12.2 KB
references/iso-17025.mdmarkdown12.0 KB
references/quality-manual-guide.mdmarkdown11.3 KB
references/source-ledger.mdmarkdown20.7 KB
scripts/_catalog.pyscript7.6 KB
scripts/_common.pyscript16.4 KB
scripts/audit_document_records.pyscript5.4 KB
scripts/check_capa.pyscript8.7 KB
scripts/check_qmsr_transition.pyscript5.5 KB
scripts/check_supplier_controls.pyscript5.6 KB
scripts/check_traceability.pyscript5.5 KB
scripts/gap_analyzer.pyscript5.5 KB
scripts/validate_evidence_manifest.pyscript8.2 KB
scripts/validate_scope_intake.pyscript7.1 KB

scripts/gap_analyzer.py

View on GitHub
#!/usr/bin/env python3
"""Create a fail-closed QMS evidence gap report from a local manifest.

The analyzer uses explicit, human-authored domain labels. It does not infer
conformity from filenames or keywords and never reports a compliance percentage.
"""

from __future__ import annotations

import argparse
import re
from collections import Counter
from typing import Any

from _catalog import StandardProfile
from _common import (
    InputError,
    build_report,
    emit_report,
    guarded_main,
    load_json,
    profile_for,
    require_root_object,
    standard_parser,
)
from validate_evidence_manifest import validate as validate_manifest


def _entry_ready(entry: dict[str, Any]) -> bool:
    status = entry.get("status")
    approval = entry.get("approval")
    evidence = entry.get("evidence")
    sources = entry.get("source_refs")
    return (
        isinstance(status, str)
        and status in {"approved", "implemented", "verified", "closed"}
        and isinstance(approval, dict)
        and approval.get("status") == "approved"
        and isinstance(evidence, list)
        and bool(evidence)
        and isinstance(sources, list)
        and bool(sources)
    )


def analyze(
    data: dict[str, Any],
    *,
    base_dir: str | None,
    verify_files: bool,
    profile: StandardProfile,
) -> tuple[dict[str, Any], int]:
    review, manifest_metrics = validate_manifest(
        data,
        base_dir=base_dir,
        verify_files=verify_files,
        profile=profile,
    )
    expected_raw = data.get("expected_domains")
    expected = {
        item
        for item in expected_raw
        if isinstance(item, str) and item in profile.process_domains
    } if isinstance(expected_raw, list) else set()

    entries_raw = data.get("entries")
    entries = entries_raw if isinstance(entries_raw, list) else []
    invalid_entries = {
        int(match.group(1))
        for finding in review.findings
        if (match := re.match(r"entries\[(\d+)\](?:\.|$)", finding.path))
    }
    by_domain: dict[str, list[tuple[int, dict[str, Any]]]] = {
        domain: [] for domain in profile.process_domains
    }
    for index, item in enumerate(entries):
        if not isinstance(item, dict):
            continue
        domain = item.get("domain")
        if isinstance(domain, str) and domain in by_domain:
            by_domain[domain].append((index, item))

    domain_results: list[dict[str, Any]] = []
    statuses: Counter[str] = Counter()
    for domain in profile.process_domains:
        domain_entries = by_domain[domain]
        if domain not in expected:
            status = "not-assessed"
            explanation = (
                "Domain was not declared in expected_domains; this is not a "
                "not-applicable determination."
            )
        elif not domain_entries:
            status = "evidence-missing"
            explanation = "No manifest entry was supplied for this expected domain."
        elif all(
            index not in invalid_entries and _entry_ready(entry)
            for index, entry in domain_entries
        ):
            status = "evidence-present-for-human-review"
            explanation = (
                "Submitted entry metadata passed the requested structural checks; "
                "substantive adequacy remains for authorized human review."
            )
        else:
            status = "evidence-incomplete"
            explanation = (
                "At least one submitted entry has a structural finding, is draft, "
                "unapproved, unsourced, or missing evidence."
            )
        statuses[status] += 1
        domain_results.append(
            {
                "domain": domain,
                "entry_ids": sorted(
                    str(entry.get("id"))
                    for _, entry in domain_entries
                    if isinstance(entry.get("id"), str)
                ),
                "explanation": explanation,
                "status": status,
            }
        )

    report = build_report(
        "gap_analyzer",
        review.findings,
        metrics={
            **manifest_metrics,
            "domain_status_counts": dict(sorted(statuses.items())),
        },
        standard=profile.key,
    )
    report["domains"] = domain_results
    report["method"] = (
        "Explicit manifest coverage only; no filename/keyword scoring, clause-text "
        "reproduction, compliance percentage, or automated applicability decision."
    )
    return report, 1 if review.findings else 0


def main() -> int:
    parser = standard_parser(
        "Create a fail-closed evidence gap report from a local readiness manifest.",
        "Path to the local evidence-manifest JSON file",
        with_standard=True,
    )
    parser.add_argument(
        "--base-dir",
        help="Base directory for contained relative evidence paths",
    )
    parser.add_argument(
        "--verify-files",
        action="store_true",
        help="Verify bounded local JSON/Markdown evidence paths and optional hashes",
    )
    args: argparse.Namespace = parser.parse_args()
    if args.verify_files and not args.base_dir:
        raise InputError("--verify-files requires --base-dir")
    data = require_root_object(load_json(args.input))
    report, code = analyze(
        data,
        base_dir=args.base_dir,
        verify_files=args.verify_files,
        profile=profile_for(args),
    )
    emit_report(
        report,
        args.output,
        force=args.force,
        compact=args.compact,
    )
    return code


if __name__ == "__main__":
    guarded_main(main)
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall