stata-cli

A Stata command line for agents: runs do-files, returns regression results as JSON and keeps a daemon for fast repeats.

  • 59 ★ on the repository
  • Last commit
CLI

Extended access

Why this level

  • Runs arbitrary Stata code on your machine, and Stata commands can read and write files and call the shell.
All reasons and checks

ashuigordon/stata-cli

Install

Manual install

pip install stata-cli

Requires installed Stata 17 or newer; after installing, `stata-cli detect` finds the program path.

Access and checks

How we review

Extended accessThe tool runs code or makes network calls and only reads external data.

  • Runs arbitrary Stata code on your machine, and Stata commands can read and write files and call the shell.

This is third-party code. Review the repository files before installing.

What it does

stata-cli connects the agent to the Stata the user already has installed, through PyStata. The agent runs Stata code from a string or stdin, executes `.do` files, views the dataset with a filter and row limit and reads variable metadata, stored `r()`, `e()` and `s()` results, matrices such as `e(b)` and `e(V)`, value labels and macros. Graphs export to PNG, SVG or PDF. A background daemon keeps PyStata running, cutting startup from 2 to 3 seconds to roughly 85 milliseconds. Output comes in compact mode and as JSON with exit codes, and the built-in reference covers 57 topics from syntax to causal inference. A `SKILL.md` ships in the box, so Codex, Claude Code and Cursor drive Stata without extra setup.

Who it is for. Economists and social scientists doing empirical research in Stata who want an agent to run, check and chart analyses.

Good fit when

  • The agent runs a series of regressions and reads coefficients and the variance matrix as structured data.
  • You need to open a `.do` file, run it and export graphs without launching the Stata shell.
  • Repeated queries on the same data should answer in a fraction of a second.
  • Before writing a command you want to consult the Stata reference for syntax.

Not a fit when

  • There is no licensed Stata 17 or newer on the machine.
  • The analysis runs in R or Python without Stata.
  • Running someone else's `.do` files without reading them: Stata commands can reach the system.

Example request

Load the auto dataset, regress price on mpg and weight and return the coefficients and R-squared as JSON.

Limitations

A licensed Stata 17 or newer and Python 3.9 or newer are required: the tool does not include Stata. The program path is detected automatically, and a non-standard install is set with `stata-cli config set stata-path`. The npm version is a thin wrapper over `uvx`, `pipx` or `python3`, so Python is still required. Settings live in `~/.stata-cli/config.json` and graphs go to `~/.stata-cli/graphs/` by default.

How to disable. Stop the daemon with `stata-cli daemon stop`, remove the package with `pip uninstall stata-cli` and delete the `~/.stata-cli` directory.

FAQ

How do I install stata-cli?

Run `pip install stata-cli`. The zero-setup variant is `npx stata-cli run "display 1+1"`. After installing, run `stata-cli detect` to check the Stata path.

Why use the daemon?

It keeps PyStata running so repeated queries take roughly 85 milliseconds instead of 2 to 3 seconds. Start it with `stata-cli daemon start`.

How do I get estimation results as JSON?

The `--json` flag turns on structured output, `stata-cli return e` returns stored `e()` results and `stata-cli matrix e(b)` returns the coefficient matrix.

Where are graphs saved?

They export automatically as PNG, SVG or PDF into `~/.stata-cli/graphs/`.

Can I stop a long command?

Yes, the tool has interruption: it sends a break signal to the running Stata command.

Discussion

No questions or reviews yet.

CLI tools

An MCP server that lets an agent run local Stata: regressions, econometrics, replicating computations from papers

MCP serverExtended access276Repository stars

stata-code runs Stata from Claude Code and Cursor: DiD, IV and RDD, esttab tables and a compact result format.

MCP serverExtended access55Repository stars

Barrios Skills: 46 skills for economists and accountants covering Stata, R, panel data, WRDS, EDGAR, charts and academic writing

SkillExtended access68Repository stars

17 skills for economists: research ideas, literature review, Stata and R, LaTeX models, tables and Beamer slides

SkillExtended access672Repository stars

The CLI imports CSV and JSON into SQLite, runs SQL and reshapes tables for agent-assisted local data preparation.

CLIExtended access2.2KRepository stars

README in short

The author positions the tool as an agent-native command line for empirical research: structured JSON, exit codes and a ready skill definition. Install paths, commands, daemon mode and advanced usage are described.

README badge

Report a problem