shiny-r-optimize
БесплатноБез исполняемых скриптовНе проверенDiagnose and fix performance problems in Shiny for R apps — slow startup, sluggish interactions, long-running blocking operations, and apps that struggle…
от posit-dev★ 578 звёзд на GitHubОб этом скилле
Optimizing Shiny App Performance
Make an existing Shiny for R app faster without changing what it does. The typical user has an app that worked fine for one or two developers and is now too slow or must support more users. Keep all app logic intact; prefer code changes over deployment tuning; resist rewrites.
Order of preference for every fix:
- Eliminate work that isn't needed (don't compute outputs nobody is looking at; don't compute with inputs that aren't ready).
- Reuse work that repeats (shared reactives, caching).
- Accelerate unavoidable work (faster data formats, vectorized code).
- Relocate work that blocks (async / background tasks) — last resort; it buys concurrency, not raw speed.
Workflow
1. Understand the complaint
Pin down what "slow" means and write it as a benchmark to beat:
- What feels slow? First page load? Every interaction? One specific action? Only when several people use it at once?
- How many concurrent users must it support? (1–5, ~20, hundreds?)
- Where does it run? Locally, Posit Connect, Posit Connect Cloud, Shiny Server?
- How big is the data, where does it live, and how often does it change?
2. Scan the source for smells — and fix them now
Read the app code (app.R / server.R / ui.R / modules) and look for the
classic smells. Every smell in this table has a safe, behavior-preserving
fix: apply each fix you find immediately, before measuring. These ten
changes fix the large majority of slow Shiny apps.
| Smell (search for) | Why it hurts | Fix |
|---|---|---|
read.csv/read_csv/DB queries inside server() or render functions |
Re-runs per session or per invalidation | Load once in global scope → data-loading.md |
| Same subsetting/aggregation repeated in several outputs | Duplicate computation on every change | Extract one shared reactive() → reactive-graph.md |
Renderers defined inside observeEvent()/observe() |
Re-creates outputs; fights the reactive model | Define once at server top level, gate with bindEvent()/req() → reactive-graph.md |
Expensive render* with no req() guard |
Computes on empty/half-ready inputs at startup | req() at the top of the body → reactive-graph.md |
| Many heavy outputs on the landing view | All must compute before the page is usable | Move to tabs/navs — hidden outputs don't compute → rendering-ui.md |
No bindCache() on repeated identical expensive calls |
Everyone re-pays the same cost | bindCache() → caching.md |
| Sliders/text inputs feeding expensive chains directly | One drag = dozens of recomputations | debounce()/throttle()/bindEvent() → reactive-graph.md |
Sys.sleep, long model fits, slow API/DB calls inline in reactives/renders |
Blocks the whole R process for all users | ExtendedTask → async-tasks.md |
renderUI() used for routine value updates |
DOM rebuild + input rebinding per update | update*Input() → rendering-ui.md |
Wide isolate()-free reads in eventReactive/observeEvent |
Invalidates more than necessary | Narrow dependencies → reactive-graph.md |
Apply the fixes in this rough order (cheapest first): data loads to global
scope → req() guards → shared reactives → tabs for heavy outputs →
bindCache() → debounce chatty inputs → update*Input() over renderUI →
faster data formats (fread/feather/DuckDB) → ExtendedTask for multi-second
operations → busy indicators (bslib::useBusyIndicators()) for remaining
waits.
3. Measure — to confirm, not to gate
Measurement is for confirming fixes and for finding what the scan can't see. It must never crowd out action. If the app is hard to run, profiling is slow, or results are ambiguous, apply the scan fixes anyway and say what couldn't be verified.
# Where does the time go? (CPU/memory profile)
p <- profvis::profvis(shiny::runApp("app.R"))
debrief::pv_print_debrief(p) # debrief turns the profvis output into text
# summaries — hot functions/lines, call paths,
# memory, suggestions — much easier to act on
# than the interactive flame graph. Follow up
# with pv_focus(), pv_hot_lines(),
# pv_suggestions(); compare before/after runs
# with pv_print_compare().
# Is implementation A faster than B?
bench::mark(A(x), B(x), check = FALSE)
Two tools in the ecosystem are for the user, not for you to run: reactlog has the user interact with their own app and explore the reactive-graph visualization to understand how their reactives interact
Установить shiny-r-optimize в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл shiny-r-optimize?
Diagnose and fix performance problems in Shiny for R apps — slow startup, sluggish interactions, long-running blocking operations, and apps that struggle beyond a handful of concurrent users. Use when a Shiny app is slow, hangs, recomputes too much, times out, or needs to support more users; when the user asks to "speed up", "optimize", or "make faster" an existing Shiny app; or when preparing a prototyped app for real-world traffic.
Как установить скилл shiny-r-optimize?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл shiny-r-optimize запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic