Skip to content

📖 《把 AI 当助手——经济实证研究的诚信、方法与工具》双语网页版:每章中文部在前,English Edition 在后,内容与最新合订 PDF 一致。

第1章 · 开发环境搭建与 AI 协作基础 ​

1.1 AI IDE 生态全景与选型 ​

集成开发环境(IDE)是程序员的核心工作工具。回顾 IDE 的发展历程,可以大致分为三个阶段:

第一阶段:编辑器时代(1980s–2000s)。以 Vim、Emacs 为代表,程序员需要手动配置语法高亮、编译命令和调试流程,学习曲线陡峭但高度可定制。

第二阶段:传统 IDE 时代(2000s–2022)。以 Eclipse、Visual Studio、IntelliJ IDEA 为代表,IDE 集成了代码补全、语法检查、调试器、版本控制等功能,极大提升了开发效率。但这一阶段的代码补全本质上是基于规则的模式匹配——它只能根据已输入的字符推测可能的补全项,无法理解代码的语义和上下文。

第三阶段:AI IDE 时代(2023 至今)。大语言模型(LLM)的突破催生了全新的 IDE 形态——AI IDE。与传统 IDE 的根本区别在于:AI IDE 内嵌了具有代码理解能力的大模型,不仅能补全代码,还能理解需求、生成项目、调试错误、重构代码。AI IDE 将程序员的角色从"逐行编写代码"转变为"描述需求 + 审核 AI 产出",开发范式发生了根本性变革。

主流 AI IDE 对比 ​

当前市场上的 AI IDE 产品众多,以下从经济类专业学生和研究者的实际需求出发,对主流产品进行对比分析:

表 1.1 主流 AI IDE 对比。

L6|L6|L6|L6|L6|L6

对比维度 & TRAE & Qoder & Cursor & CodeBuddy & Windsurf
模型支持 & 豆包系列 & 通义+Claude & Claude+GPT & 腾讯混元 & Claude+GPT
MCP 支持 & 支持 & 支持 & 支持 & 支持 & 支持
Skill 支持 & 有限 & 丰富 & 有限 & 丰富 & 有限
定价 & 免费 & 付费 & 付费 & 试用后付费 & 付费
中文支持 & 优秀 & 优秀 & 一般 & 优秀 & 一般
国内访问 & 直接 & 直接 & 需加速 & 直接 & 需加速\

[本手册推荐] 本手册以 TRAE 和 Qoder 为主要教学 AI IDE。TRAE 完全免费、中文界面友好、Builder 和 SOLO 模式适合教学演示;Qoder Skill 生态更丰富,适合深入研究。两者可混用,核心概念和操作逻辑相通。

下载地址:

本表信息截至 2026 年 9 月。AI IDE 市场变化极快,实际选择请以各产品官网最新信息为准;15 款工具的完整口碑对比报告(价格、市场动态与风险案例,2026-09-27 重新抓取)见附录 H。

选型逻辑:推荐理由、已知缺陷与版本管理 ​

为什么是 TRAE + Qoder。两款工具都直接国内访问、都支持 MCP 协议(附录 E 的学术 MCP 矩阵在两个平台上都能运行):

  • TRAE:基础版免费、无调用次数限制,零成本起步;中文原生界面降低操作门槛;trae是国内增长最快的 AI IDE 之一。

  • Qoder:2026 年 7 月发布的 IDC 报告显示,其以 47.6% 的份额居中国 AI Coding 市场第一(智谱 CodeGeeX 11.5%、商汤 Raccoon 10.5%、腾讯 CodeBuddy 7% 分列二至四位),迭代速度与生态规模有保障;Skill 体系与本手册的工具矩阵(附录 E)天然契合;「先列 to-do 规划、再逐步执行」的交互模式,恰好训练「先想清楚再动手」的研究习惯。

但它们并非没有缺点——这份缺陷清单正是本手册反复强调版本管理的现实理由(完整案例见附录 H.4):

  • TRAE:快照回退功能有丢代码的公开案例(2026 年 6 月官方论坛仍有「回退后记录消失」的新反馈);普通对话模式的上下文长度偏短,长周期论文项目容易「失忆」——让它做大改动前,务必先提交一版 Git 快照。

  • Qoder:Credits 消耗规律不完全透明,重度任务额度消耗快;2026 年 6 月有用户反馈重启后模型被自动切回 Auto 的 BUG。

  • 行业共性风险:各家 AI IDE 的 Agent 都可能在未经确认的情况下删改文件

[为什么必须配合 CNB 做版本管理?] 上面的缺陷清单指向同一个结论:AI 写得快,删得也快。Git 版本控制是唯一对各家工具都有效的「保险丝」——每次提交都是一个可回退的快照,AI wu删坏的任何文件都能一键还原;版本历史同时是研究过程的自动留痕,答辩时能证明工作是逐步完成的(呼应第 0 章研究环)。平台选 CNB(cnb.cool):国内直连速度快、微信扫码注册、公开仓库免费,学生无需任何网络加速(CNB 是什么,见 §1.2 装机步骤后的绿框提示;注册与推送全流程见附录 G)。

配合 AI IDE 的 CNB 管理五技巧(按重要性排序):

  1. 改前存档:让 AI 执行重构、批量修改等「大动作」之前,先 git add . 并 git commit——AI 改坏任何文件,都能用 git checkout 还原到改动之前;

  2. 小步提交:每完成一个产出物(一张表、一节分析)就提交一次,commit message 写清楚「做了什么」(如「问卷清洗 v1:剔除 183 个无效样本」)——三个月后你会感谢这些备注;

  3. .gitignore 铁律:原始数据(.dta、.csv)、密钥文件(API token)、编译中间文件一律不进仓库;

  4. 章末推送:每章产出物(research_question.md 等,清单见附录 C)推送到 CNB——一个学期下来,云端自然沉淀出一份完整的研究档案,电脑坏了也不会丢;

  5. 回退三板斧:出问题时 git status(看改了什么)→ git diff(看具体差异)→ git log(找到想回到的版本号)。

1.2 环境配置:让 AI 帮你装机 ​

第一步:安装并登录 AI IDE ​

从 §1.1 的下载地址安装 TRAE 或 Qoder 后,首次启动需要登录:

TRAE 登录流程:

  1. 首次启动会看到中文登录界面

  2. 选择「手机号登录」,输入手机号获取验证码

  3. 登录后进入首页,选择 Code 模式(代码开发专属界面)

  4. 可以跳过 VS Code 配置导入步骤(新手推荐)

  5. 进入代码编辑界面后,左侧能看到 Builder、文件树等菜单

Qoder 登录流程:

  1. 首次启动会看到登录界面

  2. 支持手机号、邮箱等多种登录方式

  3. 登录后进入主界面,左侧是文件树,右侧是 AI 对话区

[提示] TRAE 和 Qoder 都是免费的,用学校邮箱或手机号注册即可。登录后可以同步你的生成记录和配置。

第二步:复制这段提示词,让 AI 自动装机 ​

装好并登录 TRAE 或 Qoder 之后,不需要自己手动装其他工具。把下面这段提示词完整复制粘贴到 AI 对话框里,它会自动检测你的系统、安装缺失的软件、配置好所有环境,最后告诉你"全部就绪"。

复制这段提示词,粘贴到 AI 对话框 ​

你好!我正在按照《AI辅助经济研究学生自学手册》搭建研究环境。请你帮我完成以下工作:

1. 检测我的操作系统(macOS 还是 Windows)
2. 逐项检查以下工具是否已安装,未安装的帮我安装:
   - Python 3.12+
   - Node.js 20 LTS(选 LTS 版,不要选 Current)
   - Git
   - 包管理器(macOS: Homebrew / Windows: winget)
   - uv(Python 包管理器,极快)
   - gh(GitHub CLI,用于 PR/Issue 管理)
   - pandoc(文档格式转换)
   - Zotero 10.0+(文献管理)
   - Stata 18(如果已安装)

