design-with-existing-representations

Guides selection of data representations in R packages using existing structures before creating new classes.

1|Updated Aug 11, 2026
One-click install
npx skills add https://github.com/0xMuluh/package-development-skills --skill design-with-existing-representations-0xmuluh
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: design-with-existing-representations
Source: https://github.com/0xMuluh/package-development-skills/tree/main/design-with-existing-representations
Command: npx skills add https://github.com/0xMuluh/package-development-skills --skill design-with-existing-representations-0xmuluh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Package developers often create unnecessary custom classes, wrappers, and containers when vectors, matrices, data frames, lists, or established ecosystem containers would suffice, creating long-term maintenance obligations for constructors, accessors, validation, serialization, and migration. ## Core Features & Use Cases - Representation Preference Order: Evaluates options from base structures through ecosystem containers, upstream result classes, and metadata mechanisms before permitting a new class. - Required Representation Check: Provides a documented checklist forcing concrete justification of why existing representations are insufficient before introducing new structure. - Anti-Pattern Catalog: Identifies wrapper classes, parallel object universes, and conversion-heavy workflows to avoid. - Use Case: When building an R package that returns ordination results, use this Skill to determine whether to return the upstream rda object directly instead of wrapping it in a package-specific result class. ## Quick Start Ask the AI to review your planned data representation for a new package feature and justify whether a new class is needed or an existing structure suffices.

Frequently Asked Questions about design-with-existing-representations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I decide whether to create a new class in an R package?▼

Create a new class only when existing structures fail a concrete current requirement, such as invariant preservation, specialized subsetting, dispatch, or validation. Document why base structures, ecosystem containers, upstream results, and metadata mechanisms are insufficient first.

When should I use a data frame instead of a custom result class?▼

Use a data frame when information is tabular and heterogeneous, such as coefficients, test statistics, or sample metadata. A custom class is only justified when dispatch or structural invariants genuinely require it.

Should I wrap upstream result objects in package-specific classes?▼

No, preserve upstream result classes when they already provide useful methods like print, summary, plot, and predict. Only wrap them when a concrete downstream operation fails without the wrapper.

What are the hidden costs of creating a new S3 or S4 class?▼

A new class requires constructors, validation, accessors, printing, subsetting, serialization, compatibility handling, testing, migration support, and deprecation policy. These obligations usually far exceed the initial class definition cost.

When is a named list sufficient for storing results?▼

A named list suffices when components differ in type or shape, names communicate meaning, and no specialized subsetting or generic dispatch is needed. It is often clearer than a custom container with one-line accessors.