hashgraph-online/awesome-codex-plugins / plugins/aklofas/kicad-happy/skills/kicad
kicad
VerifiedAnalyze 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.
scripts/schema_codec.py
View on GitHub"""Dataclass -> JSON Schema Draft 2020-12 converter.
Zero external dependencies. Walks dataclass fields and emits a schema
suitable for both human reference (--schema flag) and runtime validation.
Rules:
- Every field must carry metadata={"description": "..."} — we refuse
to emit schema for undocumented fields (forces descriptions to live
next to the type declaration, not in a sidecar markdown file).
- Fields with no default value are required; fields with a default
(including default=None or default_factory) are optional.
- Optional[T] / T | None renders as {"anyOf": [<T>, {"type": "null"}]}.
- Nested dataclasses render as inline object schemas (no $defs/$ref
for v1.4; revisit if schemas grow cyclic or enormous).
- list[T] -> {"type": "array", "items": <T>}
- dict[str, T] -> {"type": "object", "additionalProperties": <T>}
- bare dict / dict[str, Any] -> {"type": "object"} (no constraints)
- bare list -> {"type": "array"} (no item constraints)
- field(metadata={"const": <value>}) adds "const": <value> to the
emitted schema fragment — useful for discriminator fields like
analyzer_type or schema_version that must carry a fixed value.
- field(metadata={"json_name": "<key>"}) renames the emitted JSON
property to <key> (an explicit wire name; the schematic envelope
maps "_redirected_from" and "_stale_file_warning" this way).
"""
from __future__ import annotations
import json
import sys
import types
import typing
from dataclasses import MISSING, fields, is_dataclass
_SCHEMA_URI = "https://json-schema.org/draft/2020-12/schema"
def dataclass_to_json_schema(cls: type) -> dict:
"""Top-level entry. Produces a complete Draft 2020-12 schema document."""
if not is_dataclass(cls):
raise TypeError(f"{cls!r} is not a dataclass")
body = _object_schema_for(cls)
body["$schema"] = _SCHEMA_URI
body["title"] = cls.__name__
return body
def _object_schema_for(cls: type) -> dict:
"""Internal: emit an object schema body for a dataclass."""
hints = typing.get_type_hints(cls)
props: dict[str, dict] = {}
required: list[str] = []
for f in fields(cls):
meta = f.metadata or {}
if "description" not in meta:
raise ValueError(
f"{cls.__name__}.{f.name}: missing description metadata. "
f"Use dataclasses.field(metadata={{'description': '...'}}) "
f"on every envelope field."
)
try:
field_schema = _type_to_schema(hints[f.name])
except TypeError as e:
raise TypeError(
f"{cls.__name__}.{f.name}: {e}"
) from e
field_schema["description"] = meta["description"]
if "const" in meta:
field_schema["const"] = meta["const"]
json_key = meta.get("json_name", f.name)
props[json_key] = field_schema
if f.default is MISSING and f.default_factory is MISSING:
required.append(json_key)
out = {"type": "object", "properties": props, "required": required}
return out
def _type_to_schema(tp) -> dict:
"""Map a Python type annotation to a JSON Schema fragment."""
origin = typing.get_origin(tp)
args = typing.get_args(tp)
# Handle Optional[T] / T | None / Union[T, None]
if origin is typing.Union or (origin is not None and origin is types.UnionType):
non_none = [a for a in args if a is not type(None)]
if len(non_none) == 1 and len(args) == 2:
inner = _type_to_schema(non_none[0])
return {"anyOf": [inner, {"type": "null"}]}
# General union — union of schemas
return {"anyOf": [_type_to_schema(a) for a in args]}
# list[T], List[T]
if origin in (list, typing.List):
if args:
return {"type": "array", "items": _type_to_schema(args[0])}
return {"type": "array"}
# dict[str, T], Dict[str, T]
if origin in (dict, typing.Dict):
if args and len(args) == 2:
# Only dict[str, X] is meaningful for JSON.
return {
"type": "object",
"additionalProperties": _type_to_schema(args[1]),
}
return {"type": "object"}
# Bare collection types
if tp in (list, typing.List):
return {"type": "array"}
if tp in (dict, typing.Dict):
return {"type": "object"}
# Primitives
if tp is int:
return {"type": "integer"}
if tp is float:
return {"type": "number"}
if tp is str:
return {"type": "string"}
if tp is bool:
return {"type": "boolean"}
if tp is type(None):
return {"type": "null"}
# typing.Any / object -> unconstrained
if tp is typing.Any or tp is object:
return {}
# Nested dataclass
if is_dataclass(tp):
return _object_schema_for(tp)
raise TypeError(f"Cannot convert {tp!r} to JSON Schema")
def emit_schema(cls: type) -> None:
"""CLI helper: print dataclass schema as JSON to stdout, exit 0."""
print(json.dumps(dataclass_to_json_schema(cls), indent=2))
sys.exit(0)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| 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: 197k | Updated | Claude CodeCodex | Verified | Install |