Skip to content

hashgraph-online/awesome-codex-plugins / plugins/aklofas/kicad-happy/skills/datasheets

datasheets

Verified

Extract structured specifications from electronic component datasheet PDFs — pinouts, electrical characteristics, peripherals, topology, and features. Cache extractions per project for consumption by schematic and PCB analyzers. Primary consumer infrastructure for `kicad`, `emc`, `spice`, and `thermal` analyzers. Use this skill whenever the user asks to extract, verify, or read specs from a component datasheet; when analyzers need verified IC knowledge (EN pin thresholds, PG presence, USB peripheral speed); or when a review mentions datasheet coverage, extraction quality, or per-MPN specifications. Also triggers on "extract this datasheet", "what are the specs for MPN X", "verify datasheet extraction", or "check pin functions for part Y".

FileKindSize
SKILL.mdskill md11.2 KB
datasheet_types/__init__.pyscript1.9 KB
datasheet_types/base_block.pyscript6.5 KB
datasheet_types/cache_reader.pyscript12.3 KB
datasheet_types/codec.pyscript6.3 KB
datasheet_types/extraction.pyscript8.0 KB
datasheet_types/pinout.pyscript5.2 KB
datasheet_types/regulator.pyscript5.3 KB
datasheet_types/spec_value.pyscript2.4 KB
datasheet_types/trust_gating.pyscript5.0 KB
distributor_core/__init__.pyscript0 B
distributor_core/cli.pyscript2.9 KB
distributor_core/download.pyscript36.7 KB
distributor_core/inputs.pyscript9.0 KB
distributor_core/manifest.pyscript5.7 KB
distributor_core/sync.pyscript21.0 KB
distributor_core/verify.pyscript12.1 KB
examples/abm8g-106-12.000mhz-t.jsonconfig9.4 KB
examples/irlml6344.jsonconfig16.0 KB
examples/lm2596-adj.jsonconfig14.3 KB
examples/lm358.jsonconfig15.6 KB
examples/mbrs540t3g.jsonconfig12.3 KB
examples/stm32f103c8t6.jsonconfig51.1 KB
prompts/base.mdmarkdown4.5 KB
prompts/crystal.mdmarkdown8.8 KB
prompts/diode.mdmarkdown8.3 KB
prompts/mcu.mdmarkdown9.6 KB
prompts/opamp.mdmarkdown10.7 KB
prompts/pinout.mdmarkdown4.7 KB
prompts/regulator.mdmarkdown4.4 KB
prompts/scout.mdmarkdown3.5 KB
prompts/transistor.mdmarkdown12.5 KB
references/cache-layout.mdmarkdown8.4 KB
references/consumer-api.mdmarkdown10.8 KB
references/dispatch-claude-code.mdmarkdown9.4 KB
references/dispatcher-contract.mdmarkdown8.2 KB
references/extraction-pipeline.mdmarkdown1.7 KB
references/extraction-schema.mdmarkdown18.0 KB
references/field-extraction-guide.mdmarkdown14.9 KB
references/quality-scoring.mdmarkdown8.4 KB
schemas/CHANGELOG.mdmarkdown16.0 KB
schemas/base.schema.jsonconfig9.3 KB
schemas/crystal.schema.jsonconfig7.2 KB
schemas/diode.schema.jsonconfig7.9 KB
schemas/extraction.schema.jsonconfig3.7 KB
schemas/fixtures/lm2596-adj.example.jsonconfig14.3 KB
schemas/fixtures/manifest.example.jsonconfig1000 B
schemas/fixtures/minimal.example.jsonconfig2.1 KB
schemas/manifest.schema.jsonconfig3.0 KB
schemas/mcu.schema.jsonconfig12.4 KB
schemas/opamp.schema.jsonconfig9.2 KB
schemas/pinout.schema.jsonconfig5.9 KB
schemas/plan.schema.jsonconfig4.6 KB
schemas/regulator.schema.jsonconfig8.4 KB
schemas/scout.schema.jsonconfig2.9 KB
schemas/spec_value.schema.jsonconfig3.0 KB
schemas/transistor.schema.jsonconfig12.0 KB
scripts/_smoke_v14_roundtrip.pyscript8.9 KB
scripts/datasheet_extract_cache.pyscript21.2 KB
scripts/datasheet_features.pyscript17.1 KB
scripts/datasheet_page_selector.pyscript16.7 KB
scripts/datasheet_score.pyscript15.5 KB
scripts/datasheet_verify.pyscript45.6 KB
scripts/extraction_schema.pyscript1.8 KB
scripts/merge_results.pyscript13.0 KB
scripts/plan_extraction.pyscript9.5 KB
scripts/validate_extraction_result.pyscript4.0 KB
scripts/validate_sanity_vector.pyscript6.4 KB

scripts/_smoke_v14_roundtrip.py

View on GitHub
#!/usr/bin/env python3
"""v1.4/v2 cache round-trip smoke test.

Builds a minimal synthetic analysis dict referencing an IC with MPN
LM2596-ADJ, plants the canonical v2-format example extraction at
<tmpdir>/datasheets/extracted/LM2596-ADJ.json, and calls
run_datasheet_verification().

Expected behavior:
- No crash.
- Returns a dict with findings[] and summary.
- ics_with_extractions=1 (LM2596-ADJ passes the v1.4 trust gate).
- Pin-voltage checks run via the v2→v1 adapter (domain-level limits).
  With VIN=12V (well within op_max=40V / abs_max=45V), no voltage
  violation findings are produced; on a 50V rail, VIN (pin 1) gets one
  abs-max error (45V).
- One extraction_not_verifiable INFO finding is emitted because
  required-external and decoupling checks have no v2 equivalent data.

Exit code 0 = pass, 1 = fail (any exception or wrong return shape).
"""

import shutil
import sys
import tempfile
from pathlib import Path

DS_SCRIPTS = Path(__file__).resolve().parent
EXAMPLE_FIXTURE = Path(__file__).resolve().parents[1] / "examples" / "lm2596-adj.json"

sys.path.insert(0, str(DS_SCRIPTS))


def build_synthetic_analysis() -> dict:
    """Minimal analysis dict referencing an IC with MPN LM2596-ADJ."""
    return {
        "file": "/tmp/fake.kicad_sch",
        "components": [
            {
                "reference": "U1",
                "type": "ic",
                "value": "LM2596-ADJ",
                "mpn": "LM2596-ADJ",
                "pin_nets": {"1": "VIN", "2": "OUT", "3": "GND", "4": "FB", "5": "ON_OFF"},
            },
            {"reference": "C1", "type": "capacitor", "value": "100nF", "parsed_value": 100e-9},
            {"reference": "C2", "type": "capacitor", "value": "10uF", "parsed_value": 10e-6},
        ],
        "nets": {
            "VIN": {"pins": [{"component": "U1"}, {"component": "C1"}, {"component": "C2"}]},
            "OUT": {"pins": [{"component": "U1"}]},
            "GND": {"pins": [{"component": "U1"}, {"component": "C1"}, {"component": "C2"}]},
            "FB": {"pins": [{"component": "U1"}]},
            "ON_OFF": {"pins": [{"component": "U1"}]},
        },
        "rail_voltages": {"VIN": 12.0, "OUT": 5.0},
    }


def main() -> int:
    if not EXAMPLE_FIXTURE.exists():
        print(f"FAIL: fixture missing: {EXAMPLE_FIXTURE}", file=sys.stderr)
        return 1

    with tempfile.TemporaryDirectory() as tmp:
        tmp_path = Path(tmp)
        cache_dir = tmp_path / "datasheets" / "extracted"
        cache_dir.mkdir(parents=True)
        shutil.copy(EXAMPLE_FIXTURE, cache_dir / "LM2596-ADJ.json")

        from datasheet_verify import run_datasheet_verification

        analysis = build_synthetic_analysis()
        try:
            result = run_datasheet_verification(analysis, project_dir=str(tmp_path))
        except AttributeError as exc:
            print(f"FAIL: AttributeError on v1.4 cache (rc.2 regression): {exc}", file=sys.stderr)
            return 1
        except Exception as exc:
            print(f"FAIL: unexpected exception: {type(exc).__name__}: {exc}", file=sys.stderr)
            return 1

        if not isinstance(result, dict):
            print(f"FAIL: result is not a dict: {type(result).__name__}", file=sys.stderr)
            return 1
        if "findings" not in result or "summary" not in result:
            print(f"FAIL: result missing required keys: {sorted(result.keys())}", file=sys.stderr)
            return 1
        if not isinstance(result["findings"], list):
            print(f"FAIL: findings is not a list: {type(result['findings']).__name__}", file=sys.stderr)
            return 1

        ics_with_ext = result["summary"].get("ics_with_extractions", 0)
        if ics_with_ext != 1:
            print(
                f"FAIL: expected ics_with_extractions=1 (LM2596-ADJ should pass v1.4 trust gate), "
                f"got {ics_with_ext}",
                file=sys.stderr,
            )
            return 1

        # The v2 adapter must emit exactly one extraction_not_verifiable
        # finding (required-external + decoupling unverifiable for v2 format),
        # and must NOT emit any voltage violation (VIN=12V is within limits).
        nv_findings = [f for f in result["findings"]
                       if f.get("type") == "extraction_not_verifiable"]
        if len(nv_findings) != 1:
            print(
                f"FAIL: expected exactly 1 extraction_not_verifiable finding "
                f"(v2 format: required-external + decoupling not verifiable), "
                f"got {len(nv_findings)}: {nv_findings}",
                file=sys.stderr,
            )
            return 1
        voltage_violations = [f for f in result["findings"]
                              if f.get("type") in ("pin_voltage_abs_max_exceeded",
                                                   "pin_voltage_operating_exceeded")]
        if voltage_violations:
            print(
                f"FAIL: unexpected voltage violation findings for 12V input "
                f"(abs_max=45V, op_max=40V): {voltage_violations}",
                file=sys.stderr,
            )
            return 1

        # The same part on a 50 V rail: pin 1 (VIN) exceeds its 45 V
        # absolute maximum, so the adapter's limits reach a finding.
        over = build_synthetic_analysis()
        over["rail_voltages"]["VIN"] = 50.0
        over_findings = run_datasheet_verification(over, project_dir=str(tmp_path))["findings"]
        abs_max = [(f.get("pin_number"), f.get("abs_max_V"), f.get("severity"))
                   for f in over_findings if f.get("type") == "pin_voltage_abs_max_exceeded"]
        if abs_max != [("1", 45, "error")]:
            print(
                f"FAIL: expected one abs-max error on pin 1 (50V > 45V), got {abs_max}",
                file=sys.stderr,
            )
            return 1

        print(
            f"PASS: v2 round-trip OK. "
            f"findings={len(result['findings'])} "
            f"(1 extraction_not_verifiable INFO, 0 voltage violations) "
            f"ics_checked={result['summary'].get('ics_checked')} "
            f"ics_with_extractions={ics_with_ext}"
        )
        return 0


def test_placement_sniff() -> int:
    """Test that verify_v14_extraction flags absolute_max entries citing
    non-stress-rating sections (the USBLC6 failure mode).
    """
    from datasheet_verify import verify_v14_extraction

    # Synthetic v1.4 extraction with the USBLC6-style misplacement:
    # entries citing "Table 2. Electrical characteristics" placed in absolute_max.
    extraction = {
        "schema_version": "1.0",
        "source": {"local_path": "fake.pdf", "sha256": "deadbeef"},
        "extraction": {"quality_score": 77},
        "base": {
            "pinout": [],
            "recommended_operating": {},
            "absolute_max": {
                # CORRECT: cites stress-rating section
                "TJ_max": [{
                    "min": None, "max": 150, "typ": None, "unit": "°C",
                    "condition": "Junction temperature",
                    "evidence": {"section": "7.1 Absolute Maximum Ratings", "page": 5},
                }],
                # WRONG: cites Table 2 (electrical chars), should be flagged
                "VBR": [{
                    "min": 6.0, "max": None, "typ": None, "unit": "V",
                    "condition": "Breakdown voltage",
                    "evidence": {"section": "Table 2. Electrical characteristics", "page": 4},
                }],
                "VF_max": [{
                    "min": None, "max": 1.1, "typ": None, "unit": "V",
                    "condition": "Forward voltage at IF=10mA",
                    "evidence": {"section": "Table 2. Electrical characteristics", "page": 4},
                }],
            },
        },
        "categories": [],
    }

    issues = verify_v14_extraction(extraction)
    placement_issues = [
        i for i in issues if "absolute_max" in i.get("path", "") and "section" in i.get("path", "")
    ]

    if len(placement_issues) != 2:
        print(
            f"FAIL: expected 2 placement-sniff issues (VBR + VF_max), "
            f"got {len(placement_issues)}: {placement_issues}",
            file=sys.stderr,
        )
        return 1

    paths = {i["path"] for i in placement_issues}
    expected = {
        "base.absolute_max.VBR[0].evidence.section",
        "base.absolute_max.VF_max[0].evidence.section",
    }
    if paths != expected:
        print(f"FAIL: unexpected paths. got {paths}, expected {expected}", file=sys.stderr)
        return 1

    print("PASS: placement-sniff flags Table 2 entries, leaves Absolute Max section alone")
    return 0


if __name__ == "__main__":
    for _stream in (sys.stdout, sys.stderr):  # UTF-8 on a cp1252 pipe (Windows)
        if hasattr(_stream, "reconfigure"):
            _kw = {"newline": "\n"}
            if (getattr(_stream, "encoding", "") or "").lower().replace("-", "") != "utf8":
                _kw.update(encoding="utf-8", errors="backslashreplace")
            _stream.reconfigure(**_kw)
    rc1 = main()
    rc2 = test_placement_sniff()
    sys.exit(rc1 | rc2)
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: 197kUpdated Claude CodeCodexVerifiedInstall