3. 对于每个工具,执行版本检查命令并报告结果:
   - python3 --version(应显示 3.12.x 或更高)
   - node --version(应显示 v20.x.x)
   - git --version
   - uv --version
   - gh --version
   - pandoc --version
   - zotero --version(如果支持命令行)
4. 配置 Zotero CLI 工具:
   - 安装 cli-anything-zotero:pip install cli-anything
   - 验证安装:cli-anything-zotero --help
   - 如果 Zotero 数据目录不在默认位置,帮我配置路径

5. 配置 Stata MCP(如果 Stata 已安装):
   - 检查 Stata 安装路径
   - 配置 MCP 服务器 endpoint:http://localhost:4000
   - 测试连接:curl http://localhost:4000/health

6. 配置 Git 和 CNB 远程仓库:
   - 检查 git 全局配置(user.name, user.email)
   - 如果未配置,提示我设置
   - 帮我理解如何添加 CNB 远程仓库(cnb.cool)
7. 创建项目目录结构(如果尚未创建):
   research-project/
   ├── data/           # 原始数据(不进 git)
   ├── do/             # Stata do 文件
   ├── output/         # 回归结果、图表
   ├── docs/           # 文档、笔记
   ├── references/     # 参考文献 PDF
   └── README.md

8. 生成环境检查报告:
   - 列出所有已安装工具及版本(✓ 标记)
   - 列出未安装或版本不符的工具(✗ 标记)
   - 提供手动安装命令或下载链接
   - 给出下一步操作建议

注意事项:
- macOS 用户:使用 Homebrew 安装(brew install ...)
- Windows 用户:
  - 优先使用 winget(winget install ...)
  - 如果 winget 不可用,提供官网下载链接
  - 所有命令行操作需要在管理员权限的终端中执行
- 如何打开管理员终端:右键点击屏幕左下角「开始」按钮
  → 选择「终端(管理员)」或「Windows PowerShell(管理员)」
- 如果遇到权限问题或网络问题,请告诉我具体怎么解决

做完后你应该看到:AI 逐项报告检查结果,大部分显示 ✅。如果有某项显示 ❌,AI 会告诉你怎么手动处理——通常是网络问题或权限问题,按提示操作即可。

[什么是 CNB?] CNB(cnb.cool)是国内版 GitHub——代码托管平台。注册只需微信扫码,国内访问速度快,公开仓库免费。详细操作见附录 G。

[Windows 用户] 提示词中的"winget"是 Windows 的包管理器,需要手动安装。

winget 安装方法:

  1. 打开 Microsoft Store(开始菜单搜索 "Microsoft Store")

  2. 搜索 "App Installer" 并安装(这是微软官方的安装器,包含 winget)

  3. 安装完成后重启终端,输入 winget --version 验证

备选方法(如果 Microsoft Store 不可用):

Stata 命令行链接在 Windows 上需要手动加 PATH——AI 会一步步教你。 如果 winget 不可用,AI 会改用官网下载方式安装。

官网下载备选方案(适用于所有 Windows 版本):

进阶:配置 Stata MCP(让 AI 直接操作 Stata) ​

Stata MCP 是一个让 AI 能直接运行 Stata 代码的桥接服务。配置后,你可以在 AI 对话框中直接要求"帮我跑一个面板数据固定效应回归",AI 会自动生成代码并执行。

两种方案对比:

表 1.2 进阶:配置 Stata MCP(让 AI 直接操作 Stata)。

L3|L3|L3

特性 & hanlulong/stata-mcp & SepineTam/mcp-for-stata
类型 & VS Code 扩展(localhost HTTP) & 独立 MCP Server + CLI
适用客户端 & 需 IDE 窗口活动 & 所有 MCP 客户端
执行方式 & IDE 内嵌 via localhost:4000 & do 文件 via subprocess
安装方式 & VS Code 市场搜索 DeepEcon.stata-mcp & uvx stata-mcp install --all
最佳场景 & 在 IDE 中编写运行 Stata & Agent 驱动分析\

推荐方案:hanlulong/stata-mcp(VS Code 扩展版),安装简单,与 TRAE/Qoder 集成度高。

安装步骤:

  1. 在 TRAE/Qoder 的扩展市场搜索 DeepEcon.stata-mcp

  2. 点击安装

  3. 配置 MCP 服务器(见下方两种方式,任选其一)

方式一:让 AI 自动配置(推荐,零手工)

安装扩展后,直接在 AI 对话框中粘贴以下提示词(AI 能理解英文指令,直接复制即可):

AI 会自动读取你的 MCP 配置文件、写入正确的 endpoint、并提醒你重启客户端。无需手动编辑 JSON 文件。

方式二:手工配置 MCP(适合想了解原理的同学)

打开 AI IDE 的 MCP 配置文件(TRAE/Qoder:设置 → MCP → 编辑配置),添加以下内容:

macOS 配置:

"stata-mcp": {
  "command": "uvx",
  "args": ["stata-mcp"],
  "env": {
    "STATA_PATH": "/Applications/Stata/StataMP.app/Contents/MacOS/stata-mp",
    "MCP_STATA_LOGLEVEL": "INFO"
  }
}

Windows 配置:

"stata-mcp": {
  "command": "uvx",
  "args": ["stata-mcp"],
  "env": {
    "STATA_PATH": "C:\\Program Files\\Stata18\\StataMP-64.exe",
    "MCP_STATA_LOGLEVEL": "INFO"
  }
}

[重要] STATA_PATH 必须与你本机 Stata 的实际安装路径一致!

查找 Stata 路径:

  • macOS:右键点击 Stata 应用 → 显示包内容 → Contents/MacOS/stata-mp

  • Windows:通常为 C:\Program Files\Stata18\StataMP-64.exe

MCP 工具清单(配置后 AI 可使用的 3 个工具):

  • stata_run_selection — 运行选中的 Stata 代码片段

  • stata_run_file — 运行整个 .do 文件

  • stata_session — 会话管理(list / destroy)

使用示例(在 AI 对话框中输入,基于 Stata 自带数据,无需额外数据文件):

端点地址(hanlulong 方案):

表 1.3 端点 / 协议 / 用途速查表。

端点协议用途
http://localhost:4000/mcp-streamableStreamable HTTP首选(现代客户端)
http://localhost:4000/mcpSSE旧版兼容
http://localhost:4000/healthHTTP GET健康检查

快捷键:

表 1.4 操作 / Mac / Win/Linux速查表。

操作MacWin/Linux
运行选中代码Cmd+Shift+EnterCtrl+Shift+Enter
运行整个 .do 文件Cmd+Shift+DCtrl+Shift+D
停止执行Cmd+Shift+CCtrl+Shift+C

SepineTam 方案安装(适用于 Agent 驱动分析场景):

# 一键安装所有客户端
uvx stata-mcp install --all

# 单客户端安装示例
uvx stata-mcp install -c claude
uvx stata-mcp install -c cursor

# 环境检查
uvx stata-mcp doctor

故障排除:

表 1.5 问题 / 解决方案速查表。

问题解决方案
服务未启动检查状态栏是否显示 "Stata";执行 curl http://localhost:4000/health
端口冲突修改 stata-vscode.mcpServerPort 设置
Stata 未找到手动设置 stata-vscode.stataPath 指向安装目录
UV 安装失败手动运行 curl -LsSf https://astral.sh/uv/install.sh | sh
输出截断调整 maxOutputTokens(0 = 无限制)
MCP 工具未出现重启 IDE/客户端(MCP 工具列表不会在同一会话中刷新)

[提示] 如果以上命令不理解,直接在 AI 对话框中输入:帮我安装 UV 包管理器 或 帮我解决 stata-mcp 连接问题,AI 会自动诊断并处理。

进阶:无 Stata 环境的 Python 替代方案 ​

若暂无 Stata 环境,可用 Python + statsmodels 实现相同功能:

import pandas as pd
import statsmodels.formula.api as smf

# 读取 Stata 数据
df = pd.read_stata("data/bank_panel.dta")

# OLS 回归(聚类稳健标准误)
model = smf.ols(
    "roe ~ npl_ratio + car + loan_growth + np.log(asset)",
    data=df
).fit(cov_type="cluster", cov_kwds={"groups": df["bank_id"]})

print(model.summary())

1.3 LaTeX 学术排版环境 ​

在经济学学术界,LaTeX 是论文写作的事实标准。掌握 LaTeX 对经济类专业学生有三重价值:

  • 学术论文或图书排版:国内外很多图书和期刊(如 Journal of Finance、《经济研究》、《金融研究》)均要求或推荐 LaTeX 投稿。LaTeX 的公式排版、参考文献管理、交叉引用等功能远超 Word。

安装步骤 ​

Windows:安装 MiKTeX(推荐)

  1. 访问 https://miktex.org/download,下载 Basic MiKTeX Installer(约 230 MB)

  2. 运行安装程序,选择"Install for current user"(无需管理员权限)

  3. 安装完成后打开 MiKTeX Console → Settings → 将"Install missing packages"设为 Always

macOS:安装 MacTeX

# 方式一:通过 Homebrew(推荐)
brew install --cask mactex

# 方式二:清华镜像手动下载(约 7 GB,国内速度快)
curl -L -o /tmp/mactex.pkg \
  "https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/mac/mactex/mactex-20260324.pkg"
sudo installer -pkg /tmp/mactex.pkg -target /

验证安装(Windows / macOS 通用)

xelatex --version   # 应输出 XeTeX 版本信息
biber --version     # 应输出 biber 版本号

测试中文编译

新建 test.tex,写入:

\documentclass{ctexart}
\begin{document}
你好,LaTeX!如果中文正常显示,环境配置成功。
\end{document}

终端执行 xelatex test.tex,生成 PDF 且中文正常即可。

[提示] MiKTeX 首次编译会自动下载缺失宏包(如 ctex 系列),弹出提示点击 Install 即可。首次耗时约 1–2 分钟,后续约 5–10 秒。macOS 使用 MacTeX 则无需额外下载,已包含全部宏包。

实战演练:Stata 回归 → LaTeX 表格 → PDF ​

安装好 LaTeX 环境后,你可以用 AI 一键完成「跑回归 → 导出 LaTeX 表格 → 编译 PDF」的完整流程。以下为实际运行记录。

第一步:在 AI 对话框中输入提示词

第二步:AI 自动执行 Stata 回归

AI 通过 stata-mcp 自动运行以下 Stata 命令:

webuse auto, clear
summarize price mpg weight foreign

输出:

    Variable |        Obs   Mean    Std. dev.       Min        Max
-------------+----------------------------------------------------
       price |         74   6165.26   2949.50       3291      15906
         mpg |         74   21.30     5.79          12         41
      weight |         74   3019.46   777.19       1760       4840
     foreign |         74   0.30      0.46           0          1

运行两列回归:

gen ln_price = ln(price)
gen weight_foreign = weight * foreign
quietly reg ln_price mpg weight foreign, robust
estimates store m1
quietly reg ln_price mpg weight foreign weight_foreign, robust
estimates store m2

第三步:esttab 导出 LaTeX 表格

esttab m1 m2 using reg_table.tex, replace \
  style(tex) booktabs b(4) se(4) \
  star(* 0.10 ** 0.05 *** 0.01) \
  r2 ar2 scalar(F N) \
  mtitles("OLS" "Interaction")

esttab 会自动生成一个完整的 LaTeX 表格文件(reg_table.tex),包含 booktabs 三线表、显著性星号、标准误和模型拟合指标。

第四步:编译生成 PDF

在终端执行:

xelatex auto_reg_demo.tex

即可生成包含回归表格和结果解读的 PDF 文件。

最终效果:完整的回归分析报告,包含描述统计表、两列回归对比表(OLS vs 交乘项)、以及结果解读。整个流程从提示词到 PDF,AI 全程自动完成——这就是 MCP + LaTeX 的协作闭环。

1.4 AI 协作四模式详解 ​

现代 AI IDE 通常提供多种 AI 协作模式,理解每种模式的特点和适用场景,是高效利用 AI 的前提。本节以 TRAE 为例详解四种模式,其他 AI IDE 的逻辑类似。

IDE 模式:传统编码 + AI 辅助补全 ​

工作方式:在编辑器中正常编写代码,AI 在光标位置提供行内补全建议(类似手机输入法的联想功能)。按 Tab 键接受建议,按 Esc 键忽略。

典型场景:

  • 编写重复性代码(如批量定义变量、生成样板代码)

  • 补全函数签名和参数

  • 根据注释生成代码片段

Chat 模式:问答式交互 ​

工作方式:在侧边栏的聊天窗口中与 AI 对话,AI 仅以文字回答,不会直接修改代码文件。这是最安全的模式,适合学习理解阶段。

典型场景:

  • 理解概念:"什么是 SARIMA 模型的季节性差分?"

  • 解释代码:"这段 pandas 代码的 groupby 操作做了什么?"

  • 排查错误:"这个 ImportError 是什么原因?"

  • 对比方案:"ARIMA 和 LSTM 在时间序列预测中各有什么优劣?"

Builder 模式:AI 直接操作文件系统 ​

工作方式:AI 可以直接创建、修改、删除文件,并在终端中执行命令。这是生产力最高的模式,也是风险较高的模式。

典型场景:

  • 从零生成项目:"做一个贪吃蛇网页"

  • 批量修改文件:"把所有 Python 文件的 import 语句按字母排序"

  • 安装依赖并运行:"安装 flask 并启动开发服务器"

[安全提醒] Builder 模式下 AI 可以直接操作文件系统,存在误删文件或执行危险命令的风险。建议:

  • 重要项目务必使用 Git 版本控制,出错可以回退

  • 初学者优先使用 Chat 模式理解问题,再切换 Builder 模式执行

  • 不要在含有重要数据的目录中使用 SOLO 模式

SOLO 模式:全自主开发 ​

工作方式:SOLO 模式下 AI 拥有最大自主权,它会自行规划任务、分解步骤、创建子 Agent、执行操作。界面通常为三栏布局:左侧任务计划、中间代码编辑、右侧预览/终端。

典型场景:

  • 快速原型验证:"帮我搭建一个银行客户管理系统的原型"

  • 零代码开发:只描述需求,完全依赖 AI 生成

四模式对比 ​

表 1.6 四模式对比。

L4|L4|L4|L4

模式 & AI 权限 & 风险等级 & 适用场景
IDE & 行内补全 & 低 & 日常编码
Chat & 仅回答 & 最低 & 学习理解
Builder & 读写文件 + 执行命令 & 中 & 项目生成
SOLO & 全自主操作 & 高 & 快速原型\

1.5 三范式认知地图:MCP / Skill / CLI 各管什么 ​

装机之前,先搞懂一个关键问题:为什么需要三类不同的 AI 工具?它们各管什么?

本手册把 AI 辅助研究的工具分为三个层次。你可以把它想象成一个人:MCP 是感官(接收信息),Skill 是大脑里的知识(知道怎么做),CLI 是双手(执行动作)。

如果你更熟悉金融工作场景,也可以这样理解:MCP 像 Bloomberg 终端(拿数据),Skill 像投资研究框架(知道怎么分析),CLI 像 Excel 和 Word(输出报告)。

