xiaohongshu
xiaohongshu
r-anti-slop
Enforce production-quality R code standards. Prevents generic AI patterns through namespace qualification, explicit returns, and tidyverse conventions. Use when writing or reviewing R code for data analysis or packages.
Full skill instructions
df <- dataUse this for:
df, result, missing ::)Skip for:
Before (AI Slop):
# Load the library
library(dplyr)
# Read the data
df <- read.csv("data.csv")
# Filter the data
result <- df %>% filter(x > 0)
After (Anti-Slop):
customer_data <- readr::read_csv("data/customers.csv")
active_customers <- customer_data |>
dplyr::filter(status == "active", revenue > 0)
return(active_customers)
What changed:
customer_data not df)dplyr::, readr::)|> not %>%)| If you need to... | Do this | Details |
|---|---|---|
| Name variables | Use snake_case, no df/data/result | reference/naming.md |
| Call tidyverse functions | Always use :: (e.g., dplyr::filter()) | reference/tidyverse.md |
| Return from function | Always explicit return() statement | reference/naming.md |
| Write pipe chains | Use |>, break at 8+ operations | reference/tidyverse.md |
| Document functions | Specific @param, @return, no circular text | reference/documentation.md |
| Handle missing data | Explicit strategy + report data loss | reference/statistical-rigor.md |
| Validate data | Check assumptions with stopifnot() | reference/statistical-rigor.md |
| Format code | Use styler::style_file() | reference/tidyverse.md |
| Check code quality | Use lintr::lint() | reference/tidyverse.md |
Namespace qualification - All external functions use ::
# Good
dplyr::filter(data, x > 0)
# Bad
filter(data, x > 0)
Explicit returns - Every function has return()
# Good
my_function <- function(x) {
result <- x + 1
return(result)
}
# Bad
my_function <- function(x) {
x + 1
}
Naming conventions - All objects use snake_case
# Good
customer_lifetime_value <- calculate_clv(data)
# Bad
df <- calculate_clv(data)
customerLifetimeValue <- calculate_clv(data)
Documentation quality - No generic descriptions
# Good
#' @param deaths Data frame with `age_group` and `count` columns
# Bad
#' @param data The data
Code formatting - Run styler and lintr
styler::style_file("script.R")
lintr::lint("script.R")
Before committing R code, verify:
::return()snake_casedf, data, result, temp)|>) have space before, end linesattach() calls->)Context: AI generated an analysis script with generic patterns.
Steps:
Run detection script
Rscript toolkit/scripts/detect_slop.R analysis.R --verbose
Fix high-priority issues first
# Replace df, data, result with descriptive names
# Before
df <- readr::read_csv("data.csv")
result <- df %>% filter(x > 0)
# After
customer_data <- readr::read_csv("data/customers.csv")
active_customers <- customer_data |> dplyr::filter(status == "active")
Add namespace qualification
# Before
data %>% filter(x > 0) %>% summarize(mean(y))
# After
data |>
dplyr::filter(x > 0) |>
dplyr::summarize(mean_y = mean(y))
Add explicit returns
# Before
calculate_rate <- function(numerator, denominator) {
numerator / denominator
}
# After
calculate_rate <- function(numerator, denominator) {
rate <- numerator / denominator
return(rate)
}
Break long pipes
# Before (12 operations in one chain)
result <- data |>
filter(...) |> mutate(...) |> group_by(...) |>
summarize(...) |> arrange(...) |> [7 more ops]
# After
clean_data <- data |>
dplyr::filter(!is.na(value)) |>
dplyr::mutate(category = categorize(value))
summary_stats <- clean_data |>
dplyr::group_by(category) |>
dplyr::summarize(mean_val = mean(value))
Format and validate
styler::style_file("analysis.R")
lintr::lint("analysis.R")
Expected outcome: Score drops from 60+ to <20
Context: R package has generic roxygen documentation.
Steps:
Identify generic patterns
# Bad
#' Process Data
#'
#' @description This function processes the data.
#' @param data The data.
#' @return The result.
Make description specific
# Good
#' Calculate age-adjusted mortality rates
#'
#' Computes mortality rates per 100,000 population, standardized to the
#' 2000 US Census age distribution using direct standardization.
Describe parameter structure
# Good
#' @param deaths Data frame with columns `age_group` and `count`.
#' @param population Data frame with columns `age_group` and `pop_size`.
Specify return value
# Good
#' @return A tibble with columns:
#' \describe{
#' \item{county}{County FIPS code}
#' \item{rate}{Age-adjusted rate per 100,000}
#' \item{se}{Standard error of the rate}
#' }
Add realistic examples
# Good
#' @examples
#' counties <- data.frame(
#' county = c("A", "B"),
#' deaths = c(150, 200),
#' population = c(50000, 80000)
#' )
#'
#' adjust_rates(counties, rate_per = 100000)
#' #> # A tibble: 2 x 3
#' #> county rate se
#' #> 1 A 312. 25.4
#' #> 2 B 258. 18.2
Expected outcome: Documentation that teaches, not restates
Context: Final checks before CRAN submission.
Steps:
Run all quality checks
# Standard checks
devtools::check()
# Anti-slop checks
lapply(list.files("R", full.names = TRUE), function(f) {
system(paste("Rscript toolkit/scripts/detect_slop.R", f))
})
Fix documentation
@param descriptions are specific@examples run and are realistic@return describes structureValidate code quality
# Format all files
styler::style_dir("R/")
# Check lints
lintr::lint_package()
Check CRAN-specific requirements
Expected outcome: Clean R CMD check with no slop patterns
ALWAYS use :: for external packages
Exceptions (don't need ::):
mean(), sum(), log(), etc.lm(), glm(), t.test(), etc.head(), tail(), str(), etc.ALWAYS use return() - never implicit
All objects use snake_case
customer_data not customerData or dfcalculate_rate not calculateRateinput_data not inputDataPrefer |> over %>% (unless R < 4.1)
Never use: df, data, result, temp, x, n (except standard math notation)
Follow Tidyverse Style Guide as primary reference:
See reference/tidyverse.md for complete tidyverse conventions.
styler::style_file() - Auto-format codelintr::lint() - Check code qualityRscript toolkit/scripts/detect_slop.R - Detect AI patternsThis skill focuses on code quality and avoiding generic patterns.
Use together with Posit skills for complete coverage:
| Task | Use This Skill | + Posit Skill |
|---|---|---|
| Write error messages | r/anti-slop (quality) | + r-lib/cli (structure) |
| Write tests | r/anti-slop (code quality) | + r-lib/testing (test patterns) |
| Prepare for CRAN | r/anti-slop (no slop) | + r-lib/cran-extrachecks (requirements) |
| Document lifecycle | r/anti-slop (doc quality) | + r-lib/lifecycle (deprecation) |
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience