Back to Skills

component

majiayu000
Updated Yesterday
58
9
58
View on GitHub
Metageneral

About

This is the foundational skill for managing electronic components in the library, used when creating new component types or manufacturer handlers. It provides core functionality for MPN operations, BOM entries, and component classification via a hierarchical type system. Developers should use it as the base for extending component support and working with manufacturer-specific data.

Quick Install

Claude Code

Recommended
Plugin CommandRecommended
/plugin add https://github.com/majiayu000/claude-skill-registry
Git CloneAlternative
git clone https://github.com/majiayu000/claude-skill-registry.git ~/.claude/skills/component

Copy and paste this command in Claude Code to install this skill

Documentation

Electronic Component Skill

This skill provides guidance for working with electronic components in the lib-electronic-components library.

Core Concepts

Component Type Hierarchy

Components are classified using ComponentType enum with two levels:

  • Base types: RESISTOR, CAPACITOR, MOSFET, OPAMP, etc.
  • Manufacturer-specific types: MOSFET_INFINEON, CAPACITOR_CERAMIC_MURATA, etc.

Use getBaseType() to map specific types to their base type.

Key Classes

ClassPurpose
ComponentTypeEnum of ~200 component types with passive/semiconductor flags
ComponentManufacturerEnum of manufacturers with regex patterns
ManufacturerHandlerInterface for manufacturer-specific MPN parsing
MPNUtilsStatic utilities for MPN normalization, similarity, type detection
BOMEntryComponent entry in a bill of materials

Adding a New Manufacturer Handler

  1. Create handler in src/main/java/no/cantara/electronic/component/lib/manufacturers/:
public class NewMfrHandler implements ManufacturerHandler {
    @Override
    public void initializePatterns(PatternRegistry registry) {
        registry.registerPattern(ComponentType.RESISTOR,
            Pattern.compile("^NMF[0-9]{4}.*", Pattern.CASE_INSENSITIVE));
    }

    @Override
    public String extractPackageCode(String mpn) { /* ... */ }

    @Override
    public String extractSeries(String mpn) { /* ... */ }

    @Override
    public boolean isOfficialReplacement(String mpn1, String mpn2) { return false; }

    @Override
    public Set<ManufacturerComponentType> getManufacturerTypes() { return Set.of(); }

    @Override
    public Set<ComponentType> getSupportedTypes() {
        return Set.of(ComponentType.RESISTOR);
    }
}
  1. Add entry to ComponentManufacturer enum:
NEW_MFR("(?:NMF)[0-9]", "New Manufacturer", new NewMfrHandler()),

Adding a New Component Type

  1. Add to ComponentType enum with passive/semiconductor flags:
NEW_TYPE(false, true),  // (isPassive, isSemiconductor)
NEW_TYPE_MANUFACTURER(false, true),
  1. Update getBaseType() switch to map specific types to base:
case NEW_TYPE_INFINEON, NEW_TYPE_ST -> NEW_TYPE;
  1. Add patterns in relevant manufacturer handlers

MPN Operations

// Normalize MPN (removes special characters)
String normalized = MPNUtils.normalize("LM358-N"); // "LM358N"

// Strip package suffix to get base part number
String base = MPNUtils.stripPackageSuffix("MAX3483EESA+"); // "MAX3483EESA"
String base2 = MPNUtils.stripPackageSuffix("LTC2053HMS8#PBF"); // "LTC2053HMS8"

// Generate search variations (for datasheet/component searches)
List<String> vars = MPNUtils.getSearchVariations("TJA1050T/CM,118");
// ["TJA1050T/CM,118", "TJA1050T"]

// Check component equivalence (ignoring package suffixes)
boolean equiv = MPNUtils.isEquivalentMPN("LTC2053HMS8#PBF", "LTC2053HMS8#TR"); // true

// Extract package suffix
Optional<String> suffix = MPNUtils.getPackageSuffix("MAX3483EESA+"); // Optional.of("+")

// Detect manufacturer
ComponentManufacturer mfr = ComponentManufacturer.fromMPN("STM32F103C8T6");

// Detect component type
ComponentType type = ComponentType.fromMPN("IRF540N"); // MOSFET

// Calculate similarity
double sim = MPNUtils.calculateSimilarity("LM358", "MC1458"); // 0.9

Package Suffix Support

MPNUtils now supports manufacturer-specific package suffixes:

  • Maxim/AD: + (lead-free) - e.g., MAX3483EESA+
  • Linear Tech: #PBF, #TR (RoHS, Tape & Reel) - e.g., LTC2053HMS8#PBF
  • NXP: /CM,118 (ordering codes) - e.g., TJA1050T/CM,118
  • Various: ,315 (ordering codes) - e.g., NC7WZ04,315