三范式对比表 ​

表 1.7 三范式对比表。

L4|L4|L4|L4

维度 & MCP(连接层) & Skill(知识层) & CLI(执行层)
本质 & Model Context Protocol,连接协议 & 领域知识文件(Markdown 格式 SOP) & Shell 命令行工具
比喻 & AI 的"USB-C 接口"——插上就能读数据 & AI 的"操作手册"——教它标准流程 & AI 的"双手"——直接操作文件和数据
形态 & JSON-RPC Server(后台运行) & SKILL.md 文件(纯文本) & 可执行程序(终端调用)
开发成本 & 高(需写 Server 代码) & 低(写 Markdown 即可) & 零(用现成工具)
适合场景 & 对接外部 API / 数据库 & 知识复用、流程标准化 & 本地文件操作、批处理
典型应用 & tushareMcp 拉 A 股面板数据 & stata Skill 指导 OLS→FE→RE & officecli 输出回归表格到 Word\

黄金组合 ​

三者不是互斥的,而是协同的:

MCP(拿到数据)+ Skill(知道怎么做)+ CLI(执行动作)= 完整研究自动化链

一个具体场景:假设你要做"银行治理结构与 ROE"的实证研究——

  1. MCP 拿数据:用 tushareMcp 拉 100 家上市银行 5 年财务数据

  2. Skill 指导分析:stata skill 告诉 AI 该跑 OLS → FE → RE 三模型对照

  3. CLI 输出结果:officecli 把回归表格写入 Word,直接交给导师

现在你不需要记住每个工具的名字——后面各章会逐一展开。这里只需建立"三层分工"的认知框架:连接 → 知识 → 执行。

1.6 标准研究文件夹:五目录结构 ​

做研究最怕什么?不是模型跑不通,而是文件乱到找不到。三个月前的数据放在哪个文件夹?那张回归表格是第几版?日志文件呢?

从现在开始,所有研究项目都用统一的五目录结构。这不是形式主义——它是可复现性的物理保障。

目录模板 ​

my_research_project/
+-- data/
|   +-- raw/          <- 原始数据(只读!永不修改!)
|   +-- clean/        <- 清洗后数据(由 code/ 脚本生成)
+-- code/             <- 所有 .do / .py / .R 脚本
+-- output/           <- 回归表格、图表、日志(脚本自动生成)
+-- refs/             <- 参考文献 PDF + .bib 文件
+-- README.md         <- 一页说明(项目/数据/方法/复现命令)

三条铁律 ​

表 1.8 三条铁律。

L3|L3|L3

规则 & 原因 & 违反后果
data/raw/ 只读不改 & 原始数据是唯一真相来源 & 改了就无法复现,审稿人/导师无法验证
所有修改通过 code/ 脚本完成 & 脚本可重跑 = 结果可复现 & 手动改 Excel 的操作无法追溯
output/ 不手动编辑 & 由脚本自动生成,保证一致性 & 手动改过的表格与代码输出不匹配\

[提示] 为什么 data/raw/ 只读这么重要?因为你的论文可能被任何人要求复现。如果原始数据被改过,你就无法证明结果是从哪来的——这在学术上叫“数据不可溯源”,是严重问题。本手册第 0 章的撤稿案例(§0.1)已经说明:学术诚信的底线一旦突破,后果是不可逆的。

核心洞察:贪吃蛇实验中的“分析 → 生成 → 运行 → 调试”四步闭环,是本手册后续所有实操的工作模式。无论做论文解读、数据清洗还是回归分析,AI 都遵循这一流程。例如 §1.3 的实战演练中,你输入提示词后 AI 分析需求、生成 Stata 代码、运行回归、输出 LaTeX 表格——这就是同一个闭环在经济研究场景中的应用。理解这个闭环,你就掌握了与 AI 高效协作的节奏感。


🛠 AI 辅助研究栏|本章 AI 用法:环境配置与首次协作 ​

场景:你刚装好 TRAE/Qoder,不确定环境是否完整。

正确做法:

  1. 复制 §1.2 的提示词,粘贴到 AI 对话框

  2. AI 自动检测并安装缺失工具

  3. 按 AI 指示完成验证

进阶用法:让 AI 帮你写 Stata 代码

AI 生成的代码可能如下(节选,完整版见 output/auto_analysis.do):

/*
============================================================
  汽车价格决定因素分析——完整 do 文件
  数据来源:Stata 自带 auto 数据集(1978年美国汽车,N=74)
  作者:AI 辅助生成(学生需自行验证每一步结果)
  日期:2026-09-26
============================================================
*/

* ---- Step 1: 加载数据 ----
clear all
sysuse auto, clear
describe
codebook

* ---- Step 2: 描述性统计 ----
summarize price mpg weight foreign length turn
corr price mpg weight foreign

* ---- Step 3: 生成辅助变量 ----
gen lnp = ln(price)
gen wt_per_thousand = weight / 1000
label var lnp "对数价格"
label var wt_per_thousand "车重(千磅)"

* ---- Step 4: OLS 回归 ----
regress price mpg weight foreign length
estimates store ols_full

* ---- Step 5:  post-estimation 诊断 ----
vif                       // 方差膨胀因子(多重共线性)
hettest                   // Breusch-Pagan 异方差检验
predict resid, residual   // 保存残差
histogram resid, normal   // 残差正态性目视检查

* ---- Step 6: 稳健标准误回归 ----
regress price mpg weight foreign length, robust
estimates store ols_robust

* ---- Step 7: 输出 LaTeX 表格 ----
estimates table ols_full ols_robust, stats(N r2 adj_r2) b(%9.3f) se(%9.3f)

esttab ols_full ols_robust using "output/auto_reg_table.tex", ///
    replace star(* 0.10 ** 0.05 *** 0.01) ///
    se r2 aic bic ///
    title("Auto Price OLS Regression") ///
    mtitles("Full" "Robust SE")

log close
di "[OK] 全部完成!LaTeX 表格已保存至 auto_reg_table.tex"

注:auto 是截面数据(74 辆汽车的单期观测),无法做固定效应(FE)回归或 Hausman 检验——这两步需要面板数据(多个体多期)。如果你让 AI 对截面数据跑 FE,AI 可能编出看似正确的代码但结果毫无意义。本章 §1.3 的实战演练会带你用真实 Stata MCP 跑通上述全流程。

AI 会生成代码——但你必须自己跑一遍,确认结果正确。

禁忌:

  • ❌ 直接复制 AI 生成的代码不加验证

  • ❌ 让 AI "帮我编一个显著的结果"

  • ❌ 不看输出就问 AI "我的假设成立吗"



🛡 AI 诚信栏|S1.1 环境正版 ​

  • 自学环境使用正版或学校授权软件

  • 不使用破解版、绿色版 Stata——不仅是法律问题,破解版可能篡改计算结果或植入恶意代码

  • Zotero、Python、Node.js、Git 均为开源免费,无正版问题

S1.2 AI 辅助代码不伪造结果 ​

  • ✅ AI 可以帮你写 Stata 代码、解释输出、建议模型选择

  • ✅ AI 可以帮你调试报错、优化代码结构

  • ❌ 但每一个写进论文的系数,必须是你在自己电脑上跑出来的

  • ❌ 红线:不得用 AI "生成"回归结果(如让 AI 编造系数表格、伪造 p 值)

检查方法:

  • 所有 .do 文件 + .log 文件存档(log 文件记录了完整运行过程,含时间戳)

  • 导师随时可以要求你当面重跑代码复现结果

  • 如果你的论文中某个数字在 log 文件里找不到对应——那就是伪造的

