add-rcpp-integration
Add Rcpp or RcppArmadillo integration to an R package for high-performance C++ code.
Skill by Philipp Thoss
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/pjt222-add-rcpp-integration
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing, writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/add-rcpp-integration
Tools it pre-approves 6
From allowed-tools in SKILL.md: the agent may use these without asking you each time.
ReadWriteEditBashGrepGlob
What's inside
- Skill name
add-rcpp-integration- Description
- Add Rcpp or RcppArmadillo integration to an R package for high-performance C++ code. Covers setup, writing C++ functions, RcppExports generation, testing compiled code, and debugging. Use when an R function is too slow and profiling confirms a bottleneck, when you need to interface with existing C/C++ libraries, or when implementing algorithms (loops, recursion, linear algebra) that benefit from compiled code.
- License
- MIT
- Allowed tools
- Read, Write, Edit, Bash, Grep, Glob
- Metadata
- tags: r, rcpp, cpp, performance, compiled-code · author: Philipp Thoss · domain: r-packages · version: 1.0 · language: R · complexity: advanced
- Instructions
- 192 lines in SKILL.md · view on GitHub
Before installing
- Pre-approves any shell command
Files (1)
- SKILL.md
SKILL.md (first lines)
# 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
```r
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:
```r
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`:
```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:
```cpp
#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;
}
```
**Got:** C++ source file exists at `src/my_function.cpp` with valid `// [[Rcpp::export]]` annotation and roxygen-style `//'` documentation comments.
**If fail:** Verify the file uses `#include <Rcpp.h>` (or `<RcppArmadillo.h>` for Armadillo), that the export annotation is on its own line directly above the function signature, and that return types map to valid Rcpp types.
### Step 3: Generate RcppExports
```r
Rcpp::compileAttributes()
devtools::document()
```
**Got:** `R/RcppExports.R` and `src/RcppExports.cpp` generated automatically.
**If fail:** Check C++ syntax errors. Ensure `// [[Rcpp::export]]` tag is present above each exported function.
### Step 4: Verify Compilation
```r
devtools::load_all()
```
**Got:** Package compiles and loads without errors.
**If fail:** Check compiler output for errors. Common issues:
- Missing system headers: Install development libraries
- Syntax errors: C++ compiler messages point to the line
- Missing `Rcpp::depends` attribute for RcppArmadillo
### Step 5: Write Tests for Compiled Code
```r
test_that("cumsum_cpp matches base R", {
x <- c(1, 2, 3, 4, 5)
expect_equal(cumsum_cpp(x), cumsum(x))From pjt222/agent-almanac, MIT.
More from pjt222/agent-almanac
- 0.616score
adaptic
Philipp Thoss
Master skill composing the 5-step synoptic cycle for panoramic synthesis across multiple domains.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
add-puzzle-type
Philipp Thoss
Scaffold a new puzzle type across all 10+ pipeline integration points in jigsawR.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
aikido
Philipp Thoss
Practice aikido as a defensive martial art emphasizing harmony, redirection, and controlled resolution.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-codebase-for-mcp
Philipp Thoss
Analyze an arbitrary codebase to identify functions, APIs, and data sources suitable for exposure as MCP tools, producing a tool specification document.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-codebase-workflow
Philipp Thoss
Analyze an arbitrary codebase to auto-detect workflows, data pipelines, and file dependencies using putior's put_auto() engine.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-diffusion-dynamics
Philipp Thoss
Analyze the dynamics of diffusion processes using stochastic differential equations, Fokker-Planck equations, first-passage time distributions, and parameter…
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-generative-diffusion-model
Philipp Thoss
Analyze pre-trained generative diffusion models (Stable Diffusion, DALL-E, Flux) by computing quality metrics (FID, IS, CLIP score, precision/recall)…
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-kernel-bottleneck
Philipp Thoss
Systematically identify whether a GPU kernel is compute-bound, memory-bound, or latency-bound using roofline analysis, occupancy calculations, compute/load…
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-magnetic-field
Philipp Thoss
Calculate and visualize magnetic fields produced by current distributions using the Biot-Savart law, Ampere's law, and magnetic dipole approximations.
SkillBFreshness: B★ 42Claude Code - 0.616score
analyze-magnetic-levitation
Philipp Thoss
Analyze magnetic levitation systems by applying Earnshaw's theorem to determine whether passive static levitation is possible, then identifying the…
SkillBFreshness: B★ 42Claude Code - 0.616score
analyze-prime-numbers
Philipp Thoss
Analyze prime numbers using primality tests, factorization algorithms, prime distribution analysis, and sieve methods.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
adapt-architecture
Philipp Thoss
Execute structural metamorphosis using strangler fig migration, chrysalis phases, and interface preservation.
SkillBFreshness: B★ 42Claude Code +9
Signals
- Stars
- 42
- Forks
- 5
- Open issues
- 182
- Last commit (this folder)
- Aug 17, 2026 (2 months ago)
- Last release
- Aug 26, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 1.0
- License
- MIT
- Repository
- github.com/pjt222/agent-almanac
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Philipp Thoss
- 0.616score
adaptic
Philipp Thoss
Master skill composing the 5-step synoptic cycle for panoramic synthesis across multiple domains.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
add-puzzle-type
Philipp Thoss
Scaffold a new puzzle type across all 10+ pipeline integration points in jigsawR.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
aikido
Philipp Thoss
Practice aikido as a defensive martial art emphasizing harmony, redirection, and controlled resolution.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-codebase-for-mcp
Philipp Thoss
Analyze an arbitrary codebase to identify functions, APIs, and data sources suitable for exposure as MCP tools, producing a tool specification document.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-codebase-workflow
Philipp Thoss
Analyze an arbitrary codebase to auto-detect workflows, data pipelines, and file dependencies using putior's put_auto() engine.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
adapt-architecture
Philipp Thoss
Execute structural metamorphosis using strangler fig migration, chrysalis phases, and interface preservation.
SkillBFreshness: B★ 42Claude Code +9
Cite this page
add-rcpp-integration skill. Agent Mart. https://agentmart.dev/skills/pjt222-add-rcpp-integration (last updated 2026-10-24)