Install any skill in seconds. Free to start, no credit card required.
Get Started Free →brycewang-stanford/stata-c-plugins
Develop high-performance C/C++ plugins for Stata using the stplugin.h SDK.
Passed 20 of 23 test cases with the skill, and 14 of 23 without it.
and 5 more in the full report
6 fixed14 passed either way3 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 6 test cases the skill fixed. Same model, same prompt, with and without the skill.
We are setting up a Docker environment on macOS to compile Linux plugin binaries for Stata. To ensure the compiled shared library runs on older Linux HPC clusters with GLIBC 2.14+, which Ubuntu release should we specify for the build container?
| Checked | Without skill | With skill |
|---|---|---|
| Specifies Ubuntu 18.04 Docker image | Missed | Passed |
The instructions your model reads when the skill loads.
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:
references/translation_workflow.md — full translation workflow, test repurposing, fidelity auditreferences/testing_strategy.md — test layers, reference data generation, Layer 0 (repurpose original tests)references/performance_patterns.md — pthreads, XorShift RNG, quickselect, pre-sorted indicesreferences/packaging_and_help.md — .toc/.pkg/.sthlp templates, build scriptsreferences/cpp_plugins.md — C++ wrapping, extern "C", exception safety, compilationtranslation_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.
test cases passed, vs 14 / 23 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.