S1.3 结论不复用 AI 原话 ​

  • AI 解释回归结果的语言往往很流畅,但带有明显的"AI 腔"

  • 论文中的结论必须用你自己的话重新表述

  • 自检方法:写完一段后问自己——"这段话我能在答辩时口头说出来吗?"如果说不出来,说明不是你真正理解的

[重点] 三个 S1.x 检查点的关系:S1.1 保证工具正当,S1.2 保证数据真实,S1.3 保证表达原创。三者共同构成"环境章"的诚信底线。



本章小结 ​

  1. AI IDE 已进入第三阶段,选择 TRAE 或 Qoder 即可开始——两者免费、中文友好、支持 MCP。

  2. 环境配置可以全程交给 AI:§1.2 的装机提示词让 AI 自动完成 Python/Node.js/Git 安装;Stata MCP 配置支持 AI 自动写入(方式一)或手工编辑(方式二)。

  3. MCP + Skill + CLI 三范式是后续所有章节的工具框架:MCP 拿数据、Skill 指导分析、CLI 输出结果。

  4. 标准研究文件夹(data/raw + code + output + refs + README)是可复现性的物理保障,三条铁律从第一天开始执行。


English Edition ​

Chapter 1 · Setting Up the Development Environment and the Basics of AI Collaboration ​

1.1 The AI IDE Landscape and Tool Selection ​

The integrated development environment (IDE) is the programmer’s core working tool. Its history falls roughly into three stages:

Stage 1: The editor era (1980s–2000s). Represented by Vim and Emacs, programmers had to configure syntax highlighting, compile commands, and debugging workflows by hand—a steep learning curve but high customizability.

Stage 2: The traditional IDE era (2000s–2022). Represented by Eclipse, Visual Studio, and IntelliJ IDEA, IDEs integrated code completion, syntax checking, debuggers, and version control, greatly improving development efficiency. But completion in this era was essentially rule-based pattern matching—it could only guess possible completions from the characters already typed, without understanding the semantics or context of the code.

Stage 3: The AI IDE era (2023 to present). The breakthrough of large language models (LLMs) has created a new IDE form—the AI IDE. The fundamental difference from traditional IDEs: an AI IDE embeds a large model capable of understanding code, so it can not only complete code but also understand requirements, generate projects, debug errors, and refactor code. The AI IDE shifts the programmer’s role from “writing code line by line” to “describing requirements + reviewing AI output”—a fundamental change of development paradigm.

Comparing the Mainstream AI IDEs ​

The market offers many AI IDEs. From the practical needs of economics students and researchers, we compare the mainstream products below:

Table 1.1 Comparing the mainstream AI IDEs.

L6|L6|L6|L6|L6|L6

Dimension & TRAE & Qoder & Cursor & CodeBuddy & Windsurf
Models & Doubao series & Qwen + Claude & Claude + GPT & Tencent Hunyuan & Claude + GPT
MCP support & Yes & Yes & Yes & Yes & Yes
Skill support & Limited & Rich & Limited & Rich & Limited
Pricing & Free & Paid & Paid & Free trial, then paid & Paid
Chinese UI & Excellent & Excellent & Fair & Excellent & Fair
Access from China & Direct & Direct & VPN needed & Direct & VPN needed\

[Handbook recommendation] This handbook uses TRAE and Qoder as the main teaching AI IDEs. TRAE is completely free with a friendly Chinese interface; its Builder and SOLO modes suit classroom demonstration. Qoder has a richer Skill ecosystem and suits deeper research work. You can mix the two—the core concepts and operating logic are shared.

Download links:

Table information as of September 2026. The AI IDE market changes extremely fast; for actual choices consult each product’s official site. The full reputation comparison of 15 tools (pricing, market dynamics, and risk cases; re-collected 2026-09-27) appears in Appendix H.

Selection Logic: Reasons, Known Defects, and Version Management ​

Why TRAE + Qoder. Both tools are directly accessible from China and both support the MCP protocol (the academic MCP matrix of Appendix E runs on both platforms):

  • TRAE: the basic edition is free with no call limits—zero-cost entry; a native Chinese interface lowers the operating barrier; TRAE is one of the fastest-growing AI IDEs in China.

  • Qoder: the IDC report of July 2026 puts it first in China’s AI Coding market with a 47.6% share (Zhipu CodeGeeX 11.5%, SenseTime Raccoon 10.5%, and Tencent CodeBuddy 7% in second through fourth); its iteration speed and ecosystem scale are assured; its Skill system fits this handbook’s tool matrix (Appendix E) naturally; and its “list a to-do plan first, then execute step by step” interaction pattern trains exactly the research habit of “think it through before acting”.

But they are not without defects—this defect list is the practical reason this handbook keeps stressing version management (full cases in Appendix H.4):

  • TRAE: the snapshot-rollback feature has public cases of lost code (as of June 2026 the official forum still had new reports of “records disappearing after rollback”); ordinary chat mode has a rather short context, so long-running paper projects easily suffer “amnesia”—before asking it for a major change, always commit a Git snapshot first.

  • Qoder: the Credits consumption rules are not fully transparent, and heavy tasks burn quota quickly; in June 2026 users reported a bug where the model was automatically switched back to Auto after a restart.

  • Industry-wide risk: every AI IDE’s agent may delete or modify files without confirmation.

[Why must you pair it with CNB for version control?] The defect list above points to one conclusion: AI writes fast and deletes fast. Git version control is the only fuse that works across all tools—every commit is a restorable snapshot, and any file the AI breaks can be restored in one step; the version history is simultaneously an automatic audit trail of the research process, proving at the defense that the work was done step by step (echoing the research loop of Ch. 0). We choose CNB (cnb.cool) as the platform: direct fast access from China, WeChat QR registration, free public repositories—students need no VPN at all (what CNB is, see the green box after the §1.2 installation steps; the full registration and push workflow is in Appendix G).

Five CNB habits to pair with your AI IDE (ordered by importance):

  1. Commit before big changes: before letting the AI do refactoring, batch edits, or other “big moves”, run git add . and git commit—if the AI breaks any file, git checkout restores the pre-change state;

  2. Small, frequent commits: commit after each deliverable (one table, one section of analysis), with a commit message saying clearly “what was done” (e.g., “questionnaire cleaning v1: dropped 183 invalid responses”)—three months later you will thank these notes;

  3. The .gitignore iron rule: raw data (.dta, .csv), key files (API tokens), and build intermediates never enter the repository;

  4. Push at chapter end: push each chapter’s deliverables (research_question.md etc.; checklist in Appendix C) to CNB—over a semester the cloud naturally accumulates a complete research archive, safe even if your computer dies;

  5. The three-step rollback: when something goes wrong, git status (what changed) → git diff (the exact differences) → git log (find the version to return to).

1.2 Environment Setup: Let the AI Install Your Tools ​

Step 1: Install and Log In to the AI IDE ​

After installing TRAE or Qoder from the links in §1.1, log in on first launch:

TRAE login flow:

  1. The first launch shows a Chinese login screen

  2. Choose “phone number login”, enter your number, and get the verification code

  3. After login you reach the home screen; choose Code mode (the coding-specific interface)

  4. You may skip the VS Code configuration import step (recommended for beginners)

  5. In the code editing interface, the left side shows Builder, the file tree, and other menus

Qoder login flow:

  1. The first launch shows a login screen

  2. Phone number, email, and other login methods are supported

  3. After login you reach the main interface: file tree on the left, AI chat area on the right

[Tip] TRAE and Qoder are both free—register with a school email or phone number. After login your generation history and settings sync.

Step 2: Copy This Prompt and Let the AI Install Everything ​

After TRAE or Qoder is installed and you are logged in, you do not need to install anything else by hand. Copy the following prompt into the AI chat box in full; it will detect your system, install the missing software, configure the whole environment, and finally tell you “all set”.

Copy This Prompt into the AI Chat Box ​

