返回技能列表

scaffold-shiny-app

pjt222
更新于 6 days ago
16 次查看
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, making it ideal for starting dashboards, data explorers, or production web apps. Use it when bootstrapping any interactive Shiny application to establish the proper structure from the beginning.

快速安装

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 中复制并粘贴此命令以安装该技能

技能文档

架 Shiny 應

建新 Shiny 應含產備結構用 golem、rhino、或素架。

  • 始新互動 R 網應→用
  • 建儀板或資探原型→用
  • 設產 Shiny 應為 R 包(golem)→用
  • 啟企 Shiny 項(rhino)→用

  • :應名
  • :框選(golem、rhino、素)
  • :含模架(默:是)
  • :用 renv 管依(默:是)
  • :釋標(shinyapps.io、Posit Connect、Docker)

一:擇框

按項需選宜框:

結構
golem產應運為 R 包R 包含 DESCRIPTION、測、誌
rhino企應含 JS/CSS 建管box 模、Sass、JS 包、rhino::init()
速原型與學單 app.R 或 ui.R/server.R 對

得:明框決於項範與組需。

敗:未定→默 golem—予最多結構可後簡。素僅宜棄原型。

二:架項

Golem 路

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

建:

myapp/
├── DESCRIPTION
├── NAMESPACE
├── R/
│   ├── app_config.R
│   ├── app_server.R
│   ├── app_ui.R
│   └── run_app.R
├── dev/
├── inst/
├── man/
├── tests/
└── vignettes/

Rhino 路

rhino::init("myapp")

建:

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

素路

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)

得:項目建含諸架檔。

敗:golem→確 golem 包裝(install.packages("golem"))。rhino→自 GitHub 裝(remotes::install_github("Appsilon/rhino"))。素→確 shiny、bslib 裝。

三:配依

Golem/素

renv::init()

usethis::use_package("shiny")
usethis::use_package("bslib")
usethis::use_package("DT")
usethis::use_package("plotly")

renv::snapshot()

Rhino

依管於 dependencies.R

library(shiny)
library(bslib)
library(DT)

得:諸依錄於 DESCRIPTION(golem)或 dependencies.R(rhino)、renv 鎖。

敗:renv::init() 敗→查寫權。包裝敗→查 R 本相容。

四:建首模

Golem

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

R/mod_dashboard.Rtests/testthat/test-mod_dashboard.R

Rhino

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)
    })
  })
}

加模函至 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)
    })
  })
}

得:模檔建含 UI 與服函用正命空。

敗:確模 UI 函諸入/出 ID 用 NS(id)。無命空→ID 多用時撞。

五:行應

golem::run_dev()
shiny::runApp()
shiny::runApp("app.R")

得:應於瀏無誤啟。

敗:察 R 控制台誤訊。常題:缺包(裝之)、口已用(port = 3839)、UI/服碼語誤。

  • 應目結構合所擇框
  • shiny::runApp() 啟無誤
  • ≥ 1 模架含 UI 與服函
  • 依錄(DESCRIPTION 或 dependencies.R)
  • renv.lock 捕諸包本
  • 模用 NS(id) 命空隔

  • 產用素:素無測施、文、釋工。原型外用 golem 或 rhino
  • 模缺命空:模 UI 諸 inputIdoutputId 必裹 ns()。忘致默 ID 撞
  • golem 無 devtools 流:golem 應為 R 包。用 devtools::load_all()devtools::test()devtools::document(),非 source()
  • rhino 無 box:rhino 用 box 為模入。勿退 library()—用 box::use() 顯入

  • build-shiny-module
  • test-shiny-app
  • deploy-shiny-app
  • design-shiny-ui
  • create-r-package
  • manage-renv-dependencies

GitHub 仓库

pjt222/agent-almanac
路径: i18n/wenyan-ultra/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是理想选择。

查看技能