Back to Skills

build-parameterized-report

pjt222
Updated 6 days ago
18 views
17
2
17
View on GitHub
Metaautomationdesign

About

This skill enables developers to create parameterized Quarto or R Markdown reports that generate multiple variations from a single template. It covers defining parameters, programmatic rendering, and batch generation for automated workflows. Use it for producing department-specific reports, client-customized outputs, or automating recurring reports with different inputs.

Quick Install

Claude Code

Recommended
Primary
npx skills add pjt222/agent-almanac -a claude-code
Plugin CommandAlternative
/plugin add https://github.com/pjt222/agent-almanac
Git CloneAlternative
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/build-parameterized-report

Copy and paste this command in Claude Code to install this skill

Documentation

建參報

造受參之報,自一模生多客變。

  • 為異部、域、期生同報
  • 自模造客專報
  • 建濾於具子之儀
  • 自定期報附異入

  • :報模(Quarto 或 R Markdown)
  • :參定(名、類、默)
  • :批生之參值列
  • :生報之出目

一:YAML 定參

Quarto(report.qmd):

---
title: "Sales Report: `r params$region`"
params:
  region: "North America"
  year: 2025
  include_forecast: true
format:
  html:
    toc: true
---

R Markdown(report.Rmd):

---
title: "Sales Report"
params:
  region: "North America"
  year: 2025
  include_forecast: true
output: html_document
---

得: YAML 頭含 params: 塊附名參,各有正類默值。

敗: 渲敗報「object 'params' not found」→確 params: 塊於 YAML 首縮對。Quarto params 必於 YAML 頂,非 format: 下嵌。

二:碼中用參

```{r}
#| label: filter-data

data <- full_dataset |>
  filter(region == params$region, year == params$year)

nrow(data)
```

## Overview for `r params$region`

This report covers the `r params$region` region for `r params$year`.

```{r}
#| label: forecast
#| eval: !expr params$include_forecast

# This chunk only runs when include_forecast is TRUE
forecast_model <- forecast::auto.arima(data$sales)
forecast::autoplot(forecast_model)
```

得: 碼塊以 params$name 引參,條塊以 Quarto #| eval: !expr params$flag。行內 R 表如 `r params$region` 渲動文。

敗: params$name 返 NULL→驗參名於 YAML 與碼全合(區大小)。察默值類正。

三:以客參渲

單渲:

# Quarto
quarto::quarto_render(
  "report.qmd",
  execute_params = list(region = "Europe", year = 2025)
)

# R Markdown
rmarkdown::render(
  "report.Rmd",
  params = list(region = "Europe", year = 2025),
  output_file = "report-europe-2025.html"
)

得: 單報以客參值成渲,覆 YAML 默。出檔於所述徑造。

敗: Quarto 渲敗→察 quarto CLI 已裝且於 PATH。R Markdown 敗→驗 rmarkdown 已裝。確參名於 execute_params(Quarto)或 params(R Markdown)合 YAML 定。

四:批渲多報

regions <- c("North America", "Europe", "Asia Pacific", "Latin America")
years <- c(2024, 2025)

# Generate all combinations
combinations <- expand.grid(region = regions, year = years, stringsAsFactors = FALSE)

# Render each
purrr::pwalk(combinations, function(region, year) {
  output_name <- sprintf("report-%s-%d.html",
    tolower(gsub(" ", "-", region)), year)

  quarto::quarto_render(
    "report.qmd",
    execute_params = list(region = region, year = year),
    output_file = output_name
  )
})

得: 每域年組一 HTML。

敗: 察參名於 YAML 與碼全合。確諸參值有效。

五:加參驗

#| label: validate-params

stopifnot(
  "Region must be a valid region" = params$region %in% valid_regions,
  "Year must be numeric" = is.numeric(params$year),
  "Year must be reasonable" = params$year >= 2020 && params$year <= 2030
)

得: 驗碼塊於每渲始行,若參出範或類誤則以清誤止。

敗: stopifnot() 生無益訊→換顯 if (!cond) stop("message") 呼以清診。

六:組出

# Create output directory
output_dir <- file.path("reports", format(Sys.Date(), "%Y-%m"))
dir.create(output_dir, recursive = TRUE, showWarnings = FALSE)

# Render with output path
quarto::quarto_render(
  "report.qmd",
  execute_params = list(region = region),
  output_file = file.path(output_dir, paste0("report-", region, ".html"))
)

得: 出檔書於日戳子目附述名(如 reports/2025-06/report-europe.html)。

敗: dir.create() 敗→察父目存且可書。Windows 上驗徑長不過 260 字。

  • 報以默參渲
  • 報以每組客參渲
  • 參處前驗
  • 出檔命述
  • 條段依參正渲
  • 批生於諸組完

  • 參名不合:YAML 名必全合碼 params$name
  • 類強轉:YAML 或解 year: 2025 為整,而碼候字元。必顯。
  • 條評:Quarto 用 #| eval: !expr params$flag,非 eval = params$flag
  • 檔覆:無唯出名→每渲覆前
  • 批記:久批或積記。宜用 callr::r() 為隔。

  • create-quarto-report — 基 Quarto 文設
  • generate-statistical-tables — 適參之表
  • format-apa-report — 參化學術報

GitHub Repository

pjt222/agent-almanac
Path: i18n/wenyan-ultra/skills/build-parameterized-report
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

Related Skills

content-collections

Meta

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

View skill

polymarket

Meta

This skill enables developers to build applications with the Polymarket prediction markets platform, including API integration for trading and market data. It also provides real-time data streaming via WebSocket to monitor live trades and market activity. Use it for implementing trading strategies or creating tools that process live market updates.

View skill

creating-opencode-plugins

Meta

This skill helps developers create OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It provides the plugin structure, event API specifications, and implementation patterns for JavaScript/TypeScript modules. Use it when you need to intercept, monitor, or extend the OpenCode AI assistant's lifecycle with custom event-driven logic.

View skill

sglang

Meta

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

View skill