Hello! I am setting up my research environment following the
"Self-Study Handbook of AI-Assisted Economic Research". Please
do the following for me:

1. Detect my operating system (macOS or Windows)
2. Check whether each of these tools is installed, and install
   any that are missing:
   - Python 3.12+
   - Node.js 20 LTS (choose LTS, not Current)
   - Git
   - Package manager (macOS: Homebrew / Windows: winget)
   - uv (a very fast Python package manager)
   - gh (GitHub CLI, for PR/Issue management)
   - pandoc (document format conversion)
   - Zotero 10.0+ (reference management)
   - Stata 18 (if already installed)

3. For each tool, run the version check command and report:
   - python3 --version (should show 3.12.x or higher)
   - node --version (should show v20.x.x)
   - git --version
   - uv --version
   - gh --version
   - pandoc --version
   - zotero --version (if CLI is supported)
4. Configure the Zotero CLI tool:
   - Install cli-anything-zotero: pip install cli-anything
   - Verify the install: cli-anything-zotero --help
   - If the Zotero data directory is not at the default
     location, configure the path for me

5. Configure Stata MCP (if Stata is installed):
   - Locate the Stata installation path
   - Set the MCP server endpoint: http://localhost:4000
   - Test the connection: curl http://localhost:4000/health

6. Configure Git and the CNB remote repository:
   - Check the git global config (user.name, user.email)
   - If unset, prompt me to set them
   - Explain how to add a CNB remote (cnb.cool)
7. Create the project directory structure (if not yet created):
   research-project/
   ├── data/           # raw data (not in git)
   ├── do/             # Stata do files
   ├── output/         # regression results, figures
   ├── docs/           # documents, notes
   ├── references/     # reference PDFs
   └── README.md

8. Produce an environment check report:
   - List installed tools with versions (mark with ✓)
   - List missing or wrong-version tools (mark with ✗)
   - Provide manual install commands or download links
   - Suggest the next steps

Notes:
- macOS users: install via Homebrew (brew install ...)
- Windows users:
  - Prefer winget (winget install ...)
  - If winget is unavailable, give official download links
  - All command-line operations need an administrator terminal
- How to open an admin terminal: right-click the Start button
  at the lower-left corner → choose "Terminal (Admin)" or
  "Windows PowerShell (Admin)"
- If you hit permission or network problems, tell me exactly
  how to resolve them

What you should see afterwards: the AI reports each check one by one, most showing ✅. If any shows ❌, the AI will tell you how to fix it manually—usually a network or permission issue; just follow the prompts.

[What is CNB?] CNB (cnb.cool) is a China-based GitHub—a code hosting platform. Registration is a WeChat QR scan, domestic access is fast, and public repositories are free. Detailed operations in Appendix G.

[Windows users] “winget” in the prompt is the Windows package manager and must be installed manually.

How to install winget:

  1. Open the Microsoft Store (search “Microsoft Store” in the Start menu)

  2. Search for and install “App Installer” (Microsoft’s official installer, which includes winget)

  3. Restart the terminal and verify with winget --version

Fallback (if the Microsoft Store is unavailable):

The Stata command-line link on Windows needs a manual PATH entry—the AI will walk you through it. If winget is unavailable, the AI will switch to official downloads.

Official download fallbacks (for all Windows versions):

Advanced: Configuring Stata MCP (Let the AI Drive Stata Directly) ​

Stata MCP is a bridge service that lets the AI run Stata code directly. Once configured, you can ask in the AI chat box, “run a panel fixed-effects regression for me”, and the AI generates and executes the code automatically.

Comparing the two options:

Table 1.2 Two Stata MCP options.

L3|L3|L3

Feature & hanlulong/stata-mcp & SepineTam/mcp-for-stata
Type & VS Code extension (localhost HTTP) & Standalone MCP server + CLI
Suitable clients & Requires an active IDE window & All MCP clients
Execution & Embedded in the IDE via localhost:4000 & do files via subprocess
Install & Search DeepEcon.stata-mcp in the VS Code marketplace & uvx stata-mcp install --all
Best for & Writing and running Stata inside the IDE & Agent-driven analysis\

Recommended: hanlulong/stata-mcp (the VS Code extension)—simple to install and well integrated with TRAE/Qoder.

Installation steps:

  1. Search DeepEcon.stata-mcp in the TRAE/Qoder extension marketplace

  2. Click install

  3. Configure the MCP server (two ways below; pick either)

Option 1: Let the AI configure it (recommended, zero manual work)

After installing the extension, paste the following prompt into the AI chat box (the AI understands English; copy directly):

The AI will read your MCP configuration file, write the correct endpoint, and remind you to restart the client. No manual JSON editing.

Option 2: Manual MCP configuration (for those who want to understand the machinery)

Open the AI IDE’s MCP configuration file (TRAE/Qoder: Settings → MCP → Edit configuration) and add:

macOS configuration:

"stata-mcp": {
  "command": "uvx",
  "args": ["stata-mcp"],
  "env": {
    "STATA_PATH": "/Applications/Stata/StataMP.app/Contents/MacOS/stata-mp",
    "MCP_STATA_LOGLEVEL": "INFO"
  }
}

Windows configuration:

"stata-mcp": {
  "command": "uvx",
  "args": ["stata-mcp"],
  "env": {
    "STATA_PATH": "C:\\Program Files\\Stata18\\StataMP-64.exe",
    "MCP_STATA_LOGLEVEL": "INFO"
  }
}

[Important] STATA_PATH must match the actual Stata installation path on your machine!

Finding the Stata path:

  • macOS: right-click the Stata app → Show Package Contents → Contents/MacOS/stata-mp

  • Windows: usually C:\Program Files\Stata18\StataMP-64.exe

MCP tool list (the three tools available to the AI once configured):

  • stata_run_selection — run the selected Stata code fragment

  • stata_run_file — run an entire .do file

  • stata_session — session management (list / destroy)

Usage example (type it in the AI chat box; uses Stata’s built-in data, no extra data files needed):

Endpoint addresses (hanlulong option):

Table 1.3 Endpoint / protocol / purpose quick reference.

EndpointProtocolPurpose
http://localhost:4000/mcp-streamableStreamable HTTPFirst choice (modern clients)
http://localhost:4000/mcpSSELegacy compatibility
http://localhost:4000/healthHTTP GETHealth check

Keyboard shortcuts:

Table 1.4 Action / Mac / Win-Linux quick reference.

ActionMacWin/Linux
Run selected codeCmd+Shift+EnterCtrl+Shift+Enter
Run the whole .do fileCmd+Shift+DCtrl+Shift+D
Stop executionCmd+Shift+CCtrl+Shift+C

SepineTam option installation (for agent-driven analysis scenarios):

# Install for all clients in one command
uvx stata-mcp install --all

# Single-client install examples
uvx stata-mcp install -c claude
uvx stata-mcp install -c cursor

# Environment check
uvx stata-mcp doctor

Troubleshooting:

Table 1.5 Problem / solution quick reference.

ProblemSolution
Service not startedCheck whether the status bar shows “Stata”; run curl http://localhost:4000/health
Port conflictChange the stata-vscode.mcpServerPort setting
Stata not foundSet stata-vscode.stataPath manually to the install directory
UV installation failedRun curl -LsSf https://astral.sh/uv/install.sh | sh manually
Output truncatedAdjust maxOutputTokens (0 = unlimited)
MCP tools not appearingRestart the IDE/client (the MCP tool list does not refresh within one session)

[Tip] If you don’t understand the commands above, just type in the AI chat box: help me install the uv package manager or help me fix the stata-mcp connection; the AI will diagnose and handle it.

Advanced: A Python Alternative When You Have No Stata ​

Without Stata, Python + statsmodels delivers the same functionality:

import pandas as pd
import statsmodels.formula.api as smf

