Skip to content

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

Analyze KiCad projects and PDF schematics: schematics, PCB layouts, Gerbers, footprints, symbols, netlists, and design rules. Reviews designs for bugs, traces nets, cross-references schematic to PCB, extracts BOM data, checks DRC/ERC, DFM, power trees, and regulator circuits. Every finding carries a confidence label and evidence source with trust_summary rollup. Analyzes PDF schematics from dev boards, reference designs, eval kits, and datasheets. Supports KiCad 5–10. Use whenever the user mentions .kicad_sch, .kicad_pcb, .kicad_pro, PCB design review, schematic analysis, PDF schematics, reference designs, Gerber files, DRC/ERC, netlist issues, BOM extraction, signal tracing, power budget, DFM, or wants to understand, debug, compare, or review any hardware design. Also for "check my board", "review before fab", "what's wrong with my schematic", "is this ready to order", "check my power supply", "verify this circuit", OSHWA certification readiness, or any electronics/PCB design question.

FileKindSize
SKILL.mdskill md79.1 KB
references/config-reference.mdmarkdown19.1 KB
references/datasheet-verification.mdmarkdown16.5 KB
references/deep-review.mdmarkdown9.7 KB
references/design-intent.mdmarkdown5.6 KB
references/diff-analysis.mdmarkdown17.6 KB
references/file-formats.mdmarkdown15.1 KB
references/gerber-parsing.mdmarkdown33.5 KB
references/manual-gerber-parsing.mdmarkdown24.5 KB
references/manual-pcb-parsing.mdmarkdown17.2 KB
references/manual-schematic-parsing.mdmarkdown12.8 KB
references/net-tracing.mdmarkdown12.0 KB
references/oshwa-certification.mdmarkdown4.5 KB
references/output-schema.mdmarkdown33.4 KB
references/pcb-layout-analysis.mdmarkdown27.3 KB
references/pdf-schematic-extraction.mdmarkdown15.2 KB
references/report-generation.mdmarkdown56.3 KB
references/schematic-analysis.mdmarkdown63.9 KB
references/standards-compliance.mdmarkdown33.5 KB
references/supplementary-data-sources.mdmarkdown12.5 KB
references/what-if.mdmarkdown19.5 KB
review/README.mdmarkdown4.1 KB
review/fixtures/deep_review.example.jsonconfig1.2 KB
review/fixtures/design_context.example.jsonconfig388 B
review/fixtures/review_annotations.example.jsonconfig707 B
review/prompts/design_context.mdmarkdown4.9 KB
review/schemas/deep_review.schema.jsonconfig3.3 KB
review/schemas/design_context.schema.jsonconfig2.2 KB
review/schemas/review_annotations.schema.jsonconfig1.9 KB
review/scripts/_mini_jsonschema.pyscript6.6 KB
review/scripts/build_review_plan.pyscript2.3 KB
review/scripts/deep_review_gate.pyscript27.3 KB
review/scripts/merge_annotations.pyscript7.0 KB
review/scripts/validate_review.pyscript2.6 KB
scripts/.gitignoreother13 B
scripts/README.mdmarkdown23.4 KB
scripts/analysis_cache.pyscript42.1 KB
scripts/analyze_gerbers.pyscript90.9 KB
scripts/analyze_pcb.pyscript7.4 KB
scripts/analyze_schematic.pyscript6.7 KB
scripts/analyze_thermal.pyscript48.5 KB
scripts/analyzer_envelope.pyscript15.5 KB
scripts/capability_mode.pyscript10.2 KB
scripts/check_report_sections.pyscript10.6 KB
scripts/cross_analysis.pyscript69.4 KB
scripts/cross_verify.pyscript23.1 KB
scripts/design_intent.pyscript13.5 KB
scripts/detection_schema.pyscript26.0 KB
scripts/detector_helpers.pyscript15.2 KB
scripts/diff_analysis.pyscript23.5 KB
scripts/diff_engine.pyscript47.2 KB
scripts/domain_detectors.pyscript260.5 KB
scripts/envelopes/__init__.pyscript0 B
scripts/envelopes/cross_analysis.pyscript5.9 KB
scripts/envelopes/gerber.pyscript16.1 KB
scripts/envelopes/pcb.pyscript25.9 KB
scripts/envelopes/schematic.pyscript23.1 KB
scripts/envelopes/thermal.pyscript7.4 KB
scripts/export_issues.pyscript27.6 KB
scripts/fab_release_gate.pyscript29.8 KB
scripts/finding_schema.pyscript25.7 KB
scripts/gen_output_schema_md.pyscript9.2 KB
scripts/inputs_builder.pyscript4.0 KB
scripts/kicad_core/__init__.pyscript0 B
scripts/kicad_core/classify.pyscript32.5 KB
scripts/kicad_core/cli.pyscript4.2 KB
scripts/kicad_core/coords.pyscript2.0 KB
scripts/kicad_core/diagnostics.pyscript1.9 KB
scripts/kicad_core/executables.pyscript1.0 KB
scripts/kicad_core/fields.pyscript5.9 KB
scripts/kicad_core/fileio.pyscript5.4 KB
scripts/kicad_core/hotloop.pyscript3.1 KB
scripts/kicad_core/instances.pyscript5.7 KB
scripts/kicad_core/model.pyscript4.8 KB
scripts/kicad_core/netnames.pyscript19.1 KB
scripts/kicad_core/netquery.pyscript6.7 KB
scripts/kicad_core/pairing.pyscript1.9 KB
scripts/kicad_core/parts.pyscript28.9 KB
scripts/kicad_core/passives.pyscript10.0 KB
scripts/kicad_core/pdn.pyscript1011 B
scripts/kicad_core/project.pyscript43.2 KB
scripts/kicad_core/render.pyscript2.7 KB
scripts/kicad_core/sexp.pyscript12.6 KB
scripts/kicad_core/textvars.pyscript5.4 KB
scripts/kicad_core/token_cache.pyscript2.2 KB
scripts/kicad_core/values.pyscript14.1 KB
scripts/kicad_types.pyscript15.1 KB
scripts/lifecycle_audit.pyscript6.7 KB
scripts/lifecycle_engine.pyscript52.8 KB
scripts/lookup_detectors.pyscript29.9 KB
scripts/lookup_helpers.pyscript3.0 KB
scripts/methodology_gerbers.mdmarkdown23.1 KB
scripts/methodology_pcb.mdmarkdown22.2 KB
scripts/methodology_schematic.mdmarkdown43.1 KB
scripts/netlist_queries.pyscript4.2 KB
scripts/output_filters.pyscript16.8 KB
scripts/output_io.pyscript5.3 KB
scripts/pcb/__init__.pyscript0 B
scripts/pcb/assembly.pyscript58.3 KB
scripts/pcb/connectivity.pyscript27.7 KB
scripts/pcb/copper.pyscript61.0 KB
scripts/pcb/dfm.pyscript56.9 KB
scripts/pcb/geometry.pyscript59.5 KB
scripts/pcb/pipeline.pyscript30.3 KB
scripts/pcb/presentation.pyscript24.3 KB
scripts/pcb/reader.pyscript87.1 KB
scripts/pcb/routing.pyscript53.5 KB
scripts/project_config.pyscript23.1 KB
scripts/risk_summary.pyscript3.1 KB
scripts/run_id.pyscript1.7 KB
scripts/schema_codec.pyscript5.0 KB
scripts/schematic/__init__.pyscript0 B
scripts/schematic/audits.pyscript56.0 KB
scripts/schematic/bom_stats.pyscript6.1 KB
scripts/schematic/connectivity.pyscript62.9 KB
scripts/schematic/erc_pins.pyscript8.4 KB
scripts/schematic/hierarchy.pyscript21.5 KB
scripts/schematic/ic_analysis.pyscript21.4 KB
scripts/schematic/legacy_reader.pyscript49.4 KB
scripts/schematic/net_analysis.pyscript75.5 KB
scripts/schematic/pipeline.pyscript72.2 KB
scripts/schematic/presentation.pyscript20.9 KB
scripts/schematic/reader.pyscript64.7 KB
scripts/schematic/system_analyses.pyscript126.9 KB
scripts/signal_detectors.pyscript248.0 KB
scripts/summarize_findings.pyexecutablescript17.4 KB
scripts/validation_detectors.pyscript75.3 KB
scripts/what_if.pyscript68.4 KB

