Skip to main content

AI-Assisted Coding

Author

Gang Chen

Published

May 2, 2026

AI assistants are useful for planning, code drafting, debugging, documentation, and review. They are most useful when the project has clear context, organized files, and version control.

Project Instruction Files

AI assistants work better when the project gives them clear instructions. A research project can include:

  • AGENTS.md: project instructions for Codex or other coding agents.
  • CLAUDE.md: project instructions for Claude Code.
  • docs/plan.md: project goals, milestones, tasks, and reviewed implementation plans.
  • docs/decision_log.md: important research and coding decisions.
  • docs/data_provenance.md: data source, download date, raw file name, access restrictions, and processing notes.

What are AGENTS.md and CLAUDE.md?

AGENTS.md and CLAUDE.md are plain-text instruction files in the root of your project folder that the assistant can use as project context. AGENTS.md is the convention used by Codex and many other coding agents; CLAUDE.md is the equivalent for Claude Code. They serve the same purpose, so their content is often similar.

Think of them as a short onboarding note for a new research assistant: write the key facts once instead of re-explaining the project every session. They should tell the assistant what the project is about, which files are safe to edit, which should not be changed, what coding style and packages to follow, and what checks to run before a task is done. Keep them concise, and update them as the project evolves.

Planning Before Coding

For any major coding task, ask the assistant to make a plan before editing files. Review the plan for research logic, file scope, data assumptions, and expected outputs. Only then ask the assistant to implement the approved plan.

Good planning questions include:

  • What files will be changed?
  • What data inputs and outputs are involved?
  • What assumptions are being made?
  • What checks will confirm that the task worked?
  • What should not be changed?

Variable and Model Registries

Research code should make variables and models traceable. A project can use:

  • docs/variable_registry.md: variable names, definitions, source fields, transformations, units, and changes over time.
  • docs/model_registry.md: model purpose, outcome variable, sample, controls, fixed effects, standard errors, output files, and notes.

Registries help with tracing, audit, and reproducibility. They also make it easier to check whether tables, figures, and report text match the actual analysis code.

Reproducible Checking Process

After AI-assisted edits, rerun the relevant code and check the output. A basic checking process should confirm:

  • The project can run from a clean session.
  • Raw data remain unchanged.
  • Tables and figures are regenerated from code.
  • Variable names, data dimensions, missing values, joins, and model outputs make sense.
  • Report text matches generated results.
  • Package and software versions are recorded when possible.

Rules for Using AI in Research Code

  • Ask for a plan before file edits.
  • Keep the requested task concrete.
  • Review all code and text before accepting it.
  • Rerun the analysis after edits.
  • Do not paste confidential data, student data, partner data, credentials, or restricted files into AI tools.
  • Do not let the assistant invent data, citations, models, or results.
  • Keep researcher judgment central. The human researcher is responsible for design, interpretation, and conclusions.
  • Commit only after checks and human review.