Skip to content

Data-Wise/claude-r-dev

Repository files navigation

claude-r-dev

Supercharge your R package development with AI-powered workflows using Claude Code

License: MIT GitHub release GitHub stars GitHub Pages Commands Agents

claude-r-dev is a comprehensive configuration system for Claude Code that transforms AI-assisted coding from helpful suggestions into systematic, production-ready R package development.

✨ What You Get

  • πŸ”§ Modular Profiles: Mix and match configurations for your package type
  • πŸ€– Specialized Sub-Agents: Expert AI assistants for code review, testing, and more
  • ⚑ Custom Workflows: Slash commands for common development tasks
  • πŸ“Š Quality Automation: Built-in checks for CRAN compliance, test coverage, style
  • πŸŽ“ Best Practices: Embedded standards from R package development, statistical methodology, and software engineering
  • πŸš€ One-Line Install: From GitHub directly to your package

πŸš€ Quick Start

Install Claude Code CLI

npm install -g @anthropic-ai/claude-code

Install claude-r-dev to Your Package

Option 1: One-liner (recommended)

curl -fsSL https://raw.githubusercontent.com/Data-Wise/claude-r-dev/main/scripts/install.sh | bash -s -- \
  --profile base \
  --target /path/to/your/package

Option 2: With multiple profiles

