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

references/manual-schematic-parsing.md

View on GitHub
# Manual Schematic Parsing (Script Fallback)

When `analyze_schematic.py` fails (unsupported format, newer KiCad version, corrupted file), fall back to direct file parsing. This is more expensive (reading raw S-expressions) but always works as long as the file is valid KiCad.

## Table of Contents

1. [When to Use Manual Parsing](#when-to-use-manual-parsing)
2. [File Format Quick Reference](#file-format-quick-reference)
3. [Component Extraction](#component-extraction)
4. [Net Building](#net-building)
5. [Signal Analysis Patterns](#signal-analysis-patterns)
6. [Legacy .sch Format](#legacy-sch-format)
7. [Validation Methodology](#validation-methodology)

---

## When to Use Manual Parsing

Use manual parsing when:
- `analyze_schematic.py` crashes or returns 0 components on a file you know has content
- The schematic is from a KiCad version newer than the script supports
- You need to validate script output against raw file data
- The file is partially corrupt but still readable

Always try the script first — it handles coordinate transforms, multi-unit symbols, hierarchical sheets, and net building automatically.

---

## File Format Quick Reference

### Modern `.kicad_sch` (KiCad 6+)

S-expression format. Key sections in order:

```
(kicad_sch (version N) (generator ...) (uuid ...)
  (lib_symbols ...)        ; Library symbol definitions (pin data, shapes)
  (junction ...)           ; Wire junction points
  (no_connect ...)         ; Explicit no-connect markers
  (wire ...)               ; Wire segments (coordinate pairs)
  (label ...)              ; Local net labels
  (global_label ...)       ; Cross-sheet net labels
  (hierarchical_label ...) ; Sheet-to-sheet pin labels
  (symbol ...)             ; Placed component instances
  (sheet ...)              ; Sub-sheet references (hierarchical designs)
)
```

### Legacy `.sch` (KiCad 4/5)

Line-based format. Key block types:

```
EESchema Schematic File Version N
$Comp / $EndComp          ; Component blocks
Wire Wire Line / x1 y1 x2 y2  ; Wire segments
Text Label / Text GLabel   ; Labels
NoConn ~ x y              ; No-connect markers
$Sheet / $EndSheet         ; Sub-sheet references
```

---

## Component Extraction

### Modern Format

Each placed component is a `(symbol ...)` block after the `(lib_symbols)` section:

```lisp
(symbol (lib_id "Device:R") (at 152.4 176.53 90) (unit 1)
  (property "Reference" "R13" ...)
  (property "Value" "10k" ...)
  (property "Footprint" "Resistor_SMD:R_0402_1005Metric" ...)
  (property "Datasheet" "~" ...)
  (pin "1" (uuid ...))
  (pin "2" (uuid ...))
)
```

**Extract for each component:**
- `lib_id` — library:symbol name
- `at` — placement position (X, Y, rotation angle)
- `unit` — which unit of a multi-unit symbol (1-based, e.g., LM324 unit 1-4 + power unit 5)
- Properties: Reference, Value, Footprint, Datasheet, MPN, Manufacturer, etc.

**Filtering:**
- Skip power symbols: `lib_id` contains `:power:` or the lib_symbol has a `(power)` flag
- Skip power flag markers: Reference starts with `#PWR` or `#FLG`
- Respect DNP: check for `(dnp yes)` attribute or `"DNP"` property

**Multi-unit symbols (critical):**
Symbols like LM324 (quad op-amp), STM32 (multi-bank MCU), dual inductors, relays — each unit is a separate `(symbol ...)` placement sharing the same Reference. Count unique References for BOM, not placements.

The `lib_symbols` section contains sub-symbols named `SymName_U_V` where U = unit number. `_0_1` sub-symbols contain pins shared by ALL units (typically power pins).

### Legacy Format

Components are in `$Comp`/`$EndComp` blocks:

```
$Comp
L library:SymbolName Reference
U unit_number convert_num timestamp
P x y
F 0 "R1" ...          ; Reference
F 1 "10k" ...         ; Value
F 2 "footprint" ...   ; Footprint
F 3 "datasheet" ...   ; Datasheet
F 4 "custom" ...      ; Custom field (MPN, Manufacturer, etc.)
    1    x y
$EndComp
```

**Custom fields (F4+):** May contain MPN (`manf#`, `MPN`, `MFG Part`), Manufacturer (`Manufacturer`, `MFG`), distributor part numbers (`DigiKey`, `Mouser`, `LCSC`), or DNP flag.

---

## Net Building

### Coordinate-Based Union-Find (Modern Format)

KiCad schematics don't store netlists — connectivity is implicit through coordinate matching. Build nets by:

1. **Extract all wire endpoints** from `(wire (pts (xy X1 Y1) (xy X2 Y2)))` blocks
2. **Compute absolute pin positions** for each component (see `net-tracing.md` for transforms)
3. **Union-find**: merge coordinate groups connected by wires, junctions, and shared endpoints
4. **Assign net names** from labels (local, global, hierarchical) and power symbols at group endpoints

**Critical rules:**
- **Y-axis inversion**: `absolute_Y = symbol_Y - pin_Y` (not `+`)
- **Sheet isolation**: Each sheet has a separate coordinate space. Only global labels and global power symbols connect across sheets. Local labels are scoped to their sheet.
- **Junctions**: Wires crossing at a point only connect if there's an explicit `(junction (at X Y))`. T-junctions (wire endpoint touching mid-wire) also connect.
- **Power symbols connect globally**: All instances of `GND`, `+3V3`, etc. are the same net regardless of sheet. The exception is a local power symbol (lib symbol `(power local)`), which joins only within its own sheet.

### Net Names

Nets are named by (priority order):
1. Global label name
2. Power symbol name (e.g., `GND`, `+3V3`)
3. Local label name
4. Hierarchical label name
5. Sheet pin name
6. Unnamed (auto-generated `__unnamed_N`)

### Legacy Format

Wires: `Wire Wire Line` followed by `X1 Y1 X2 Y2` on next line.
Labels: `Text Label X Y orientation 0 ~ 0 "NetName"` or `Text GLabel ...`.
No-connects: `NoConn ~ X Y`.

---

## Signal Analysis Patterns

When scripts can't detect subcircuits, look for these patterns manually in the component/net data.

### Power Regulators

**LDO pattern:** IC with pins named VIN, VOUT, GND (and optionally EN, PG, ADJ/FB). VIN and VOUT connect to different named power nets.

**Switching regulator pattern:** IC with SW/LX/PH pin connected to an inductor. May also have FB pin with voltage divider, BOOT/BST pin with bootstrap capacitor.

**Pin name variants:**
| Function | Pin names |
|----------|-----------|
| Input | VIN, VI, IN, PVIN, AVIN, INPUT |
| Output | VOUT, VO, OUT, OUTPUT |
| Feedback | FB, VFB, ADJ, VADJ (may have numeric suffix: FB1, ADJ2) |
| Switch | SW, PH, LX (may have numeric suffix: SW1, SW2) |
| Enable | EN, ENABLE, ON, ~{SHDN}, SHDN, ~{EN} |
| Bootstrap | BOOT, BST, BOOTSTRAP, CBST |

**Custom library detection:** If the IC has both VIN and VOUT connected to distinct recognized power nets (e.g., +5V and +3V3), it's almost certainly a regulator even without keyword matches in the library name.

### Voltage Dividers

Two resistors in series: R1_pin1→Net_top, R1_pin2→R2_pin1→Mid_net, R2_pin2→Net_bottom. The mid-point net should NOT be a power rail with many connections (that's pull-ups sharing a bus, not a divider).

`ratio = R_bottom / (R_top + R_bottom)`

### Op-Amp Circuits

Look for ICs with `+IN`/`IN+`, `-IN`/`IN-`, `OUT` pins (or bare `+`, `-`, `~` pin names for KiCad standard library op-amps).

**Multi-unit op-amps (LM324, TL082, etc.):** Each unit has its own +IN/-IN/OUT pins with different pin numbers. When analyzing manually, check the `lib_symbols` section for `SymName_N_1` sub-symbols to identify which pins belong to which unit.

**Configurations:**
- **Buffer**: OUT connected directly to -IN
- **Inverting**: Feedback R from OUT to -IN, input R to -IN, +IN to reference/ground
- **Non-inverting**: Feedback R from OUT to -IN, +IN to signal, -IN to ground via R
- **Comparator/open-loop**: No feedback resistor from OUT to -IN

**Common false positives:**
- Current sense amps (INA180/181/185/186/190/199): Have IN+/IN- pins but are fixed-gain, not user-configurable op-amps
- Digital power monitors (INA219/226/229): Have I2C interface, not analog op-amp pins
- Analog front-ends (AD8233): Complex ICs with internal op-amps that don't follow standard topology

### Transistor Circuits

**N-channel MOSFET:** Look for Q references with `NMOS`/`N-Channel` in lib_id or ki_keywords. Gate→drive signal, Drain→load, Source→GND (low-side switch).

**P-channel MOSFET:** `PMOS`/`P-Channel` in lib_id or ki_keywords. Source→power rail, Drain→load, Gate→control (inverted logic). Used as high-side switches.

**Reliable P-channel detection (priority order):**
1. `ki_keywords` from lib_symbol containing "P-Channel" — most reliable
2. lib_id containing `pmos`, `p-channel`, `q_pmos`
3. Value containing unambiguous P-channel family names (DMP series from Diodes Inc)

**Bridge circuits:** Look for transistor pairs where one drain connects to another's source (half-bridge mid-point). Two such pairs = H-bridge. Three = 3-phase.

### Protection Devices

TVS/ESD diodes: Keywords `TVS`, `ESD`, `PESD`, `PRTR`, `USBLC`, `SMAJ`, `SMBJ`, `LESD` in value or lib_id. Connected between signal line and ground/power.

ESD protection ICs: `USBLC6`, `PRTR5V`, `SP0502`, `TPD4E05` etc. Multi-channel protection arrays.

### Bus Detection

**I2C:** Nets named `SDA`/`SCL` (or containing these substrings), or IC pins named `SDA`/`SCL`. Look for pull-up resistors (2.2k-10k) to VCC. Exclude `SCLK`/`SCK` pins (SPI, not I2C).

**SPI:** Nets named `MOSI`/`MISO`/`SCK`/`CS` or `COPI`/`CIPO`/`SCK`/`CS`.

**UART:** Nets named `TX`/`RX`/`TXD`/`RXD` (exclude nets also containing `CAN`, `SPI`, `I2C`).

**CAN:** Nets named `CANH`/`CANL` or CAN transceiver ICs (MCP2551, SN65HVD230, TJA1050, etc.). Don't confuse with RS-485 (SN65HVD75 is RS-485, not CAN).

---

## Legacy .sch Format

### What the Analyzer Provides

The analyzer now parses `.lib` files (cache libraries and project libs) to populate pin data for legacy schematics. When `.lib` files are available:

- All component references, values, footprints, lib_ids
- Pin positions, pin names, and pin types (from `.lib` files)
- Pin-to-net mapping via wire connectivity + pin positions
- Signal analysis (voltage dividers, regulators, op-amp circuits, etc.)
- Subcircuit detection (IC + 1-hop neighbors)
- Net names from labels, power symbols, and pin associations
- Custom properties (F4+ fields: MPN, manufacturer, distributor PNs)

### Remaining Limitations

- **Pin coverage depends on `.lib` availability** — components whose `.lib` files aren't in the repo (standard KiCad system libs like `power`, `device`, `conn`) use built-in fallbacks for common symbols (R, C, L, D, LED, transistors). Uncommon standard library symbols may lack pin data.
- **No ki_keywords** — P-channel detection relies on lib_id and value only

### Hierarchical Legacy Designs

Top-level `.sch` has `$Sheet` blocks with `F1 "subsheet.sch"` pointing to sub-sheet files. Parse all sub-sheets. Hierarchical labels in sub-sheets connect to pins on the sheet block in the parent.

---

## Validation Methodology

When verifying analyzer output (or your own manual parse) against the raw schematic:

### Component Count Validation

1. Count all `(symbol (lib_id ...))` blocks after `(lib_symbols)` section
2. Leave out power symbols and power flags (`#PWR`, `#FLG` references)
3. Count each reference once: the units of a multi-unit part (U1A, U1B) are one component
4. The result should match the analyzer's `statistics.total_components`

### Net Count Validation

1. Count all `(wire ...)` blocks to verify wire count
2. The number of unique named nets should match approximately (unnamed nets may differ in grouping)
3. Spot-check 3-5 specific nets by tracing pins → wires → labels manually

### Signal Analysis Validation

For each detected subcircuit:
1. Verify the component IS what the analyzer says (check lib_id, value)
2. Verify the pin connections are as reported (trace through nets)
3. Check for false positives: is this detection actually correct?
4. Check for false negatives: are there obvious subcircuits the analyzer missed?

**Severity guide:**
- **HIGH**: Wrong component data (extraction bug) or grossly incorrect detection
- **MEDIUM**: Misleading detection (regulator classified wrong topology, wrong gain)
- **LOW**: Minor cosmetic issue (missing unit number, suboptimal configuration label)

### Known Edge Cases

- **Custom libraries**: Components from project-specific libraries may lack keywords that standard KiCad libraries have. Regulators, op-amps, and transistors from custom libs may not be detected.
- **Multi-unit symbols**: LM324 (quad op-amp), dual inductors, relays — each unit needs separate analysis. Pin numbers are unit-specific.
- **Unit-0 shared pins**: In KiCad lib_symbols, `_0_1` sub-symbols contain pins shared by all units (typically power: VCC, GND). These must be included with every placed unit.
- **Rescue libraries**: KiCad creates `*-rescue` libraries during migration. Check for `lib_prefix == "power"` exactly, not substring match (e.g., `dc-power-supply-rescue` is NOT a power library).
- **Eagle .sch files**: Not KiCad format — will output 0 components. These are XML or binary and require separate tools.
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