# Read the Stata dataset
df = pd.read_stata("data/bank_panel.dta")

# OLS regression (cluster-robust standard errors)
model = smf.ols(
    "roe ~ npl_ratio + car + loan_growth + np.log(asset)",
    data=df
).fit(cov_type="cluster", cov_kwds={"groups": df["bank_id"]})

print(model.summary())

1.3 The LaTeX Academic Typesetting Environment ​

In academic economics, LaTeX is the de facto standard for paper writing. Mastering LaTeX brings three values to economics students:

  • Typesetting papers and books: many journals and publishers at home and abroad (e.g., the Journal of Finance, Economic Research Journal, Journal of Financial Research) require or recommend LaTeX submissions. LaTeX’s formula typesetting, reference management, and cross-referencing far exceed Word.

Installation Steps ​

Windows: install MiKTeX (recommended)

  1. Visit https://miktex.org/download and download the Basic MiKTeX Installer (about 230 MB)

  2. Run the installer and choose “Install for current user” (no administrator rights needed)

  3. After installation open MiKTeX Console → Settings → set “Install missing packages” to Always

macOS: install MacTeX

# Option 1: via Homebrew (recommended)
brew install --cask mactex

# Option 2: manual download from the Tsinghua mirror
# (about 7 GB, fast in China)
curl -L -o /tmp/mactex.pkg \
  "https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/mac/mactex/mactex-20260324.pkg"
sudo installer -pkg /tmp/mactex.pkg -target /

Verify the installation (Windows / macOS alike)

xelatex --version   # should print the XeTeX version
biber --version     # should print the biber version

Test Chinese compilation

Create a new test.tex containing:

\documentclass{ctexart}
\begin{document}
你好,LaTeX!如果中文正常显示,环境配置成功。
\end{document}

Run xelatex test.tex in the terminal; success means the PDF is produced with Chinese displayed correctly. (The test file keeps the Chinese sentence—if Chinese fails to render, the environment is not ready.)

[Tip] On first compilation MiKTeX automatically downloads missing packages (e.g., the ctex family); click Install when prompted. The first run takes about 1–2 minutes, later runs 5–10 seconds. On macOS, MacTeX already bundles all packages—no extra downloads.

Hands-On: Stata Regression → LaTeX Table → PDF ​

With LaTeX installed, you can have the AI complete the whole chain “run regression → export a LaTeX table → compile the PDF” in one go. Below is an actual run log.

Step 1: type the prompt in the AI chat box

Step 2: the AI runs the Stata regression automatically

Through stata-mcp the AI runs the following Stata commands:

webuse auto, clear
summarize price mpg weight foreign

Output:

    Variable |        Obs   Mean    Std. dev.       Min        Max
-------------+----------------------------------------------------
       price |         74   6165.26   2949.50       3291      15906
         mpg |         74   21.30     5.79          12         41
      weight |         74   3019.46   777.19       1760       4840
     foreign |         74   0.30      0.46           0          1

Run two regressions:

gen ln_price = ln(price)
gen weight_foreign = weight * foreign
quietly reg ln_price mpg weight foreign, robust
estimates store m1
quietly reg ln_price mpg weight foreign weight_foreign, robust
estimates store m2

Step 3: export the LaTeX table with esttab

esttab m1 m2 using reg_table.tex, replace \
  style(tex) booktabs b(4) se(4) \
  star(* 0.10 ** 0.05 *** 0.01) \
  r2 ar2 scalar(F N) \
  mtitles("OLS" "Interaction")

esttab generates a complete LaTeX table file (reg_table.tex) with a booktabs three-line table, significance stars, standard errors, and model fit statistics.

Step 4: compile the PDF

Run in the terminal:

xelatex auto_reg_demo.tex

and you get a PDF containing the regression tables and interpretation.

Final result: a complete regression report with a descriptive-statistics table, a two-column regression comparison (OLS vs. interaction), and interpretation. From prompt to PDF the AI does everything automatically—this is the MCP + LaTeX collaboration loop.

1.4 The Four AI Collaboration Modes in Detail ​

Modern AI IDEs offer several collaboration modes; understanding each mode’s traits and use cases is the precondition for using AI efficiently. This section details the four modes using TRAE as the example; other AI IDEs work similarly.

IDE Mode: Traditional Coding + Inline AI Completion ​

How it works: you write code normally in the editor; the AI offers inline completion suggestions at the cursor (like the word suggestions on a phone keyboard). Press Tab to accept, Esc to dismiss.

Typical uses:

  • Writing repetitive code (batch variable definitions, boilerplate)

  • Completing function signatures and parameters

  • Generating code fragments from comments

Chat Mode: Question-and-Answer Interaction ​

How it works: you talk with the AI in the side-panel chat window; the AI answers in text only and never modifies code files directly. This is the safest mode, best for the learning-and-understanding stage.

Typical uses:

  • Understanding concepts: “What is the seasonal differencing of a SARIMA model?”

  • Explaining code: “What does the groupby operation in this pandas code do?”

  • Debugging: “What causes this ImportError?”

  • Comparing approaches: “What are the pros and cons of ARIMA vs. LSTM for time-series forecasting?”

Builder Mode: The AI Operates the File System Directly ​

How it works: the AI can directly create, modify, and delete files and execute commands in the terminal. This is the most productive mode—and the riskiest.

Typical uses:

  • Generating a project from scratch: “build a Snake game web page”

  • Batch-editing files: “sort the import statements of all Python files alphabetically”

  • Installing and running: “install flask and start the dev server”

[Safety reminder] In Builder mode the AI operates the file system directly, with the risk of deleting files or running dangerous commands. Recommendations:

  • Always use Git version control for important projects so you can roll back

  • Beginners should understand the problem in Chat mode first, then switch to Builder mode to execute

  • Never use SOLO mode in directories containing important data

SOLO Mode: Fully Autonomous Development ​

How it works: in SOLO mode the AI has maximum autonomy—it plans the task, decomposes steps, creates sub-agents, and executes operations. The interface is usually three-pane: task plan on the left, code editor in the middle, preview/terminal on the right.

Typical uses:

  • Rapid prototyping: “build me a prototype of a bank customer management system”

  • Zero-code development: describe the requirement and rely entirely on the AI

The Four Modes Compared ​

Table 1.6 The four modes compared.

L4|L4|L4|L4

Mode & AI permissions & Risk level & Best for
IDE & Inline completion & Low & Everyday coding
Chat & Answers only & Lowest & Learning and understanding
Builder & Read/write files + run commands & Medium & Project generation
SOLO & Fully autonomous & High & Rapid prototypes\

1.5 A Cognitive Map of Three Paradigms: What MCP / Skill / CLI Each Do ​

Before installing anything, understand one key question: why do we need three different kinds of AI tools, and what does each manage?

This handbook divides AI-assisted research tools into three layers. Picture a person: MCP is the senses (taking in information), Skill is the knowledge in the brain (knowing how to do things), CLI is the hands (executing actions).

If you prefer a finance metaphor: MCP is like a Bloomberg terminal (fetching data), Skill is like an investment research framework (knowing how to analyze), CLI is like Excel and Word (producing reports).

The Three Paradigms Compared ​

Table 1.7 The three paradigms compared.

L4|L4|L4|L4

Dimension & MCP (connection layer) & Skill (knowledge layer) & CLI (execution layer)
Essence & Model Context Protocol, a connection protocol & Domain knowledge files (Markdown SOPs) & Shell command-line tools
Metaphor & The AI’s “USB-C port”—plug in and read data & The AI’s “operations manual”—teaches it standard procedures & The AI’s “hands”—operating files and data directly
Form & JSON-RPC server (running in the background) & A SKILL.md file (plain text) & An executable program (called from the terminal)
Development cost & High (requires server code) & Low (just write Markdown) & Zero (use existing tools)
Best for & Connecting to external APIs / databases & Knowledge reuse, process standardization & Local file operations, batch processing
Typical use & tushareMcp pulling A-share panel data & A stata Skill guiding OLS→FE→RE & officecli writing regression tables into Word\