review/scripts/merge_annotations.py

View on GitHub
"""Layer 2 annotation merge tool.

There are no authority caps (trust comes from the Deep Review evidence
gate, not permission rules). HI-3 holds: stripping llm_* from a merged
envelope recovers the raw analyzer JSON.

Validates review_annotations.json against schema, applies the overlay
(suppressed annotations always apply), writes
analysis/merged/<analyzer>.json overlay artifacts, and verifies the HI-3
strip-LLM round-trip (equality of the decoded JSON; the merged file is
re-serialized, so its bytes can differ from the raw file's).

Failure semantics: orphan annotations are LOGGED in the merge report and
SKIPPED. The merge itself never fails on these — analyzer outputs always
advance. Schema validation errors are hard-fail (caller's responsibility).

Schema validation uses the stdlib-only mini-validator at
`_mini_jsonschema.py` (kept narrow to the keyword subset Layer 2 needs).
No third-party `jsonschema` dependency.
"""
from __future__ import annotations

import argparse
import json
import sys
from datetime import datetime, timezone
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "scripts"))   # skills/kicad/scripts

from finding_schema import strip_llm_overlays  # noqa: E402
from kicad_core.fileio import json_loads  # noqa: E402

SCHEMA_PATH = Path(__file__).resolve().parents[1] / "schemas" / "review_annotations.schema.json"

ANALYZER_FILES = ["schematic.json", "pcb.json", "emc.json", "thermal.json",
                   "gerber.json", "cross_analysis.json"]