Use cases:

  • Datasheet searches: Try both original and base MPN
  • Component deduplication: Same base = same component
  • BOM validation: Match supplier MPNs to design MPNs
  • Inventory matching: Ignore packaging differences

Similarity Calculators

Each component type can have a dedicated similarity calculator in componentsimilaritycalculators/:

  • ResistorSimilarityCalculator - compares resistance values, tolerances, packages
  • CapacitorSimilarityCalculator - compares capacitance, voltage, dielectric
  • MosfetSimilarityCalculator - compares Vds, Rds(on), package
  • etc.

Implement ComponentSimilarityCalculator interface and add to list in MPNUtils.

Testing

Run component-related tests:

mvn test -Dtest=MPNUtilsTest
mvn test -Dtest=ComponentTypeDetectorTest
mvn test -Dtest=MPNExtractionTest

Related Skills

Use specialized skills for specific component types:

  • /resistor - Resistor patterns and value extraction
  • /capacitor - Capacitor patterns and specifications
  • /semiconductor - Diodes, transistors, MOSFETs
  • /ic - Microcontrollers, op-amps, voltage regulators
  • /connector - Connector manufacturer patterns
  • /memory - Flash, EEPROM, RAM components

See Also

Advanced Skills

  • /handler-pattern-design - Handler patterns, anti-patterns, and testing strategies
  • /mpn-normalization - MPN suffix handling and normalization patterns
  • /component-type-detection-hierarchy - Type hierarchy, specificity levels, getBaseType() mapping
  • /component-spec-extraction - Spec extraction patterns and naming conventions
  • /manufacturer-detection-from-mpn - Manufacturer regex patterns and detection ordering

Documentation

  • HISTORY.md - Handler bug patterns and fixes (PR #89, handler cleanup PRs #73-88)
  • .docs/history/HANDLER_IMPLEMENTATION_PATTERNS.md - Detailed handler development patterns
  • .docs/history/BUG_FIX_ANALYSIS.md - Critical bugs and prevention strategies

Recording Learnings

Important: When you discover quirks, edge cases, or important patterns while working on components:

  1. General/cross-cutting learnings → Add to CLAUDE.md under "Learnings & Quirks"
  2. Component-specific learnings → Add to the relevant skill file below

Examples of what to record:

  • MPN patterns that don't follow expected conventions
  • Manufacturer-specific quirks in part numbering
  • Edge cases in similarity calculation
  • Test failures that revealed unexpected behavior
  • Regex patterns that needed adjustment

Learnings & Quirks

Handler Patterns

  • Use registry.addPattern() not registry.registerPattern() - the latter requires a compiled Pattern object
  • Handler order in ComponentManufacturer enum affects detection priority for ambiguous MPNs

MPN Edge Cases

  • Some MPNs contain hyphens that are significant (e.g., Molex 43045-0212) vs decorative (e.g., LM358-N)
  • Yageo resistors: RC0603FR-0710KL - the -07 is TCR code, not a separator
<!-- Add new learnings above this line -->

GitHub Repository

majiayu000/claude-skill-registry
Path: skills/component

Related Skills

algorithmic-art

Meta

This Claude Skill creates original algorithmic art using p5.js with seeded randomness and interactive parameters. It generates .md files for algorithmic philosophies, plus .html and .js files for interactive generative art implementations. Use it when developers need to create flow fields, particle systems, or other computational art while avoiding copyright issues.

View skill

subagent-driven-development

Development

This skill executes implementation plans by dispatching a fresh subagent for each independent task, with code review between tasks. It enables fast iteration while maintaining quality gates through this review process. Use it when working on mostly independent tasks within the same session to ensure continuous progress with built-in quality checks.

View skill

executing-plans

Design

Use the executing-plans skill when you have a complete implementation plan to execute in controlled batches with review checkpoints. It loads and critically reviews the plan, then executes tasks in small batches (default 3 tasks) while reporting progress between each batch for architect review. This ensures systematic implementation with built-in quality control checkpoints.

View skill

cost-optimization

Other

This Claude Skill helps developers optimize cloud costs through resource rightsizing, tagging strategies, and spending analysis. It provides a framework for reducing cloud expenses and implementing cost governance across AWS, Azure, and GCP. Use it when you need to analyze infrastructure costs, right-size resources, or meet budget constraints.

View skill