返回技能列表

scaffold-shiny-app

pjt222
更新于 Yesterday
3 次查看
17
2
17
在 GitHub 上查看
designdata

关于

This skill scaffolds new Shiny applications in R with three framework options: golem for production R packages, rhino for enterprise projects, or vanilla for quick prototypes. It handles project initialization and creates the first module structure. Use it when starting any interactive web application, dashboard, or data explorer in R that requires a structured foundation.

快速安装

Claude Code

推荐
主要方式
npx skills add pjt222/agent-almanac -a claude-code
插件命令备选方式
/plugin add https://github.com/pjt222/agent-almanac
Git 克隆备选方式
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/scaffold-shiny-app

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

Scaffold Shiny App

Make new Shiny app with prod-ready structure. Use golem, rhino, or vanilla scaffolding.

When Use

  • Start new interactive web app in R
  • Make dashboard or data explorer prototype
  • Set up prod Shiny app as R package (golem)
  • Bootstrap enterprise Shiny project (rhino)

Inputs

  • Required: App name
  • Required: Framework choice (golem, rhino, vanilla)
  • Optional: Module scaffolding (default: yes)
  • Optional: renv for dep management (default: yes)
  • Optional: Deploy target (shinyapps.io, Posit Connect, Docker)

Steps

Step 1: Choose Framework

Judge project needs to pick framework.

FrameworkBest ForStructure
golemProduction apps shipped as R packagesR package with DESCRIPTION, tests, vignettes
rhinoEnterprise apps with JS/CSS build pipelinebox modules, Sass, JS bundling, rhino::init()
vanillaQuick prototypes and learningSingle app.R or ui.R/server.R pair

Got: Clear framework decision based on scope, team needs.

If fail: Unsure? Default to golem — most structure, can simplify later. Vanilla only for throwaway prototypes.

Step 2: Scaffold Project

Golem Path

golem::create_golem("myapp", package_name = "myapp")

Creates.

myapp/
├── DESCRIPTION
├── NAMESPACE
├── R/
│   ├── app_config.R
│   ├── app_server.R
│   ├── app_ui.R
│   └── run_app.R
├── dev/
│   ├── 01_start.R
│   ├── 02_dev.R
│   ├── 03_deploy.R
│   └── run_dev.R
├── inst/
│   ├── app/www/
│   └── golem-config.yml
├── man/
├── tests/
│   ├── testthat.R
│   └── testthat/
└── vignettes/

Rhino Path

rhino::init("myapp")

Creates.

myapp/
├── app/
│   ├── js/
│   ├── logic/
│   ├── static/
│   ├── styles/
│   ├── view/
│   └── main.R
├── tests/
│   ├── cypress/
│   └── testthat/
├── .github/
├── app.R
├── dependencies.R
├── rhino.yml
└── renv.lock

Vanilla Path

Create app.R.

library(shiny)
library(bslib)

ui <- page_sidebar(
  title = "My App",
  sidebar = sidebar(
    sliderInput("n", "Sample size", 10, 1000, 100)
  ),
  card(
    card_header("Output"),
    plotOutput("plot")
  )
)

server <- function(input, output, session) {
  output$plot <- renderPlot({
    hist(rnorm(input$n), main = "Random Normal")
  })
}

shinyApp(ui, server)

Got: Project dir made with all scaffolding files.

If fail: Golem? Ensure golem package installed: install.packages("golem"). Rhino? Install from GitHub: remotes::install_github("Appsilon/rhino"). Vanilla? Ensure shiny + bslib installed.

Step 3: Configure Dependencies

Golem/Vanilla

# Initialize renv
renv::init()

# Add core dependencies
usethis::use_package("shiny")
usethis::use_package("bslib")
usethis::use_package("DT")         # if using data tables
usethis::use_package("plotly")     # if using interactive plots

# Snapshot
renv::snapshot()

Rhino

Deps managed in dependencies.R.

# dependencies.R
library(shiny)
library(bslib)
library(DT)

Got: All deps recorded in DESCRIPTION (golem) or dependencies.R (rhino), locked with renv.

If fail: renv::init() fails? Check write perms. Packages fail to install? Check R version compat.

Step 4: Create First Module

Golem

golem::add_module(name = "dashboard", with_test = TRUE)

Creates R/mod_dashboard.R and tests/testthat/test-mod_dashboard.R.

Rhino

Make app/view/dashboard.R.

box::use(
  shiny[moduleServer, NS, tagList, h3, plotOutput, renderPlot],
)

#' @export
ui <- function(id) {
  ns <- NS(id)
  tagList(
    h3("Dashboard"),
    plotOutput(ns("plot"))
  )
}

#' @export
server <- function(id) {
  moduleServer(id, function(input, output, session) {
    output$plot <- renderPlot({
      plot(1:10)
    })
  })
}

Vanilla

Add module functions to separate file R/mod_dashboard.R.

dashboardUI <- function(id) {
  ns <- NS(id)
  tagList(
    h3("Dashboard"),
    plotOutput(ns("plot"))
  )
}

dashboardServer <- function(id) {
  moduleServer(id, function(input, output, session) {
    output$plot <- renderPlot({
      plot(1:10)
    })
  })
}

Got: Module file made with UI + server functions using proper namespacing.

If fail: Ensure module uses NS(id) for all input/output IDs in UI function. Without namespacing, IDs collide when module used multiple times.

Step 5: Run Application

# Golem
golem::run_dev()

# Rhino
shiny::runApp()

# Vanilla
shiny::runApp("app.R")

Got: App launches in browser without errors.

If fail: Check R console for error msgs. Common: missing packages (install), port in use (specify different port port = 3839), syntax errors in UI/server.

Checks

  • App dir has correct structure for chosen framework
  • shiny::runApp() launches without errors
  • At least one module scaffolded with UI + server functions
  • Deps recorded (DESCRIPTION or dependencies.R)
  • renv.lock captures all package versions
  • Module uses NS(id) for proper namespace isolation

Pitfalls

  • Choose vanilla for prod: Vanilla lacks testing, docs, deploy tooling. Use golem or rhino for anything beyond prototypes.
  • Missing namespace in modules: Every inputId and outputId in module UI must be wrapped with ns(). Forget = silent ID collisions.
  • golem without devtools workflow: golem apps are R packages. Use devtools::load_all(), devtools::test(), devtools::document() — not source().
  • rhino without box: rhino uses box for module imports. Do not fall back to library() calls — use box::use() for explicit imports.

See Also

  • build-shiny-module — make reusable Shiny modules with proper namespace isolation
  • test-shiny-app — set up shinytest2 and testServer() tests
  • deploy-shiny-app — deploy to shinyapps.io, Posit Connect, Docker
  • design-shiny-ui — bslib theming + responsive layout design
  • create-r-package — R package scaffolding (golem apps are R packages)
  • manage-renv-dependencies — detailed renv dep management

GitHub 仓库

pjt222/agent-almanac
路径: i18n/caveman/skills/scaffold-shiny-app
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

相关推荐技能

content-collections

Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。

查看技能

polymarket

这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。

查看技能

creating-opencode-plugins

该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。

查看技能

sglang

SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。

查看技能