def _now_iso():
    return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")


def _load_raw_envelopes(raw_dir: Path) -> dict:
    """Load every analyzer JSON in raw_dir into a dict keyed by stem."""
    envelopes = {}
    for fname in ANALYZER_FILES:
        path = raw_dir / fname
        if path.exists():
            envelopes[path.stem] = json_loads(path.read_text(encoding="utf-8"))
    return envelopes


def _validate_review_schema(review: dict) -> None:
    """Hard-fail if review_annotations doesn't match schema (HI-2 protection).

    Uses the stdlib-only mini-validator at `_mini_jsonschema.py` so Layer 2
    works without the optional `jsonschema` package. If the Layer 2 schema
    grows beyond the mini-validator's supported keyword set, the validator
    raises a "unsupported schema keyword" ValidationError — switch this
    consumer back to the real jsonschema package at that point rather than
    silently extending the mini-validator.
    """
    from _mini_jsonschema import validate
    schema = json.loads(SCHEMA_PATH.read_text(encoding="utf-8"))
    validate(review, schema)


def _find_finding(envelopes: dict, finding_id: str):
    """Find a finding by id across all loaded envelopes; return first match or None.

    Assumes finding_ids are globally unique across analyzer envelopes per the
    finding_id convention `<source>:<rule_id>:<locator>` (the source
    prefix differs per analyzer). Iteration order is deterministic via
    ANALYZER_FILES.
    """
    for env in envelopes.values():
        for f in env.get("findings", []):
            if f.get("finding_id") == finding_id:
                return f
    return None


def merge(raw_dir, review_path, merged_dir) -> dict:
    """Apply Layer 2 review annotations to raw analyzer outputs.

    Returns a merge report dict (also written to merged_dir/_merge_report.json).
    Never raises on per-annotation failure: orphans and invariant violations
    are logged and skipped. Hard-fails only on schema-invalid review JSON or
    HI-3 round-trip byte mismatch.
    """
    raw_dir = Path(raw_dir)
    review_path = Path(review_path)
    merged_dir = Path(merged_dir)

    envelopes = _load_raw_envelopes(raw_dir)
    review = json_loads(review_path.read_text(encoding="utf-8"))
    _validate_review_schema(review)  # hard-fail if malformed

    invariant_violations = []
    suppressed_count = 0
    applied = 0

    for ann in review.get("annotations", []):
        finding = _find_finding(envelopes, ann["finding_id"])
        if finding is None:
            invariant_violations.append({
                "type": "orphan_annotation",
                "finding_id": ann["finding_id"],
            })
            continue
        if ann["status"] == "suppressed":
            suppressed_count += 1
        finding["llm_review"] = {
            "status": ann["status"],
            "reason": ann["reason"],
            "confidence": ann["confidence"],
            "reviewed_at": ann["reviewed_at"],
        }
        if ann.get("suggested_severity"):
            finding["llm_review"]["suggested_severity"] = ann["suggested_severity"]
        applied += 1

    # Write merged outputs
    merged_dir.mkdir(parents=True, exist_ok=True)
    for stem, env in envelopes.items():
        (merged_dir / f"{stem}.json").write_text(
            json.dumps(env, indent=2, sort_keys=True) + "\n", encoding="utf-8", newline="\n")

    # HI-3 round-trip verification (per-analyzer)
    for stem in envelopes:
        merged_data = json.loads((merged_dir / f"{stem}.json").read_text(encoding="utf-8"))
        original_raw = json.loads((raw_dir / f"{stem}.json").read_text(encoding="utf-8"))
        stripped = strip_llm_overlays(merged_data)
        if stripped != original_raw:
            raise RuntimeError(
                f"HI-3 violation: strip_llm_overlays(merged/{stem}.json) != raw/{stem}.json"
            )

    report = {
        "merged_at": _now_iso(),
        "produced_for_run_id": review.get("produced_for_run_id"),
        "annotation_count": len(review.get("annotations", [])),
        "applied_count": applied,
        "suppressed_count": suppressed_count,
        "orphan_annotations": [v for v in invariant_violations
                                if v["type"] == "orphan_annotation"],
        "invariant_violations": [v for v in invariant_violations
                                  if v["type"] != "orphan_annotation"],
        "reviewer_observations_count": len(review.get("reviewer_observations", [])),
    }
    (merged_dir / "_merge_report.json").write_text(
        json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8", newline="\n")
    return report


def main():
    p = argparse.ArgumentParser(description="Apply Layer 2 review annotations to raw analyzer outputs.")
    p.add_argument("--raw-dir", required=True, type=Path)
    p.add_argument("--review", required=True, type=Path,
                    help="Path to review_annotations.json")
    p.add_argument("--merged-dir", required=True, type=Path)
    args = p.parse_args()
    report = merge(args.raw_dir, args.review, args.merged_dir)
    print(json.dumps(report, indent=2, sort_keys=True))
    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)
    sys.exit(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: 197kUpdated Claude CodeCodexVerifiedInstall