jeremy-allen/claude-skills/designing-oop-r

Claude Code and agent skill by jeremy-allen/claude-skills

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Object-oriented programming in R: S7, S3, S4, and vctrs class design. Use this skill when designing classes for R projects, choosing between OOP systems, building class hierarchies with inheritance, or migrating between systems. Covers S7 class definitions and methods, the decision matrix for choosing S7 vs S3 vs S4 vs vctrs, practical guidelines for each system, and migration strategies.

Install

npx vskill@latest install jeremy-allen/claude-skills/designing-oop-r

SKILL.md

Designing OOP R

This skill covers object-oriented programming in R, including S7, S3, S4, and vctrs-based classes.

Decision Tree: What Are You Building?

1. Vector-like objects (behave like atomic vectors)

Use vctrs when:

  • Need data frame integration (columns/rows)
  • Want type-stable vector operations
  • Building factor-like, date-like, or numeric-like classes
  • Need consistent coercion/casting behavior
  • Working with existing tidyverse infrastructure

Examples: custom date classes, units, categorical data

2. General objects (complex data structures, not vector-like)

Use S7 when:

  • NEW projects that need formal classes
  • Want property validation and safe property access (@)
  • Need multiple dispatch (beyond S3's double dispatch)
  • Converting from S3 and want better structure
  • Building class hierarchies with inheritance
  • Want better error messages and discoverability

Use S3 when:

  • Simple classes with minimal structure needs
  • Maximum compatibility and minimal dependencies
  • Quick prototyping or internal classes
  • Contributing to existing S3-based ecosystems
  • Performance is absolutely critical (minimal overhead)

Use S4 when:

  • Working in Bioconductor ecosystem
  • Need complex multiple inheritance (S7 doesn't support this)
  • Existing S4 codebase that works well

S7 vs S3 Comparison

FeatureS3S7When S7 wins
Class definitionInformal (convention)Formal (new_class())Need guaranteed structure
Property access$ or attr() (unsafe)@ (safe, validated)Property validation matters
ValidationManual, inconsistentBuilt-in validatorsData integrity important
Method discoveryHard to find methodsClear method printingDeveloper experience matters
Multiple dispatchLimited (base generics)Full multiple dispatchComplex method dispatch needed
InheritanceInformal, NextMethod()Explicit super()Predictable inheritance needed
Migration cost-Low (1-2 hours)Want better structure
PerformanceFastest~Same as S3Performance difference negligible
CompatibilityFull S3Full S3 + S7Need both old and new patterns

S7: Modern OOP

S7 combines S3 simplicity with S4 structure. See s7-examples.md for:

  • Class definitions with new_class()
  • Property validation
  • Generic and method definition
  • Inheritance with parent

S3: Simple Classes

See s3-examples.md for:

  • Constructor functions
  • Print and format methods
  • Simple class patterns

Practical Guidelines

Choose S7 when you have:

See when-s7.md for:

  • Complex validation needs
  • Multiple dispatch needs
  • Class hierarchies with clear inheritance
Choose vctrs when you need:

See when-vctrs.md for:

  • Vector-like behavior in data frames
  • Type-stable operations
Choose S3 when you have:

See when-s3.md for:

  • Simple classes without complex needs
  • Maximum performance needs (rare)
  • Existing S3 ecosystem contributions

Migration Strategy

  1. S3 → S7: Usually 1-2 hours work, keeps full compatibility
  2. S4 → S7: More complex, evaluate if S4 features are actually needed
  3. Base R → vctrs: For vector-like classes, significant benefits
  4. Combining approaches: S7 classes can use vctrs principles internally

source: Sarah Johnson's gist https://gist.github.com/sj-io/3828d64d0969f2a0f05297e59e6c15ad

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
51
Repository forks
5
7-day trend score
20

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 1 Apr 2026, 7 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/jeremy-allen/claude-skills/designing-oop-r/badge)](https://verified-skill.com/skills/jeremy-allen/claude-skills/designing-oop-r)

Something wrong with this skill or its page? Tell us.