Agent skill · Documentation

stata-c-plugins

Develop high-performance C/C++ plugins for Stata using the stplugin.h SDK. Use when the user asks to create a Stata plugin, write C/C++ code for Stata, accelerate a Stata command with C, build cross-platform Stata plugins, or translate/port a Python or R package into Stata. Covers the full preserve/merge, cross-platform compilation, performance optimization (pthreads, pre-sorted indices, XorShift RNG), debugging, and distribution via net install. Also includes a translation workflow for porting Python/R packages to Stata — wrapping existing C++ backends when available, or writing C from scr

brycew6m878★ · +32/wk · 1 repos on radarProfile →
claude-codeNOASSERTION
Install
npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill stata-c-plugins --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 6
SKILL.md size: 23 KB
Bundled scripts: none
Path: skills/32-dylantmoore-stata-skill/plugins/stata-c-plugins/skills/stata-c-plugins/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 3,244
Language: Stata
Read our review of the source →

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

Build high-performance C/C++ plugins for Stata. This skill covers the full lifecycle from SDK setup through cross-platform distribution, based on real experience building production Stata plugins for statistical imputation, random forests, string matching, and causal inference.

This skill assumes macOS (Apple Silicon or Intel) as the development platform. Build commands, cross-compilation workflows, and Docker instructions are all Mac-oriented. The plugins themselves target all four platforms (macOS ARM64, macOS x86_64, Linux x86_64, Windows x86_64), but the development environment is macOS. If you need to develop on Linux or Windows natively, adapt the compilation and Docker sections accordingly.

How it works

  • Enter plan mode before code: create a complete inventory of features, architecture decisions, and relevant reference files (references/translation_workflow.md, references/testing_strategy.md, references/performance_patterns.md, references/packaging_and_help.md, references/cpp_plugins.md).
  • Implement sequential components in parallel where possible: C plugin, .ado wrapper, and test suite run concurrently; merge results and run a review loop after each component.
  • Run a review loop after every component with 2-3 review agents (multi-model if available). Agents review the diff, test results, and requirements, and must output gaps or issues and LGTM when correct.
  • For translations, check for an existing C/C++ backend before writing algorithms; if available, wrap it with an extern "C" glue layer; otherwise write C from scratch.
  • Provide translation workflow fidelity audits and reuse patterns from referenced documents.
  • The Plugin SDK section provides the interface between C and Stata via stplugin.h/stplugin.c and lists key API functions and 1-based indexing cautions.
  • Emphasizes memory safety: check malloc/calloc, validate argc, build with -fsanitize=address, and pre-allocate memory in stata_call().
  • Describes the stata_call() entry point including a concrete example illustrating argument parsing, data reading, computation, and writing results back via SF_vstore.
  • Includes detailed guidance for the .ado wrapper pattern, preserve/merge pattern, and the sorting contract to avoid data misalignment.
  • Cross-platform compilation tables explain target OS, output suffixes, compilers, and link flags; notes macOS-specific guidance for using -bundle and explicit cross-platform compilation steps.

When to use it

Use when the user asks to create a Stata plugin, write C/C++ code for Stata, accelerate a Stata command with C, build cross-platform Stata plugins, or translate/port a Python or R package into Stata. Also applicable when aiming for performance optimization (pthreads, pre-sorted indices, XorShift RNG), debugging, and distribution via net install.

What it can touch

The skill discusses building C/C++ plugins that interact with Stata via the stplugin.h interface, and the .ado wrapper that calls the plugin. It references cross-platform toolchains, Docker, and OS-specific build flags. It requires and references external workflows and templates in the references folder, and relies on system compilers (gcc/g++, mingw-w64) for building across platforms.

Caveats

Emphasizes that plugins must be memory-safe to avoid crashing the Stata session; stresses 1-based indexing and careful argument/data handling; warns against absolute paths in Windows loaders and encourages bare filename loading via the gtools-style pattern. Notes macOS is the assumed development platform, with cross-platform targets for distribution. License is NOASSERTION.

From the SKILL.md

# Stata C/C++ Plugin Development Build high-performance C/C++ plugins for Stata. This skill covers the full lifecycle from SDK setup through cross-platform distribution, based on real experience building production Stata plugins for statistical imputation, random forests, string matching, and causal inference. **This skill assumes macOS (Apple Silicon or Intel) as the development platform.** Build

More from Auto-Empirical-Research-Skills
All skills →
About this skill
What does the stata-c-plugins skill do?

Develop high-performance C/C++ plugins for Stata using the stplugin.h SDK. Use when the user asks to create a Stata plugin, write C/C++ code for Stata, accelerate a Stata command with C, build cross-platform Stata plugins, or translate/port a Python or R package into Stata. Covers the full preserve/merge, cross-platform compilation, performance optimization (pthreads, pre-sorted indices, XorShift RNG), debugging, and distribution via net install. Also includes a translation workflow for porting Python/R packages to Stata — wrapping existing C++ backends when available, or writing C from scr

How do I install it?

Run `npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill stata-c-plugins --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From brycewang-stanford/Auto-Empirical-Research-Skills, a repository with 3,244 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going