add-rcpp-integration

add-rcpp-integration is a skill for Claude Code from pjt222/agent-almanac. It costs 93 tokens per session (1,843 once invoked), scanned B, original, MIT.

A workflow for adding Rcpp or RcppArmadillo to an R package so selected functions can run as compiled C++ code. R is a programming language for statistics and data analysis; Rcpp connects it with C++.

In plain words
What is it for?
Use it to replace slow R functions, add compiled algorithms, connect to C++ libraries, use Armadillo for linear algebra, and test or debug the compiled code.
Why use it?
It helps address confirmed performance bottlenecks in R and reuse existing C or C++ libraries. It also covers the package setup and generated bindings needed for the languages to work together.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the agent-almanac plugin — 122 skills, 76 agents shipped together

Good fit Use it to replace slow R functions, add compiled algorithms, connect to C++ libraries, use Armadillo for linear algebra, and test or debug the compiled code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/pjt222/agent-almanac/add-rcpp-integration
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add pjt222/agent-almanac --skill add-rcpp-integration
Clone the repo
git clone --depth 1 https://github.com/pjt222/agent-almanac

Made for: Claude Code.

Or install agent-almanac, the plugin that ships this one along with the rest of its 122 skills, 76 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for add-rcpp-integration

README.md
[![agentmods](https://agentmods.dev/badge/skills/pjt222/agent-almanac/add-rcpp-integration/github.svg)](https://agentmods.dev/skills/pjt222/agent-almanac/add-rcpp-integration)
Your own site
<a href="https://agentmods.dev/skills/pjt222/agent-almanac/add-rcpp-integration"><img src="https://agentmods.dev/badge/skills/pjt222/agent-almanac/add-rcpp-integration/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for add-rcpp-integration

Your own site · 80×15
<a href="https://agentmods.dev/skills/pjt222/agent-almanac/add-rcpp-integration"><img src="https://agentmods.dev/badge/skills/pjt222/agent-almanac/add-rcpp-integration.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 93 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,843 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 2 findings, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Tool Misuse · line 170
    Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
    Fix: Validate all tool parameters against an allowlist. Reject dangerous parameter values (shell=True, --force, -rf /) and use safe defaults.
  • high Anti-Refusal · line 195
    Skill instructs the agent to omit warnings, disclaimers, or ethical commentary. Stripping safety caveats hides risk from the user and is a common jailbreak preamble.
    Fix: Remove instructions that suppress warnings, disclaimers, or ethical commentary. Let the agent surface safety-relevant caveats to the user.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00093 $0.01843
Opus 5 $0.00046 $0.00922
Sonnet 5 $0.00019 $0.00369
Haiku 4.5 $0.00009 $0.00184

Measured 6d ago against content hash 3995a65796f4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade B, and why

add-rcpp-integration scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Strips warnings and disclaimersmediumAnti-refusal

Omitting safety caveats hides risk from the user and is a common jailbreak preamble.

- [ ] `devtools::load_all()` compiles without warnings
i18n/caveman-lite/skills/add-rcpp-integration/SKILL.md · 217 lines

How it starts

The opening of the file, as written. The whole thing — 217 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Add Rcpp Integration

Integrate C++ code into an R package using Rcpp for performance-critical operations.

When to Use

  • R function is too slow and profiling confirms a bottleneck
  • Need to interface with existing C/C++ libraries
  • Implementing algorithms that benefit from compiled code (loops, recursion)
  • Adding RcppArmadillo for linear algebra operations

Inputs

  • Required: Existing R package
  • Required: R function to replace or augment with C++
  • Optional: External C++ library to interface with
  • Optional: Whether to use RcppArmadillo (default: plain Rcpp)

Procedure

Step 1: Set Up Rcpp Infrastructure

usethis::use_rcpp()

This:

  • Creates src/ directory
  • Adds Rcpp to LinkingTo and Imports in DESCRIPTION
  • Creates R/packagename-package.R with @useDynLib and @importFrom Rcpp sourceCpp
  • Updates .gitignore for compiled files

For RcppArmadillo:

usethis::use_rcpp_armadillo()

Got: src/ directory created, DESCRIPTION updated with Rcpp in LinkingTo and Imports, and R/packagename-package.R contains @useDynLib directive.

If fail: If usethis::use_rcpp() fails, manually create src/, add LinkingTo: Rcpp and Imports: Rcpp to DESCRIPTION, and add #' @useDynLib packagename, .registration = TRUE and #' @importFrom Rcpp sourceCpp to the package-level documentation file.

Step 2: Write C++ Function

Create src/my_function.cpp:

#include <Rcpp.h>
using namespace Rcpp;

//' Compute cumulative sum efficiently
//'
//' @param x A numeric vector
//' @return A numeric vector of cumulative sums
//' @export
// [[Rcpp::export]]
NumericVector cumsum_cpp(NumericVector x) {
  int n = x.size();
  NumericVector out(n);
  out[0] = x[0];
  for (int i = 1; i < n; i++) {
    out[i] = out[i - 1] + x[i];
  }
  return out;
}

For RcppArmadillo:

#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]

//' Matrix multiplication using Armadillo
//'
//' @param A A numeric matrix
//' @param B A numeric matrix
//' @return The matrix product A * B
//' @export
// [[Rcpp::export]]
arma::mat mat_mult(const arma::mat& A, const arma::mat& B) {
  return A * B;
}

Read the full file on GitHub · 217 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 217 lines · 93 tokens per session scan B 3995a65796f4

Subscribe to this mod's changes

add-rcpp-integration is a skill published in the GitHub repository pjt222/agent-almanac (32 stars, last pushed today), licensed MIT. It adds 93 tokens to every session and 1,843 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it B with 1 finding (strips warnings and disclaimers). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

coding-guidance-cpp

C++ implementation and review guidance for modern ownership, type safety, API design, and tests; use coding-guidance-qt when QObject lifetime, signals and slots, QWidget/model-view behavior, Qt threading, or Qt build tooling is the main concern. Portable across C++17/20/23 repositories and build systems.

n-n-code/n-n-code-skills · 72 tokens

coding-guidance-qt

Qt C++ implementation and review guidance for QObject, QWidget/model-view, signals and slots, thread affinity, .ui forms, and Qt build tooling; use coding-guidance-cpp for non-Qt C++ design. Portable across Qt5/Qt6 repositories with a QWidget desktop focus.

n-n-code/n-n-code-skills · 67 tokens

zephyr-json

JSON serialization and deserialization in Zephyr RTOS using the descriptor-based JSON library. Use when encoding C structs to JSON strings, parsing JSON into C structs, working with nested objects or arrays, handling cloud/IoT protocols (MQTT, HTTP, CoAP payloads), or implementing REST APIs on embedded devices.

ksachdeva/zephyr-rtos-ai · 68 tokens

gdb

Debug and trace C/C++/Rust programs with the GNU Debugger (GDB) without blocking the agent. Use when you need to set tracepoints, inspect variables, or monitor a running process while staying responsive to the user.

betab0t/skills · 50 tokens

cuopt-numerical-optimization-api

LP, MILP, and QP (beta) with cuOpt — Python, C, and CLI. Use when the user is solving LP, MILP, or QP with any cuOpt interface.

NVIDIA/skills · 51 tokens

authoring-go-sdk-tasks

Writes Airflow task logic in Go using the Airflow Go SDK. Use when the user wants to implement Airflow tasks in Go, asks about BundleProvider/RegisterDags, the bundlev1 Registry/Dag interfaces, registering Go tasks (AddTask/AddTaskWithName), dependency injection by parameter type (context.Context, sdk.TIRunContext…

astronomer/agents · 165 tokens