From fgcz-infrastructure
Autonomous R Markdown and Python report rendering with self-correcting validation. Use when asked to render an Rmd or Python report, debug a rendering failure, or submit a report rendering job. Triggers on: render, knit, rmarkdown::render, SBATCH render, render report, fix rendering error, re-render. Encodes a retry-and-validate loop that fixes common errors (S4 objects, missing packages, barcode mismatches, plot failures) without asking the user for guidance.
How this skill is triggered — by the user, by Claude, or both
Slash command
/fgcz-infrastructure:autonomous-renderThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Render R Markdown or Python reports autonomously with a validate-and-retry loop.
Render R Markdown or Python reports autonomously with a validate-and-retry loop. The goal is to collapse multi-round debugging sessions into a single invocation by self-correcting common failures.
Key principle: Do NOT ask the user for guidance between iterations. Fix issues using your judgment and only report back when done or after exhausting retries.
Before rendering, read the full Rmd/py file and identify:
.qs2, .h5ad, .rds, paths)Sample, CellType_Harmonized_Detailed, etc.).qs2 caching? Which cache files exist already?Create a mental checklist of what "success" looks like for this report.
Before rendering, verify prerequisites exist:
# Check input files exist
ls -la /path/to/input_data.qs2
# Check required packages are available
Rscript -e 'stopifnot(requireNamespace("Seurat")); stopifnot(requireNamespace("qs2"))'
# For Python reports
python -c "import scanpy; import anndata"
# Check working directory has enough disk space
df -h /srv/GT/analysis/pXXXXX/
If any prerequisite is missing, fix it before rendering (install package, correct path, etc.).
module load Dev/R/4.5.0
cd /srv/GT/analysis/pXXXXX/
Rscript -e "rmarkdown::render('report.Rmd')"
Use or adapt the existing SBATCH script if one exists (SBATCH_render_*.sh).
Otherwise create one following the CLAUDE.md template:
#!/bin/bash
#SBATCH --job-name=pXXXXX_render
#SBATCH --output=/srv/GT/analysis/pXXXXX/render_%j.log
#SBATCH --error=/srv/GT/analysis/pXXXXX/render_%j.err
#SBATCH --time=04:00:00
#SBATCH --mem-per-cpu=8G
#SBATCH --cpus-per-task=8
#SBATCH --partition=employee
module load Dev/R/4.5.0
cd /srv/GT/analysis/pXXXXX/
Rscript -e "rmarkdown::render('report.Rmd')"
echo "Completed at $(date)"
After submitting, monitor with:
squeue -u $USER # Check if running
sacct -j JOBID --format=JobID,State,ExitCode,MaxRSS,Elapsed # After completion
After rendering completes (or fails), check in this order:
# For SBATCH jobs
cat /srv/GT/analysis/pXXXXX/render_JOBID.err | tail -50
cat /srv/GT/analysis/pXXXXX/render_JOBID.log | tail -50
# For local rendering — error is inline
| Error pattern | Likely cause | Fix |
|---|---|---|
cannot open the connection / No such file | Wrong input path | Verify path exists, check for typos |
object 'X' not found | Variable not defined in scope | Check chunk execution order, missing include=FALSE chunk |
no slot of name "X" / is not a valid slot | S4 object API change (Seurat v5) | Use class() and str() to inspect, use modern accessor |
cannot coerce class 'Assay5' | Seurat v5 layer issue | Add JoinLayers() before the operation |
Error in loadNamespace / there is no package | Missing R package | pak::pkg_install("pkg") |
cannot allocate vector of size | Out of memory | Increase --mem-per-cpu or add gc() calls |
Column 'X' not found / Unknown column | Metadata column missing or renamed | Check colnames([email protected]), fix column name |
Column 'X' already exists | Duplicate metadata column | Remove duplicate before adding |
DimReduc umap not found | UMAP not computed | Add RunUMAP() step |
non-unique values when setting 'row.names' | Duplicate chunk labels in Rmd | Find and rename duplicate chunk labels |
viewport may be too small | coord_fixed() with patchwork | Replace with theme(aspect.ratio = 1) |
package 'X' was installed under R version Y | R version mismatch | Reinstall package with current R |
After successful rendering, validate the HTML output:
# HTML exists and is non-trivial
ls -la report.html
wc -c report.html # Should be >100KB for most reports
# Check for R warnings/errors embedded in HTML
grep -c "Error in\|error:\|Warning:" render_JOBID.log
# Count plot images in HTML (base64 encoded PNGs)
grep -co 'data:image/png;base64' report.html
# Check for NA/NULL text that suggests data issues
grep -c '>NA<\|>NULL<\|>NaN<' report.html
If the Rmd loads a Seurat object, verify key metrics match expectations:
If validation fails, trace back to the data loading/filtering logic, fix, and re-render.
After successful rendering and validation:
Report summary to user:
If user wants to deliver to gStore, use:
g-req copynow /srv/GT/analysis/pXXXXX/report.html /srv/gstore/projects/pXXXXX/Analyses_Paul/
Then provide the web link:
https://fgcz-sushi.uzh.ch/projects/pXXXXX/Analyses_Paul/report.html
--no-verify or skip any safety checksnpx claudepluginhub cpanse/skills --plugin fgcz-infrastructureProvides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.