The Golden Combination ​

The three are not mutually exclusive but synergistic:

MCP (fetch the data) + Skill (know how) + CLI (execute) = a complete research automation chain

A concrete scenario: suppose you study “bank governance structure and ROE”—

  1. MCP fetches the data: use tushareMcp to pull 5 years of financials for 100 listed banks

  2. Skill guides the analysis: a stata skill tells the AI to run OLS → FE → RE as a three-model comparison

  3. CLI outputs the results: officecli writes the regression tables into Word, ready for your advisor

You don’t need to memorize every tool’s name now—later chapters expand each one. Here you only need the “three-layer division of labor” framework: connect → know → execute.

1.6 The Standard Research Folder: A Five-Directory Structure ​

What is the biggest fear in research? Not that the model fails to run, but that files are too messy to find. Which folder holds the data from three months ago? Which version is that regression table? Where are the logs?

From now on, every research project uses the same five-directory structure. This is not formalism—it is the physical guarantee of reproducibility.

The Directory Template ​

my_research_project/
+-- data/
|   +-- raw/          <- raw data (read-only! never modify!)
|   +-- clean/        <- cleaned data (generated by code/ scripts)
+-- code/             <- all .do / .py / .R scripts
+-- output/           <- regression tables, figures, logs (auto-generated)
+-- refs/             <- reference PDFs + .bib files
+-- README.md         <- one-page description (project/data/method/reproduce)

Three Iron Rules ​

Table 1.8 The three iron rules.

L3|L3|L3

Rule & Reason & Consequence of breaking it
data/raw/ is read-only & Raw data is the single source of truth & Once changed, results cannot be reproduced; reviewers/advisors cannot verify
All changes go through code/ scripts & Scripts can be re-run = results reproducible & Manual Excel edits cannot be traced
Never hand-edit output/ & Generated by scripts, guaranteeing consistency & Hand-edited tables will not match code output\

[Why does read-only data/raw/ matter so much?] Because anyone may ask you to reproduce your paper. If the raw data was changed, you cannot prove where the results came from—academically this is called “untraceable data”, a serious problem. The retraction cases in Ch. 0 (§0.1) already showed: once the bottom line of research integrity is crossed, the consequences are irreversible.

Core insight: the “analyze → generate → run → debug” loop from the Snake-game experiment is the working pattern for every hands-on section of this handbook. Paper interpretation, data cleaning, regression analysis—the AI follows the same loop. In the §1.3 exercise, after your prompt the AI analyzed the need, generated Stata code, ran the regression, and exported the LaTeX table—the same loop applied to economic research. Grasp this loop and you have the rhythm of working with AI.


🛠 AI-Assisted Research|This Chapter’s AI Usage: Environment Setup and First Collaboration ​

Scenario: you have just installed TRAE/Qoder and are unsure whether the environment is complete.

Correct practice:

  1. Copy the §1.2 prompt and paste it into the AI chat box

  2. The AI detects and installs the missing tools automatically

  3. Complete verification as the AI instructs

Advanced use: have the AI write Stata code for you

The AI-generated code may look like this (excerpt; full version in output/auto_analysis.do):

/*
============================================================
  Determinants of automobile prices --- complete do file
  Data: Stata's built-in auto dataset (1978 US cars, N=74)
  Author: AI-assisted generation (the student must verify
          every result)
  Date: 2026-09-26
============================================================
*/

* ---- Step 1: Load the data ----
clear all
sysuse auto, clear
describe
codebook

* ---- Step 2: Descriptive statistics ----
summarize price mpg weight foreign length turn
corr price mpg weight foreign

* ---- Step 3: Create helper variables ----
gen lnp = ln(price)
gen wt_per_thousand = weight / 1000
label var lnp "Log price"
label var wt_per_thousand "Weight (thousand pounds)"

* ---- Step 4: OLS regression ----
regress price mpg weight foreign length
estimates store ols_full

* ---- Step 5: Post-estimation diagnostics ----
vif                       // variance inflation factors (multicollinearity)
hettest                   // Breusch-Pagan heteroskedasticity test
predict resid, residual   // save residuals
histogram resid, normal   // visual check of residual normality

* ---- Step 6: Robust-standard-error regression ----
regress price mpg weight foreign length, robust
estimates store ols_robust

* ---- Step 7: Export a LaTeX table ----
estimates table ols_full ols_robust, stats(N r2 adj_r2) b(%9.3f) se(%9.3f)

esttab ols_full ols_robust using "output/auto_reg_table.tex", ///
    replace star(* 0.10 ** 0.05 *** 0.01) ///
    se r2 aic bic ///
    title("Auto Price OLS Regression") ///
    mtitles("Full" "Robust SE")

log close
di "[OK] All done! LaTeX table saved to auto_reg_table.tex"

Note: auto is cross-sectional data (74 cars observed once), so fixed-effects (FE) regression or a Hausman test is impossible—those require panel data (many units over many periods). If you ask the AI to run FE on cross-sectional data, it may produce plausible-looking code with meaningless results. The §1.3 exercise walks you through the full pipeline above with a real Stata MCP.

The AI generates code—but you must run it yourself and confirm the results are correct.

Taboos:

  • ❌ Copying AI-generated code without verification

  • ❌ Asking the AI to “make me a significant result”

  • ❌ Asking the AI “does my hypothesis hold?” without looking at the output



🛡 AI Integrity|S1.1 Licensed Software Only ​

  • Your self-study environment uses licensed or school-authorized software

  • Never use cracked or “green” versions of Stata—not only a legal issue: cracked copies may alter computations or plant malicious code

  • Zotero, Python, Node.js, and Git are open-source and free—no licensing issue

S1.2 AI-Assisted Code Must Not Fabricate Results ​

  • ✅ AI may help you write Stata code, explain output, and suggest model choices

  • ✅ AI may help you debug errors and restructure code

  • ❌ But every coefficient that enters the paper must be produced on your own machine

  • ❌ Red line: never use the AI to “generate” regression results (fabricated coefficient tables, invented p-values)

How to check:

  • Archive all .do files + .log files (the log records the full run, with timestamps)

  • Your advisor may ask you to re-run the code in person at any time

  • If a number in your paper cannot be found in any log file—it is fabricated

S1.3 Do Not Reuse AI Wording for Conclusions ​

  • AI explanations of regression results are fluent but carry an obvious “AI accent”

  • Conclusions in the paper must be restated in your own words

  • Self-check: after writing a paragraph, ask—“can I say this aloud at my defense?” If not, you don’t truly understand it

[Key point] How the three S1.x checkpoints relate: S1.1 ensures legitimate tools, S1.2 ensures genuine data, S1.3 ensures original expression. Together they form the integrity baseline of the “environment chapter”.



Chapter Summary ​

  1. AI IDEs have entered their third stage; TRAE or Qoder is enough to start—both free, Chinese-friendly, and MCP-capable.

  2. Environment setup can be delegated to the AI end to end: the §1.2 prompt lets the AI install Python/Node.js/Git automatically; Stata MCP can be configured by the AI (option 1) or by hand (option 2).

  3. The MCP + Skill + CLI triad is the tool framework for all later chapters: MCP fetches data, Skill guides analysis, CLI outputs results.

  4. The standard research folder (data/raw + code + output + refs + README) is the physical guarantee of reproducibility; start the three iron rules on day one.

本站教学资源仅供四川农业大学选课学生学习使用,版权归原作者所有,未经授权不得转载、转发或用于商业用途