Write, repair, refactor and run Stata research do-files. Trace actual failures to their source, apply verified readability improvements, and preserve the caller and research outputs.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Stata Replication Workflow?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/plokies-2-stata-replication-workflow)
---
name: stata-replication-workflow
description: Write, repair, refactor and run Stata research do-files. Trace actual failures to their source, apply verified readability improvements, and preserve the caller and research outputs.
---
# Stata Research Workflow
Apply the relevant [writing rules](references/general-rules.md) while preserving results, presentation and the calling interface. Before editing, scan for execution or masked errors, wrong group scope in recursions, cumulative calculations or ranks, reversed coding or bounds, mismatched parallel calculations, undefined macros or references, positional lookups and returns from the wrong fit. Fix a bug even if results change when the code uniquely specifies the replacement. For an affected research or display value, cite its definition or consumer that establishes the intended replacement. If your evidence identifies a problem but leaves the intended value open, keep the behavior and propose a change.
Keep the code as written and propose a change when another interpretation is plausible or the edit changes one of these choices:
- **Caller contract.** Prepare test data and startup settings in the verification run. Propose adding or uncommenting `use ..., clear` or `profile.do`, changing directory or log scope, requiring a program option or forcing an ado path.
- **Research choices.** Propose changes to samples, denominators, aggregation units or statistics such as `(first)` to `(firstnm)`, missing values and timing, tie handling, cutoffs, baselines, weights and model specifications.
- **Storage and presentation.** Propose changing storage types, display formats, labels or wording, graph settings, row order, table columns, caller-visible names or return values, and existing `quietly`.
Write so the researcher can follow which observations enter each calculation, what it computes and where its result goes. Use the actual inputs, callers and output consumers to decide what to simplify. Keep distinct specifications, samples and inference visible, and protect source data and baselines.
Before finishing, check that the edit preserves the expected results and report how you checked, using a method that fits the project, such as running the original entry point, exercising the changed block or comparing saved results.
`scripts/stata-equivalence.cjs` is available for comparing original and edited runs in isolated copies. Use OS temporary space for verification copies and logs. Remove any verification files and directories created in the project before replying.
## References
- Use [command evidence](references/command-evidence.md) for material new or changed command interfaces. A minimal lookup for a known command is `{"request":"Read the changed estout output interface","selected_commands":["estout"]}`. For a paper example, read the [connected original code](references/paper-workflow-reading.md).
- See [execution and results](references/execution-and-results.md) for runner choice and saved results, [descriptive outputs](references/descriptive-outputs.md) for tables and figures, and the [worked examples](references/code-examples.md) for implementation choices.
- See [workflow taxonomy](references/workflow-taxonomy.md) for how to organize maintained do-files, [project workflows](references/project-workflows.md) for whole-project setup, and [codebook](references/codebook.md) and [README](references/readme-contract.md) for those deliverables.
- Use [stata-peer-audit](../stata-peer-audit/SKILL.md) for independent advice when requested or when another perspective could resolve a concrete question about data, sample, specification or results.
## Editing and hook feedback
Use a targeted edit for the maintained do-file. Keep a flagged repair only if it meets the bug rule above. Otherwise restore the behavior and propose the change.
The plugin's hook sends an edited-region reminder right after the first `.do` edit made with `apply_patch`, `Edit` or `Write` in a turn. If you made such an edit and no reminder arrived, the hooks did not run; Codex skips plugin hooks until they are trusted again after each plugin update. Say so in the final reply, ask the user to trust the stata-research-guard hooks (Codex: Settings → Hooks), and run `node hooks/stata-repeats.cjs` and `node hooks/stata-align.cjs` from the plugin root on the edited files yourself.
Read and follow the [reporting format](references/after-editing.md) for every final reply, including its required “Points to confirm” section (“확인할 점” in Korean) when no edit is needed.