stata-skill-contributo…
Guide for contributing to the stata-skill project. Use when the user wants to run the eval pipeline, analyze test results,…
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.
Claude Code
$ npx -y skills add dylantmoore/stata-skill --skill stata-c-plugins --agent claude-code
Codex
$ npx skills add dylantmoore/stata-skill --skill stata-c-plugins -a codex -y
Cursor
$ npx skills add dylantmoore/stata-skill --skill stata-c-plugins -a cursor -y
Gemini CLI
$ npx skills add dylantmoore/stata-skill --skill stata-c-plugins -a gemini-cli -y
GitHub Copilot
$ npx skills add dylantmoore/stata-skill --skill stata-c-plugins -a github-copilot -y
OpenCode
$ npx skills add dylantmoore/stata-skill --skill stata-c-plugins -a opencode -y
Windsurf
$ npx skills add dylantmoore/stata-skill --skill stata-c-plugins -a windsurf -y
name: stata-c-plugins description: >- 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 lifecycle: SDK setup, data flow, memory safety, .ado wrappers with 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 scratch when not.
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.
**Before writing any code, enter plan mode.** A good plan covers:
1. **Complete inventory** — every feature, option, and component to build (for translation: exhaustive catalog of the source package's API) 2. **Architecture decisions** — wrap C++ backend vs. write C from scratch vs. pure Stata 3. **Relevant reference files** — identify up front which of this skill's reference files contain info you'll need, and cite them explicitly in the plan steps so they get loaded at the right time:
4. **Phase-by-phase steps** with dependencies between them 5. **For each step:** what gets built, what tests get written, and that the review loop runs before proceeding 6. **For translation projects:** a final fidelity audit as the last step (see `translation_workflow.md`)
**Implement sequentially across components, in parallel within each component.** Once an interface is defined, dispatch independent sub-tasks as parallel subagents (e.g., C plugin implementation, .ado wrapper, and test suite can run simultaneously). Merge their work, run the full test suite, then proceed to the review loop before moving to the next component.
**Run the review loop after every component:**
**When translating a package, always check for an existing C/C++ backend before writing any algorithm code.** Many R packages have C++ in `src/`. Many Python packages have Cython or vendored C/C++ libraries. Standalone C++ libraries exist for string matching, linear algebra, tree algorithms, and more.
**If a C++ implementation exists, wrap it.** Do not reimplement the algorithm in C. Wrapping gives you identical output (same code path), production-grade performance, and a fraction of the code. The plugin is just a thin `extern "C"` glue layer between Stata's SDK and the library's API. Binary size is irrelevant — statically link everything (`-static-libstdc++ -static-libgcc`) and ship whatever size the binary turns out to be, even 10-15 MB on Windows. Users don't care about plugin file size; they care about correct results.
See `references/cpp_plugins.md` for the full pattern and `references/translation_workflow.md` for the workflow. Working examples of this approach (wrapping C++ backends, multi-plugin dispatching, save/load for scoring on new data) can be found in the repos listed in the project CLAUDE.md under "Example Applications."
For translation projects, also: repurpose the original package's test suite and data (see `references/testing_strategy.md` Layer 0), write additional Stata-specific tests, and end the plan with a multi-agent fidelity audit. See `references/translation_workflow.md` for the complete workflow.
Download `stplugin.h` and `stplugin.c` from: https://www.stata.com/plugins/
These two files define the interface between your C code and Stata:
| Function/Macro | Purpose | |---------------|---------| | `SF_vdata(var, obs, &val)` | Read variable value (1-indexed!) | | `SF_vstore(var, obs, val)` | Write variable value (1-indexed!) | | `SF_nobs()` | Number of observations in current dataset | | `SF_nvar()` | Number of variables in the **entire dataset** (not just plugin call) | | `SF_is_missing(val)` | Check for Stata missing value (`.`) | | `SV_missval` | The missing value constant
This project contains two Claude Code skills: Stata — A comprehensive reference that tells Claude how to use Stata. Covers core syntax, data management, econometrics, causal inference, graphics, and 20+ community packages.
Guide for contributing to the stata-skill project. Use when the user wants to run the eval pipeline, analyze test results,…
Comprehensive Stata reference for writing correct .do files, data management, econometrics, causal inference, graphics, Mata…
SciPilot Skills 家族成员,负责科研数据可视化——但定位不是"画图工具", 而是"可视化顾问"。先做数据剖析(列类型/样本量/分布/异常值/分组结构/相关性), 再结合用户的论证目标推荐图型,主动拦截科研画图的经典错误(小样本画均值柱掩盖…
Build or review source-backed descriptive, diagnostic, predictive, and prescriptive analysis for consequential decisions. Use…
Build cost-safe geospatial SQL for BigQuery, DuckDB, Snowflake, Wherobots, and Postgres and/or render results on an interactive…
Patterns for data loading, exploration, and statistical analysis