agentleFS
niuniu-869niuniu-869/stata-bridge/.claude/skills/stata/SKILL.md

stata

Skill1 starsChanged 7 months agoMITView on GitHub

Execute Stata .do files on a remote Windows machine via the stata-bridge (SSHFS + file queue). Use whenever the user wants to run Stata code, debug a .do file, run a regression, clean data in Stata, check Stata job status, or tail a Stata log. Also triggers when user mentions Stata commands (regress, reghdfe, xtreg, etc.) or opens a .do file in /stata/workspace/.

3 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions3 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 3

    1. luischanci/claude-code-research-starter★ 1same name
    2. Ricardo-kui/claude-skills★ 0same name
    3. snitkin/claude-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repositoryOne other file it gives its agents.

The file

Files
SKILL.md

Stata Skill

跑 Stata 的唯一通道。本服务器没装 Stata,必须通过 /stata/bin/stata-* 把 .do 派发到用户 Windows 机器执行。

详细上下文已在 /stata/CLAUDE.md 预加载,本文件是 /stata 调用时的速查。

双目录约定(必读)

宏放什么服务器可见?
$WORK(= /stata/workspace/).do / 日志 / 小结果✅
$DATA(Windows 本地盘)原始 .dta❌

写 .do 时永远用宏:

use   "$DATA/big.dta", clear
use   "$DATA/project-a/wave1.dta", clear               // 子目录 OK
use   "$DATA/hudonge and analyst/coverage.dta", clear  // 空格 / 中文 OK,记得加引号
save  "$WORK/output/cleaned.dta", replace
log   using "$WORK/logs/run.log", replace

* 读进来第一件事:把中文变量名重命名为 ascii(避免 length() 卡死,见"禁止"节 B1)
rename 股票代码 stkcode
rename year     yr

列 $DATA 下有哪些数据(batch 安全,不用 shell):

local subs : dir "$DATA" dirs "*"
foreach s of local subs {
    local fs : dir "$DATA/`s'" files "*.dta"
    foreach f of local fs  display "`s'/`f'"
}

一分钟速用

# 1. 先 ping,确认 Windows agent 活着
/stata/bin/stata-ping

# 2. 写 .do 到 workspace/(不要加 set processors,profile.do 已自动)
cat > /stata/workspace/my.do <<'EOF'
use "$DATA/data.dta", clear
reg y x1 x2
EOF

# 3. 同步执行(迭代首选)
/stata/bin/stata-run workspace/my.do --tail 80

# 4. 长作业改异步
JOB=$(/stata/bin/stata-async workspace/big.do --timeout 14400)
/stata/bin/stata-log $JOB --follow

调试循环

  1. Read 当前 .do
  2. Edit 改动
  3. stata-run file.do --tail 60
  4. 看 log 尾部找 r(XXX); 错误行
  5. GOTO 2

我要"看看数据长啥样"怎么办

服务器读不到 .dta 原文。写一个探查 .do,让 Stata 把元信息写到 $WORK/logs/ 下,我再 Read 文本:

log using "$WORK/logs/_describe.log", text replace
use "$DATA/target.dta", clear
describe
codebook, compact
summarize
list in 1/20
log close

Exit code

code含义行动
0成功✅
4agent 失联提醒用户查 Scheduled Task
5超时用 stata-status 继续观察
10Stata r(...) 错误读 log 定位错误行
11Windows 进程非 0看 log + agent 日志
12result.json 解析失败罕见,重试

禁止

  • ❌ bash -c "stata ..." — 服务器没装 Stata
  • ❌ use "workspace/foo.dta" 或 Windows 绝对路径 — 用 $DATA / $WORK
  • ❌ 建议用户把 .dta 放 workspace/ —— 几百 MB 走 SSHFS 会很慢
  • ❌ 在 .do 里加 set processors N — profile.do 已接管
  • ❌ 直接动 .bridge/running/ 文件
  • ❌ 对中文变量名调 length() / strlen() — 本仓库实测会静默卡死(Stata 17 MP,batch 模式下无 r(...)、agent 汇报 has_stata_error=false、timed_out=false、exit_code=null,但 log 从该命令后再无输出)。第一步先 rename 股票代码 stkcode 成 ascii,之后再用任何字符串函数

常见错误码

r(XXX);含义
111variable not found
198syntax error
601file not found(常因 $DATA 未配置,检查 workspace/bridge.config.do)
2000no observations
430convergence not achieved

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.