| name | cfps-panel-pipeline |
| description | How to configure, run, and extend this CFPS (China Family Panel Studies / 中国家庭追踪调查) Stata cleaning pipeline. Use this skill whenever the task touches the CFPS panel — setting up raw data paths, running 00_run.do, adding or changing a harmonized variable, adding a new survey wave/year, or repairing the code after CFPS republishes its data with renamed files or variables. Also use it for any "variable not found", "file not found", or missing-ado error coming out of these do-files, and whenever someone asks how a variable in cfps_ind.dta was constructed. The pipeline relies on naming conventions that are not enforced anywhere and fail silently when broken, so consult this skill before editing any .do file in this repo. |
CFPS Panel Cleaning Pipeline
The full guide lives in the repository itself, so that it serves every coding
agent rather than only Claude Code. This file is the Claude Code entry point into
it.
Read AGENTS.md in the project root first. It covers the
repo layout, the execution order, the conventions the code depends on, how to run
the pipeline, and how to verify a change. Then open the task guide it points you
to under docs/agent-guide/:
| Task | Guide |
|---|
| Setting up a fresh clone, or diagnosing a failed run | docs/agent-guide/setup-and-reproduce.md |
| Adding or modifying a harmonized variable | docs/agent-guide/add-variable.md |
| Adding a new survey wave | docs/agent-guide/add-wave.md |
| CFPS republished the data; files or variables renamed | docs/agent-guide/data-version-update.md |
The one thing to know before touching anything
Inside a wave script every harmonized variable is staged with an a_ prefix,
because each questionnaire block ends with:
keep a_*
rename a_* *_10
A variable created without that prefix is dropped by keep a_* with no error at
all. The script runs clean and the variable is simply absent from the output.
This repo has no test suite, so nothing else will catch it — always verify a new
variable actually survived into $data_gen/cfps{YY}_ind.dta rather than trusting
a successful run.
AGENTS.md explains the remaining conventions, which are equally unenforced.