# For statistical methodology packages
bash <(curl -fsSL https://raw.githubusercontent.com/Data-Wise/claude-r-dev/main/scripts/install.sh) \
  --profiles base,statistical-methods \
  --target ~/projects/mypackage

Option 3: Clone and customize

git clone https://github.com/Data-Wise/claude-r-dev.git
cd claude-r-dev
./scripts/install.sh --profiles base,statistical-methods --target ~/mypackage

Start Using

cd /path/to/your/package
claude

# Try these commands:
/permissions              # View configured tools
/project:                 # See available slash commands
/project:pre-commit-check # Run comprehensive quality checks

🎨 Create Your Custom Configuration

NEW: Interactive wizard to generate package-specific configurations!

cd your-package
claude

/project:init

The wizard asks about:

  • Package type and domain
  • Statistical notation preferences
  • Object system (S3, S4, S7, R6)
  • Function organization
  • Inference methods
  • Testing requirements
  • Website design (5 color schemes!)

...and generates a custom configuration tailored to YOUR package!

Learn more about customization β†’

πŸ“¦ Available Profiles

πŸ”§ base (Required)

Essential R package development standards

  • CRAN compliance automation
  • Testing standards (testthat3, >80% coverage)
  • Code style enforcement (tidyverse)
  • Git workflows and best practices
  • Documentation standards (roxygen2, pkgdown)

Includes:

  • /project:fix-bug - Structured debugging workflow
  • /project:pre-commit-check - Comprehensive quality checks
  • r-package-reviewer sub-agent - Expert code review
  • test-specialist sub-agent - Comprehensive test generation

πŸ“Š statistical-methods

For methodology and causal inference packages

  • Statistical notation standards (VanderWeele, Pearl, HernΓ‘n & Robins)
  • Identification assumptions documentation
  • Sensitivity analysis patterns
  • Simulation study workflows
  • S7 object system guidelines

Includes:

  • /project:add-method - Systematic new method development
  • /project:migrate-s7 - Safe S3/S4 to S7 migration
  • Enhanced r-package-reviewer with statistical correctness checks
  • Methods-specific testing patterns

πŸ“ˆ data-analysis (Coming in v1.4)

For packages focused on data analysis and visualization

🌐 shiny (Coming in v1.4)

For Shiny application packages

🧬 bioconductor (Coming in v1.4)

For Bioconductor package development

See all profiles β†’

πŸ’‘ Usage Examples

Basic Package Development

# Install base profile
./scripts/install.sh --profile base --target ~/mypackage
cd ~/mypackage
claude
# In Claude Code:
"Read the package structure and suggest improvements"
/project:pre-commit-check
/project:fix-bug "function X fails with negative inputs"

Statistical Methods Package

# Install base + statistical-methods
./scripts/install.sh --profiles base,statistical-methods --target ~/causalmethod
cd ~/causalmethod
claude
# In Claude Code:
/project:add-method "doubly-robust-mediation"
# Follows guided workflow: Plan β†’ Test β†’ Implement β†’ Document

"Use r-package-reviewer sub-agent to check statistical correctness"
# Reviews formulas, assumptions, inference methods

/project:migrate-s7 MediationResult
# Safely migrates S3/S4 classes to modern S7

Test-Driven Development

"Use test-specialist to write comprehensive tests for my_function()"
# Generates tests for happy path, edge cases, validation

/project:pre-commit-check
# Ensures >80% coverage, style compliance, R CMD check passes

"Commit these changes with a descriptive message"
# Claude writes commit following conventional commits standard

🎯 Key Features

Custom Slash Commands

Execute complex workflows with simple commands:

  • /project:add-method - Add new statistical/analytical methods
  • /project:fix-bug - Test-first debugging workflow
  • /project:migrate-s7 - S3/S4 to S7 class migration
  • /project:pre-commit-check - Full quality assurance suite

Specialized Sub-Agents

Expert AI assistants that maintain focused context:

  • r-package-reviewer: Reviews for statistical correctness, CRAN compliance, code quality
  • test-specialist: Writes comprehensive test suites with edge cases
  • documentation-writer: Creates roxygen2 docs, vignettes, pkgdown sites

Automated Quality Checks

Built-in automation for:

  • βœ… Style checking (styler, lintr)
  • βœ… Test coverage (covr, >80% required)
  • βœ… R CMD check (CRAN compliance)
  • βœ… Documentation completeness
  • βœ… Spelling and grammar
  • βœ… Git commit message standards

Statistical Rigor

For methodology packages:

  • Standard notation (VanderWeele 2015, Pearl 2009)
  • Identification assumptions documentation
  • Inference method requirements (bootstrap, delta method)
  • Sensitivity analysis integration
  • Edge case testing (missing data, collinearity, etc.)

πŸ“š Documentation

Documentation Site: https://data-wise.github.io/claude-r-dev/

πŸ—οΈ Architecture

Profile System

base/                   # Core R package standards (required)
β”œβ”€β”€ CLAUDE.md          # Main configuration
β”œβ”€β”€ settings.json      # Tool permissions
β”œβ”€β”€ commands/          # Slash commands
└── agents/            # Sub-agents

statistical-methods/    # Extends base for methodology
β”œβ”€β”€ CLAUDE.md          # Additional standards
β”œβ”€β”€ commands/          # Methods-specific commands
└── agents/            # Enhanced reviewers

Installation Process

  1. Validates target is R package (checks for DESCRIPTION)
  2. Backs up existing configuration
  3. Installs base profile
  4. Merges additional profiles
  5. Updates .gitignore
  6. Generates installation report

πŸ”§ Requirements

Essential

  • Claude Code CLI: npm install -g @anthropic-ai/claude-code
  • R (β‰₯ 4.0.0): With development tools
  • Git: For version control

R Packages (installed automatically on first use)

install.packages(c(
  "devtools", "testthat", "roxygen2",
  "styler", "lintr", "covr", "pkgdown",
  "goodpractice", "spelling", "usethis"
))

For statistical-methods profile:

install.packages("S7")  # Modern object system

🀝 Contributing

We welcome contributions! Ways to help:

  • Add new profiles: Create configurations for new package types
  • Improve existing profiles: Enhance standards and workflows
  • Submit slash commands: Share useful workflow automations
  • Create sub-agents: Build specialized AI assistants
  • Improve documentation: Clarify usage and examples
  • Report issues: Help us identify problems
  • Share feedback: Tell us what works and what doesn't

See CONTRIBUTING.md for details.

πŸ“Š Real-World Examples

mediationverse

Statistical methods package for causal mediation analysis using claude-r-dev:

  • Profiles: base + statistical-methods
  • Result: 50% faster feature development, 100% test coverage

[Your Package Here]

Successfully using claude-r-dev? Submit a PR to share your story!

πŸŽ“ Learning Resources

πŸ—ΊοΈ Roadmap

v1.0 (Current)

  • βœ… Base profile with core R package development
  • βœ… Statistical-methods profile for methodology packages
  • βœ… Smart installer with profile merging
  • βœ… Comprehensive documentation

v1.1 (Next)

  • ⬜ Data-analysis profile
  • ⬜ Shiny profile
  • ⬜ Bioconductor profile
  • ⬜ Profile update system
  • ⬜ Community profile registry

v1.2 (Future)

  • ⬜ Web-based profile builder
  • ⬜ VS Code extension integration
  • ⬜ GitHub Actions workflow templates
  • ⬜ Team collaboration features

❓ FAQ

Q: Do I need Claude Pro to use this?
A: No, Claude Code works with any Claude account. Pro provides extended thinking, but is not required.

Q: Can I use this with Cursor or other AI coding tools?
A: The configuration is optimized for Claude Code, but many patterns can be adapted.

Q: Will this work with my existing package?
A: Yes! The installer checks for existing configurations and merges intelligently.

Q: Can I customize the profiles?
A: Absolutely! See Customization Guide for details.

Q: How do I update to the latest version?
A: Run ./scripts/update.sh in your package, or reinstall with the latest version.

Q: Is this only for R packages?
A: Currently yes, but the architecture could support other languages. Contributions welcome!

πŸ“ License

MIT License - see LICENSE for details.

πŸ™ Acknowledgments

  • Anthropic - For Claude Code and best practices documentation
  • R Core Team - For R and package development infrastructure
  • Hadley Wickham - For R package development standards and tidyverse
  • Contributors - Everyone who improves and extends claude-r-dev

πŸ“¬ Contact & Support


Transform your R package development from ad-hoc to systematic, from uncertain to rigorous, from solo to AI-collaborative.

Install. Configure. Excel. πŸš€


Made with ❀️ for the R community

About

Supercharge R package development with AI-powered workflows using Claude Code

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages