Create working code demonstrations and examples.
Generates working code demonstrations for tutorials, vignettes, and presentations with explanations and examples.
/plugin marketplace add Data-Wise/craft/plugin install data-wise-craft@Data-Wise/craftcode/Create working code demonstrations and examples.
Generate demonstrations for:
Define scope
Design flow
Write code
Add context
# Demo: [Topic]
## Overview
[What this demo covers and why it matters]
## Prerequisites
- [Required packages]
- [Assumed knowledge]
## Setup
```r
# Load packages
library(package1)
library(package2)
# Sample data
data <- create_example_data()
[Explanation of what we're doing]
# Step 1: Description
result <- function_call(data)
result
#> [Expected output shown]
[Interpretation and notes]
[Continue building...]
# How to modify for this case
# Alternative approach
Issue: [Common problem] Solution: [How to fix]
## Demo Types
### Quick Example
- Single concept
- ~10 lines of code
- Immediate output
### Tutorial
- Multiple concepts
- Step-by-step progression
- Full workflow
### Vignette
- Comprehensive coverage
- Real-world use case
- Publication quality
### Live Coding
- Presentation format
- Clear stopping points
- Audience interaction notes
## MCP Integration
Uses these tools when available:
- `r_execute` - Run and verify code
- `r_plot` - Generate visualizations
- `r_preview` - Preview output
## Examples
**Request**: "Create a demo of linear regression in R for beginners"
**Request**: "Generate a vignette showing mediation analysis workflow"
**Request**: "Demo ggplot2 customization for publication-quality figures"
**Request**: "Create live-coding examples for a dplyr workshop"
## Best Practices
### Code Style
- Use consistent formatting
- Include all library() calls
- Show expected output in comments
### Explanation
- Explain before code blocks
- Interpret after outputs
- Connect to real-world use
### Reproducibility
- Set seeds for random operations
- Include data creation code
- Note package versions
## Tips
- Start with the simplest working example
- Build complexity gradually
- Include "what if" variations
- Show both success and error cases
- Link to further resources