scaffold-shiny-app
About
This skill scaffolds new Shiny applications using golem (production R package), rhino (enterprise), or vanilla (quick prototype) structures. It handles framework selection, project initialization, and creating the first module. Use it when starting interactive web apps in R, prototyping dashboards, setting up production Shiny apps as packages, or bootstrapping enterprise projects.
Quick Install
Claude Code
Recommendednpx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/scaffold-shiny-appCopy and paste this command in Claude Code to install this skill
Documentation
name: scaffold-shiny-app description: > golem(本番Rパッケージ)、rhino(エンタープライズ)、またはvanilla(クイック プロトタイプ)構造を使って新しいShinyアプリケーションをスキャフォールドします。 フレームワークの選択、プロジェクトの初期化、最初のモジュール作成を扱います。 Rで新しいインタラクティブWebアプリケーションを開始するとき、ダッシュボードや データエクスプローラーのプロトタイプを作成するとき、golemを使ってRパッケージ として本番Shinyアプリをセットアップするとき、またはrhinoでエンタープライズ Shinyプロジェクトをブートストラップするときに使用します。 locale: ja source_locale: en source_commit: 6f65f316 translator: claude-opus-4-6 translation_date: 2026-03-16 license: MIT allowed-tools: Read Write Edit Bash Grep Glob metadata: author: Philipp Thoss version: "1.0" domain: shiny complexity: basic language: R tags: shiny, golem, rhino, scaffold, web-app, reactive
Shinyアプリのスキャフォールド
golem、rhino、またはvanillaスキャフォールドを使って本番対応の構造で新しいShinyアプリケーションを作成します。
使用タイミング
- Rで新しいインタラクティブWebアプリケーションを開始するとき
- ダッシュボードやデータエクスプローラーのプロトタイプを作成するとき
- RパッケージとしてShinyアプリを本番設定でセットアップするとき(golem)
- エンタープライズShinyプロジェクトをブートストラップするとき(rhino)
入力
- 必須: アプリケーション名
- 必須: フレームワークの選択(golem、rhino、またはvanilla)
- オプション: モジュールスキャフォールドを含めるか(デフォルト:あり)
- オプション: 依存関係管理にrenvを使用するか(デフォルト:あり)
- オプション: デプロイ先(shinyapps.io、Posit Connect、Docker)
手順
ステップ1: フレームワークの選択
適切なフレームワークを選択するためにプロジェクト要件を評価します:
| フレームワーク | 最適用途 | 構造 |
|---|---|---|
| golem | Rパッケージとして出荷する本番アプリ | DESCRIPTION、テスト、ビネットを持つRパッケージ |
| rhino | JS/CSSビルドパイプラインを持つエンタープライズアプリ | boxモジュール、Sass、JSバンドリング、rhino::init() |
| vanilla | クイックプロトタイプと学習 | 単一のapp.RまたはUI.R/server.Rペア |
期待結果: プロジェクトのスコープとチームのニーズに基づいた明確なフレームワークの決定。
失敗時: 迷う場合はgolemをデフォルトとして選択してください。最も構造化されており、後で簡略化できます。vanillaは使い捨てプロトタイプにのみ適しています。
ステップ2: プロジェクトのスキャフォールド
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/
│ ├── 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パス
rhino::init("myapp")
これにより以下が作成されます:
myapp/
├── app/
│ ├── js/
│ ├── logic/
│ ├── static/
│ ├── styles/
│ ├── view/
│ └── main.R
├── tests/
│ ├── cypress/
│ └── testthat/
├── .github/
├── app.R
├── dependencies.R
├── rhino.yml
└── renv.lock
Vanillaパス
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")。vanillaの場合はshinyとbslibがインストールされているか確認してください。
ステップ3: 依存関係の設定
Golem/Vanilla
# renvの初期化
renv::init()
# コア依存関係の追加
usethis::use_package("shiny")
usethis::use_package("bslib")
usethis::use_package("DT") # データテーブルを使用する場合
usethis::use_package("plotly") # インタラクティブプロットを使用する場合
# スナップショット
renv::snapshot()
Rhino
依存関係はdependencies.Rで管理されます:
# dependencies.R
library(shiny)
library(bslib)
library(DT)
期待結果: すべての依存関係がDESCRIPTION(golem)またはdependencies.R(rhino)に記録され、renvでロックされています。
失敗時: renv::init()が失敗する場合は書き込み権限を確認してください。パッケージのインストールが失敗する場合はRバージョンの互換性を確認してください。
ステップ4: 最初のモジュールの作成
Golem
golem::add_module(name = "dashboard", with_test = TRUE)
これによりR/mod_dashboard.Rとtests/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)
})
})
}
Vanilla
UIとサーバー関数を別のファイル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関数内のすべてのinput/output IDに対してNS(id)を使用していることを確認してください。名前空間がなければ、モジュールを複数回使用するとIDが衝突します。
ステップ5: アプリケーションの実行
# Golem
golem::run_dev()
# Rhino
shiny::runApp()
# Vanilla
shiny::runApp("app.R")
期待結果: アプリケーションがエラーなしでブラウザで起動します。
失敗時: Rコンソールのエラーメッセージを確認してください。よくある問題:パッケージの欠落(インストールしてください)、ポートが使用中(port = 3839で別のポートを指定)、またはUI/サーバーコードの構文エラー。
バリデーション
- アプリケーションディレクトリが選択したフレームワークに対して正しい構造を持つ
-
shiny::runApp()がエラーなしで起動する - UIとサーバー関数を持つ少なくとも1つのモジュールがスキャフォールドされている
- 依存関係が記録されている(DESCRIPTIONまたはdependencies.R)
- renv.lockがすべてのパッケージバージョンをキャプチャしている
- モジュールが適切な名前空間分離のために
NS(id)を使用している
よくある落とし穴
- 本番にvanillaを選ぶ: vanilla構造にはテストインフラ、ドキュメント、デプロイツールが不足しています。プロトタイプ以外にはgolemまたはrhinoを使用してください。
- モジュールで名前空間を省略する: モジュールUIのすべての
inputIdとoutputIdはns()でラップする必要があります。これを忘れるとサイレントなID衝突が起きます。 - devtoolsワークフローなしのgolem: golemアプリはRパッケージです。
source()ではなくdevtools::load_all()、devtools::test()、devtools::document()を使用してください。 - boxなしのrhino: rhinoはモジュールインポートにboxを使用します。
library()呼び出しに戻らず、明示的なインポートにはbox::use()を使用してください。
関連スキル
build-shiny-module— 適切な名前空間分離を持つ再利用可能なShinyモジュールの作成test-shiny-app— shinytest2とtestServer()テストのセットアップdeploy-shiny-app— shinyapps.io、Posit Connect、またはDockerへのデプロイdesign-shiny-ui— bslibのテーマとレスポンシブレイアウトデザインcreate-r-package— Rパッケージスキャフォールド(golemアプリはRパッケージ)manage-renv-dependencies— 詳細なrenv依存関係管理
GitHub Repository
Related Skills
llamaguard
OtherLlamaGuard is Meta's 7-8B parameter model for moderating LLM inputs and outputs across six safety categories like violence and hate speech. It offers 94-95% accuracy and can be deployed using vLLM, Hugging Face, or Amazon SageMaker. Use this skill to easily integrate content filtering and safety guardrails into your AI applications.
cost-optimization
OtherThis Claude Skill helps developers optimize cloud costs through resource rightsizing, tagging strategies, and spending analysis. It provides a framework for reducing cloud expenses and implementing cost governance across AWS, Azure, and GCP. Use it when you need to analyze infrastructure costs, right-size resources, or meet budget constraints.
quantizing-models-bitsandbytes
OtherThis skill quantizes LLMs to 8-bit or 4-bit precision using bitsandbytes, achieving 50-75% memory reduction with minimal accuracy loss. It's ideal for running larger models on limited GPU memory or accelerating inference, supporting formats like INT8, NF4, and FP4. The skill integrates with HuggingFace Transformers and enables QLoRA training and 8-bit optimizers.
dispatching-parallel-agents
OtherThis Claude Skill dispatches multiple agents to investigate and fix 3+ independent problems concurrently. It is designed for scenarios involving unrelated failures that can be resolved without shared state or dependencies. The core capability is parallel problem-solving, assigning one agent per independent problem domain to maximize efficiency.
