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/output_io.py
View on GitHub"""Output mechanics shared by the kicad-owned CLIs.
write_primary_run: the analysis-cache write path for the primary analyzers (schematic, pcb, EMC
and SPICE CLIs); write_derived_output: the current-run overwrite path for the derived analyzers (gerber,
thermal, cross-analysis and lifecycle CLIs). Each CLI keeps its own --output / --analysis-dir precedence
and calls these only on the --analysis-dir branch. Lives beside analysis_cache (which depends on
diff_engine), so it is not part of the stdlib-only kicad_core package.
"""
from __future__ import annotations
import os
import sys
import tempfile
from pathlib import Path
from analysis_cache import (ensure_gitignore, MANIFEST_FILENAME, CANONICAL_OUTPUTS, _empty_manifest,
create_run, get_current_run, hash_source_file, manifest_lock, overwrite_current,
prune_runs, outputs_landed, resolve_analysis_dir, save_manifest,
should_create_new_run)
def write_primary_run(analysis_dir_arg: str, output_text: str, *, analyzer: str, source_path: str,
script_name: str, track_in_git: bool = False, extra_source_paths: tuple[str, ...] = (),
script_entry: str | None = None, diff_threshold: str = 'major', retention: int = 0,
record_project: bool = True) -> None:
"""Write one analyzer's canonical JSON into the analysis cache (new run or current overwrite).
extra_source_paths hash into source_hashes after source_path; unreadable sources are skipped.
script_entry overrides the manifest scripts[analyzer] string. record_project=False leaves a new
manifest's project empty (the EMC and SPICE CLIs consume analyzer JSON, not a KiCad project).
retention > 0 prunes the oldest unpinned runs after a new run is created; 0 keeps every run.
"""
project_dir = str(Path(source_path).parent)
analysis_dir = resolve_analysis_dir(analysis_dir_arg)
# Find .kicad_pro for manifest
pro_file = ""
if record_project:
try:
for f in os.listdir(project_dir):
if f.endswith(".kicad_pro"):
pro_file = f
break
except OSError:
pass
source_hashes = {}
for path in (source_path, *extra_source_paths):
h = hash_source_file(os.path.abspath(path))
if h:
source_hashes[os.path.basename(path)] = h
with tempfile.TemporaryDirectory() as tmp_dir:
out_file = os.path.join(tmp_dir, CANONICAL_OUTPUTS.get(analyzer, f"{analyzer}.json"))
Path(out_file).write_text(output_text, encoding='utf-8', newline="\n")
# One lock from the first-run manifest through the decision and the write, so analyzers
# run in parallel into one analysis dir extend one run instead of overwriting each other.
with manifest_lock(analysis_dir):
manifest_path = os.path.join(analysis_dir, MANIFEST_FILENAME)
if not os.path.isfile(manifest_path):
manifest = _empty_manifest()
manifest['project'] = pro_file
save_manifest(analysis_dir, manifest)
# Respect track_in_git config — skip .gitignore if user wants git tracking
if not track_in_git:
ensure_gitignore(analysis_dir)
if should_create_new_run(analysis_dir, tmp_dir, diff_threshold):
if script_entry is None:
script_entry = f"{script_name} {os.path.basename(source_path)}"
run_id = create_run(
analysis_dir=analysis_dir,
outputs_dir=tmp_dir,
source_hashes=source_hashes,
scripts={analyzer: script_entry},
)
if retention > 0:
prune_runs(analysis_dir, retention)
if outputs_landed(os.path.join(analysis_dir, run_id), tmp_dir):
print(f"Analysis cached: {os.path.join(analysis_dir, run_id, os.path.basename(out_file))}", file=sys.stderr)
else:
if overwrite_current(analysis_dir, tmp_dir, source_hashes=source_hashes):
print(f"Analysis cache updated (current run)", file=sys.stderr)
def write_derived_output(analysis_dir_arg: str, output_text: str, *, analyzer: str) -> str | None:
"""Overwrite one derived analyzer's canonical JSON in the CURRENT run; return the path written,
or None when the copy was refused (overwrite_current has already warned).
Derived analyzers (gerber, thermal, cross_analysis, lifecycle) carry no source hashes. When nothing is
tracked yet, analysis_cache.overwrite_current creates a run (it calls create_run) and the
run-folder path is returned; the trailing analysis-dir-root return is a defensive fallback only.
"""
analysis_dir = resolve_analysis_dir(analysis_dir_arg)
filename = CANONICAL_OUTPUTS.get(analyzer, f"{analyzer}.json")
with tempfile.TemporaryDirectory() as tmp_dir:
Path(os.path.join(tmp_dir, filename)).write_text(output_text, encoding='utf-8', newline="\n")
with manifest_lock(analysis_dir):
if not overwrite_current(analysis_dir, tmp_dir, source_hashes=None):
return None
current = get_current_run(analysis_dir)
if current:
return os.path.join(current[0], filename)
return os.path.join(analysis_dir, filename)
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 |