build-parameterized-report
关于
This skill enables developers to create parameterized Quarto or R Markdown reports that can be programmatically rendered with different inputs for batch generation. It's designed for automating customized reports for different clients, departments, or data subsets from a single template. Key capabilities include defining parameters, programmatic rendering, and automating recurring reports with varying inputs.
快速安装
Claude Code
推荐npx 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/build-parameterized-report在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Build Parameterized Report
Create reports that accept parameters to generate multiple customized variations from single template.
When Use
- Generating same report for different departments, regions, time periods
- Creating client-specific reports from template
- Building dashboards filtering to specific subsets
- Automating recurring reports with different inputs
Inputs
- Required: Report template (Quarto or R Markdown)
- Required: Parameter definitions (names, types, defaults)
- Optional: List of parameter values for batch generation
- Optional: Output directory for generated reports
Steps
Step 1: Define Parameters in YAML
For Quarto (report.qmd):
---
title: "Sales Report: `r params$region`"
params:
region: "North America"
year: 2025
include_forecast: true
format:
html:
toc: true
---
For R Markdown (report.Rmd):
---
title: "Sales Report"
params:
region: "North America"
year: 2025
include_forecast: true
output: html_document
---
Got: YAML header contains params: block with named parameters, each having default value of correct type.
If fail: Rendering fails with "object 'params' not found"? Ensure params: block correctly indented under YAML frontmatter. For Quarto, params must be at top level of YAML, not nested under format:.
Step 2: Use Parameters in Code
```{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)
```
Got: Code chunks reference parameters via params$name. Conditional chunks use #| eval: !expr params$flag for Quarto. Inline R expressions like `r params$region` render dynamic text.
If fail: params$name returns NULL? Verify parameter name matches exactly between YAML definition and code reference (case-sensitive). Check default values correct type.
Step 3: Render with Custom Parameters
Single render:
# 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"
)
Got: Single report renders successfully with custom parameter values overriding YAML defaults. Output file created at specified path.
If fail: Quarto render fails? Check quarto CLI installed and on PATH. R Markdown render fails? Verify rmarkdown installed. Ensure parameter names in execute_params (Quarto) or params (R Markdown) match YAML definitions exactly.
Step 4: Batch Render Multiple Reports
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
)
})
Got: One HTML file per region-year combination.
If fail: Check parameter names match exactly between YAML and code. Ensure all parameter values valid.
Step 5: Add Parameter Validation
#| 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
)
Got: Validation code chunk runs at start of each render, stops with informative error if any parameter out of range or wrong type.
If fail: stopifnot() produces unhelpful error messages? Switch to explicit if (!cond) stop("message") calls for clearer diagnostics.
Step 6: Organize Output
# 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"))
)
Got: Output files written to date-stamped subdirectory with descriptive names (e.g., reports/2025-06/report-europe.html).
If fail: dir.create() fails? Check parent directory exists and is writable. On Windows, verify path length does not exceed 260 characters.
Checks
- Report renders with default parameters
- Report renders with each set of custom parameters
- Parameters validated before processing
- Output files named descriptively
- Conditional sections render correctly based on parameters
- Batch generation completes for all combinations
Pitfalls
- Parameter name mismatch: YAML names must exactly match
params$namereferences in code - Type coercion: YAML may parse
year: 2025as integer but code expects character. Be explicit. - Conditional evaluation: Use
#| eval: !expr params$flagnoteval = params$flagin Quarto - File overwriting: Without unique output names, each render overwrites previous
- Memory in batch mode: Long batch runs may accumulate memory. Consider using
callr::r()for isolation.
See Also
create-quarto-report- base Quarto document setupgenerate-statistical-tables- tables that adapt to parametersformat-apa-report- parameterized academic reports
GitHub 仓库
相关推荐技能
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是理想选择。
