stata-bridge
CLAUDE.md1 starsChanged 7 months agoMITView on GitHub
项目: stata-bridge — Linux → Windows Stata 远程执行桥接 一个让你在 Linux 服务器上像调用本地 Stata 一样运行 .do 文件的工具集。 Stata 实际跑在用户 Windows 机器上(Stata/MP 17),通过 SSHFS 挂载 + 文件队列通信。 服务器 /stata/ 通过 SSHFS 挂到 Windows 某盘符(安装时选,默认 Z:\)→ 用户投 job.json 到 inbox/ → Windows agent 轮询调 StataMP-64.exe /e do ... → 结果写回 done/。原始 .dta 留 Windows 本地盘($DATA),不经网络。 为避免通过 SSHFS 上传几百 MB 的 .dta,profile.do 定义了两个全局宏:
In this repositoryOne other file it gives its agents.
- stataSkill
The file
Files
CLAUDE.md
项目: stata-bridge — Linux → Windows Stata 远程执行桥接
这是什么
一个让你在 Linux 服务器上像调用本地 Stata 一样运行 .do 文件的工具集。
Stata 实际跑在用户 Windows 机器上(Stata/MP 17),通过 SSHFS 挂载 + 文件队列通信。
自带 skill: stata
- 位置:
.claude/skills/stata/SKILL.md - 用户可通过
/stata调用做速查 - 本 CLAUDE.md 已包含跑 Stata 所需的全部知识,默认每次会话自动加载到上下文,不需要再显式调用 skill
你进入本项目后,看到 .do / Stata / 回归相关任务时,直接按下面"关键命令"走
架构一句话
服务器 /stata/ 通过 SSHFS 挂到 Windows 某盘符(安装时选,默认 Z:\)→ 用户投 job.json 到 inbox/ →
Windows agent 轮询调 StataMP-64.exe /e do ... → 结果写回 done/。原始 .dta 留 Windows 本地盘($DATA),不经网络。
关键命令速查
/stata/bin/stata-ping # 必须先 ping
/stata/bin/stata-run workspace/foo.do # 同步(主要)
/stata/bin/stata-async workspace/big.do # 异步,返回 job-id
/stata/bin/stata-status <job-id> # 查状态
/stata/bin/stata-log <job-id> --follow # tail log
/stata/bin/stata-clean --days 7 # 清旧记录重要约定
.do文件放/stata/workspace/(Windows 看到<MOUNT>:\workspace\,路径对齐)- 别手动
set processors,workspace/profile.do已自动配置多核 + 大 maxvar - 服务器没装 Stata,任何
bash -c "stata ..."都是错的,所有执行必须走/stata/bin/stata-* - 提交前先 ping,agent 挂了就提醒用户检查
StataBridgeAgentScheduled Task
双目录约定(重要)
为避免通过 SSHFS 上传几百 MB 的 .dta,profile.do 定义了两个全局宏:
| 宏 | 指向 | 用途 |
$WORK | Windows <MOUNT>:\workspace\(即 Linux /stata/workspace/) | .do / 小输出 / log,服务器和 Windows 都能看到 |
$DATA | Windows 本地盘(如 G:\stata-data),服务器看不到 | 原始 .dta 存这里,不经 SSHFS |
写 .do 的规范:
use "$DATA/big.dta", clear // 读本地盘,快
save "$WORK/output/cleaned_small.dta" // 小结果回传到桥接目录
log using "$WORK/logs/run.log", replace- 服务器上的 Claude 看不到
$DATA下的.dta原文件;需要元信息时,写个小.do跑describe/codebook/summarize把输出写到$WORK/logs/*.log,再读回文本分析。 $DATA的实际值由用户在 Windows 上通过workspace/bridge.config.do配置;模板见workspace/bridge.config.do.example。- 绝对不要建议用户把
.dta放workspace/下。
文档
README.md— 面向普通用户的使用说明WINDOWS_SETUP.md— Windows 端安装(给 Windows Claude Code)bin/stata-agent.ps1— Windows 端 agent 源码(v1.1,已打 exit_code + 原子写补丁).claude/skills/stata/SKILL.md—/stataskill 定义
调试经验(别再踩同样坑)
- Stata/MP batch 模式默认
c(processors)=1→ 用profile.do自动 set - PowerShell
Set-Content非原子 → agent v1.1 的Set-ContentAtomic已修;仍遇到exit_code:null则升级 agent(WINDOWS_SETUP.md §6.4) c(flavor)在 MP 上可能返回IC(显示 quirk),判断 MP 用c(MP)- Windows 写出的 JSON 有 UTF-8 BOM,jq 能处理,原生 Python 需
utf-8-sig - 中文变量名 +
length()/strlen()会静默卡死(batch 模式、无r(...)、agent 判定成功)。读进来立刻rename 中文 ascii消除隐患,而非在后续命令里绕
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
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.

