A Practical Guide

Claude Code in VS Code
for Academic Economists

Agentic AI assistance for R, Stata, Python, and LaTeX

by Claes Bäckman

Installation in 5 Steps

Installing Claude Code in VS Code and getting started is straightforward.

Mac users: replace Ctrl with Cmd throughout — e.g. Cmd+Shift+X for Extensions, Cmd+Shift+P for the Command Palette.
  1. Open VS Code and open the Extensions panel by pressing Ctrl+Shift+X.
  2. Search "Claude Code" and install the official Anthropic extension.
  3. Click the Claude icon (Claude) in the left sidebar or on the top right of a window pane.
  4. Sign in with your Claude account or API key.
  5. Open your full project folder in VS Code (File → Open Folder), not just a single file. Claude needs the whole directory tree to be useful. This can be any folder on your computer — a git repository, a Dropbox folder, or a plain folder on your desktop all work equally well.
Tip: Run Claude Code: Open Walkthrough from the Command Palette (Ctrl+Shift+P) for a quick interactive tour of the basics.
VS Code welcome screen with Extensions panel, Open Folder, and Claude Code icon highlighted
The VS Code welcome screen — Extensions panel (left), Open Folder (middle), Claude Code icon (top right).
VS Code with a project folder opened on the left and the Claude Code panel opened on the right
Once a folder is opened and Claude Code is launched — project files in the Explorer (left), Claude Code panel (right).
Tip: Do you like the light theme in the pictures, but find that your VSCode is in dark mode? Ask Claude to help you change the theme with a prompt like Change my VS Code theme to light. It can switch themes for you without needing to navigate the settings menu. If you want to change the theme manually, open settings and themes and choose a light theme.

After Installing — What to Do Next

Claude Code works out of the box, but a few one-time setup steps make it dramatically more useful for empirical research. Everything below is covered in detail in the sections that follow — this is the short roadmap.

  1. Install the extensions for your research stack. Stata, Python, LaTeX, CSV viewers — Claude reads what's installed and can run code, render tables, and preview PDFs directly in the editor.
  2. Create a CLAUDE.md file for each project. Tell Claude once about your data, sample definitions, and coding conventions. It reads this at the start of every session so you never have to repeat yourself.
  3. Add skills for the workflows you repeat. Turn a standard robustness check, a referee-style review, or a slide-deck build into a one-line slash command you can invoke in any project.

A Starter Pack for Economists

Install these alongside Claude Code to cover the full research stack. Search for each by the extension ID in the Extensions panel (Ctrl+Shift+X).

Stata

tmonk.stata-workbench
A VS Code-compatible extension that allows Stata code to be run directly from the editor. Enables AI agents to directly interact with Stata. It also exposes an MCP server so Claude Code can directly execute Stata commands, inspect your variables, and read stored results. Built by Thomas Monk, London School of Economics.

Python

ms-python.python
The core Python extension. Syntax highlighting, IntelliSense, and the run-button for .py files. Required for anything Python-related.
ms-python.vscode-pylance
Fast, type-aware language server for Python. Gives Claude Code better static context about your code — variable types, function signatures — which improves suggestion quality.
ms-python.debugpy
Python debugger. Set breakpoints and inspect variables mid-run — essential when tracking down why a panel merge or regression loop is producing unexpected results.
ms-python.vscode-python-envs
Manages virtual environments (conda, venv, pipenv) from inside VS Code. Keeps project dependencies isolated — important when different papers use different package versions.
Why install Python even if you don't write Python. A surprising share of the everyday friction in empirical work — converting a PDF or .docx to markdown, reshaping a messy CSV, scraping a table from a webpage, pulling a series from an API, cleaning a bibliography file, splitting a 200-page document into chapters — is solved most quickly by a ten-line Python script. You don't need to know the language to benefit. Ask Claude Code in plain English ("convert this PDF to markdown, keep the tables", "download monthly CPI from FRED and save as CSV"), and it will write, run, and debug the script for you. Installing the Python extensions above is what makes that path smooth: Claude can execute scripts, see the errors, and iterate without you having to set anything up. Think of Python less as a language you need to learn and more as a general-purpose glue that Claude uses on your behalf.

LaTeX

james-yu.latex-workshop
The standard LaTeX extension. Compiles on save, renders a side-by-side PDF preview, shows compile errors inline, and provides autocomplete for commands and citations. Pairs well with Claude Code for table and notation fixes — you see the output update immediately.
yzane.markdown-pdf
Converts Markdown files to PDF with one command. Useful for quick memos, referee responses, or notes that don't need full LaTeX treatment.

Data Files

mechatroner.rainbow-csv
Colour-codes CSV columns so you can visually verify structure at a glance. Also adds a lightweight SQL-like query tool (RBQL) for filtering rows without loading into R or Python. Very useful for quickly sanity-checking raw data files.
tomoki1207.pdf
Renders PDFs inline in VS Code. Read papers, codebooks, and data documentation without leaving the editor — useful when you want Claude Code to reference a PDF alongside your code.
LaTeX build-file cleanup. By default, latex-workshop leaves a trail of auxiliary files (.aux, .bbl, .log, .fls, .fdb_latexmk, …) next to your .tex source. To have VS Code delete them automatically after each successful build, add three settings to your .vscode/settings.json:
"latex-workshop.latex.autoClean.run": "onBuilt",
"latex-workshop.latex.clean.method": "glob",
"latex-workshop.latex.clean.fileTypes": [
  "*.aux", "*.bbl", "*.blg", "*.log",
  "*.out", "*.toc", "*.fls", "*.fdb_latexmk",
  "*.nav", "*.snm", "*.vrb"
]
The first line triggers cleanup after every build; the second tells it to match by file extension; the third lists which extensions to delete. Set autoClean.run to "never" if you'd rather keep the aux files around (useful when debugging bibliography or cross-reference errors).

What Claude Code Can Read — and What to Convert First

Claude Code works best with plain text. The more a file looks like characters-on-a-page (as opposed to a rendered binary), the better Claude can read, edit, and reason about it. For economists this has practical consequences: a referee report in .docx or a codebook as a scanned PDF are both usable, but giving Claude a text version of the same file produces noticeably better results.

A markdown file (.md) is the simplest useful form of this: a plain-text document with lightweight formatting conventions — # for headings, *italic*, **bold**, bullet lists, and links written as [text](url) — that renders into nicely formatted output but stays fully readable and editable as raw text.

A rough guide to how Claude handles the formats you're most likely to encounter:

Plain text
.md, .txt, .tex, .bib, .csv, .json, .yaml
Native — no friction. Claude reads these directly and can edit them line by line. Markdown and LaTeX are the ideal substrate for any writing task. CSV and TSV are fine up to a few thousand rows; larger files should be summarised or sampled before being shown to Claude.
Code
.py, .R, .do, .jl, .sh
Native. Claude reads, edits, and runs these. Stata do-files are no exception — Claude reads them as text even without a Stata installation, though it can only execute them if you have the stata-workbench extension set up.
Jupyter
.ipynb
Native. Claude reads and edits notebook cells directly — code, markdown, and stored outputs — without round-tripping through a script. Useful when a co-author sends an .ipynb or when you want exploratory analysis and prose side by side.
Word
.docx
Usable with a conversion step. Claude can open .docx files, but formatting, comments, and tracked changes often come through awkwardly. For referee reports or co-author comments, convert to markdown first with pandoc file.docx -o file.md. Claude can do this for you — just ask.
Excel
.xlsx, .xls
Convert to CSV first. Claude cannot read Excel binaries directly. Export the sheet as CSV, or ask Claude to run a short Python script that does it. Multi-sheet workbooks are best split into one CSV per sheet with clear names.
Stata / R binaries
.dta, .rds, .sav
Convert first. Claude cannot read these binary formats. Ask Claude to write a short script (Stata export delimited, R readr::write_csv, or Python pyreadstat) to dump the dataset, a sample, or a summary to CSV or markdown.
PDF
.pdf
The most common problem format. See the detailed note below.
Images
.png, .jpg, figures
Partial support. Claude Code can view images directly — useful for showing it a plot you want to improve, or a screenshot of a results table. But it cannot reliably extract text from scanned documents; for those, use OCR first.
Qualtrics / survey
.qsf
Convert first. The Qualtrics .qsf format is technically JSON but deeply nested and hard to read. Ask Claude to write a short script that flattens it into a markdown outline of blocks, questions, and answer choices — much easier to evaluate.

Handling PDFs

PDFs are where most researchers get stuck. They look like documents, but under the hood they are a layout format, not a text format — the "text" is often a sequence of glyphs positioned on a page, with no inherent notion of paragraphs, columns, or tables. Claude Code can read PDFs, but results vary enormously depending on how the PDF was produced.

A practical rule of thumb:

Born-digital PDFs
(from LaTeX, Word, etc.)
Usually fine for short documents. Claude can read them directly. Expect some mangling of tables, footnotes, and multi-column layouts.
Long PDFs
(50+ pages)
Convert to markdown first. Reading a 200-page PDF directly eats your context window and slows every subsequent turn. A clean markdown version is a fraction of the size and far easier to navigate.
Scanned PDFs
(image-based)
Claude cannot read these as text at all — they are essentially images of pages. Run OCR first (ocrmypdf is a good free option), then convert the OCR'd PDF to markdown.
PDFs with equations and tables
These are the hardest case. Any extraction will be imperfect. If you have access to the source .tex, use that instead — it will always be cleaner than re-parsing the compiled PDF.

For converting PDFs to markdown, a few options work well:

pandoc
The universal converter. Free, command-line, handles dozens of formats. Good first try: pandoc paper.pdf -o paper.md. Works best on clean, born-digital PDFs.
marker / MinerU / docling
ML-based PDF-to-markdown tools. Noticeably better than pandoc on papers with tables, figure captions, and equations. All are free and open source. Claude Code can install and run them for you.
A /pdf-to-markdown skill
Roll your own. A short skill (see next section) can wrap all of the above with sensible fallbacks — try pandoc first, fall back to a better tool if the output is empty or suspiciously short, and report the word count so you can sanity-check the result.
Rule of thumb: if a file format requires a conversion step, do it once up front and commit the markdown version alongside the original. Every later session then starts from clean text, and you don't waste context re-converting the same document. This is especially worth doing for codebooks, data dictionaries, and reference PDFs you'll revisit across months of work.

CLAUDE.md and Skills

CLAUDE.md — Persistent Project Context

A CLAUDE.md file at your project root is read automatically at the start of every Claude Code session. It's the place to tell Claude things that are always true about your project — conventions, variable naming, dataset structure, what not to touch — so you don't have to repeat them in every prompt.

The easiest way to create one is to type /init in the Claude Code panel. Claude will read your project folder and generate a draft CLAUDE.md automatically — inferring file structure, languages, and conventions. Review and edit the result before using it. Alternatively, create the file manually. A useful starting point for an empirical project:

# Project: [Paper title]

## Data
- Unit of analysis: firm-year panel, 2010–2022
- Raw data lives in data/raw/ — never edit these files
- Main dataset after cleaning: data/clean/panel.dta (N ≈ 47,000)

## Code conventions
- R scripts are numbered (01_clean.R, 02_analysis.R, ...)
- All regressions cluster SEs at the firm level
- Use fixest for all panel regressions

## LaTeX
- Main file: paper/main.tex
- Tables generated by 03_tables.R go to paper/tables/
- Use \widehat{} not \hat{} for estimators

CLAUDE.md files work at two levels, and both are loaded simultaneously:

~/.claude/CLAUDE.md
Computer-level. Applies to every project on your machine. The right place for personal preferences that never change — your preferred coding language, how you like SEs clustered, LaTeX notation conventions, or a note that you work with Scandinavian register data and prefer variable names in English. The ~ is shorthand for your home folder — on Mac/Linux this is /Users/yourname/.claude/, on Windows it's typically C:\Users\yourname\.claude\. Note that folders starting with . are hidden by default; use Cmd+Shift+. on Mac to show them in Finder.
your-project/CLAUDE.md
Folder-level. Applies only when Claude Code is opened in that project folder. Use it for things specific to one paper — dataset structure, sample restrictions, which script produces which output file, co-author conventions.

When you open a project, Claude reads both files. The folder-level file takes precedence if there's any conflict.

Writing as well as code: CLAUDE.md is also the right place for instructions about how you want Claude to write — tone, voice, the kinds of hedging or phrasing to avoid. Paul Goldsmith-Pinkham has a useful post on using these instructions to get AI assistance that improves rather than flattens your prose: Writing and thinking with AI assistance.

Skills — Reusable Workflows as Slash Commands

Skills are markdown instruction files that become /slash-commands you can invoke in the Claude panel. When you type /skill-name, Claude loads the instructions and executes them — useful for repetitive tasks you run across projects, like a standard robustness check or reformatting a regression table.

Skills live in one of two places:

~/.claude/skills/
Global skills, available in every project. Good for general research workflows.
your-project/.claude/skills/
Project-specific skills, only available in that project folder.

Each skill is a folder containing a SKILL.md file. The folder name becomes the slash command. To create a /robustness command:

mkdir -p ~/.claude/skills/robustness
# then create ~/.claude/skills/robustness/SKILL.md

A minimal SKILL.md for an economist:

---
name: robustness
description: Run standard robustness checks on the main regression.
---

For the main specification in this project:
1. Re-run with alternative clustering (industry-year instead of firm)
2. Re-run dropping the top and bottom 1% of the outcome variable
3. Re-run on the pre-2020 subsample only
4. Produce a summary table comparing coefficients across all specs

Downloading Skills Others Have Written

There is a growing community library of shared skills. Copy any SKILL.md folder into ~/.claude/skills/ and it becomes available immediately as a slash command.

For economists specifically, a few starting points that are already in use in the field:

Skills for getting feedback on research. Commands for referee-style reviews of papers, grant proposals, and code — structured prompts that mimic the kind of critique you'd get from a colleague.
Scott Cunningham's collection of Claude skills for empirical work. Includes /beautiful_deck, which turns notes or a draft outline into a clean, presentation-ready deck, alongside other workflow tools worth browsing.
Chris Blattman's skill reference. A set of research-workflow skills, including /done for wrapping up a session and logging what changed. Useful as a model for how a working economist structures daily Claude Code use.
Worth knowing: Claude can also invoke skills automatically when it judges them relevant — not just when you type the slash command. If you'd rather control when a skill runs, add disable-model-invocation: true to the frontmatter.

Git Integration

Claude Code is git-aware. When you open a project that is a git repository, Claude can see your commit history, staged changes, and diffs — without you having to paste anything. This makes it useful for version control tasks alongside coding ones.

✍️Write commit messages
Write a commit message for my staged changes.
🔍Explain what changed
Summarise what changed between the last two commits 
in 02_analysis.R.
🤝Resolve a merge conflict
I have a merge conflict in 03_tables.R. Read both 
versions and resolve it, keeping the more recent 
variable names.
No git? That's fine — a Dropbox folder, a shared network drive, or a plain folder on your desktop all work equally well as the project root. Git is optional; Claude Code does not require it.

Managing the Context Window

Claude can only hold a limited amount of text in its working memory at once — roughly equivalent to a few hundred pages. For large empirical projects with many scripts and data files, this fills up quickly, and performance degrades as it approaches the limit. A few habits help:

📎Use @-mentions to be selective

Rather than letting Claude read everything, point it at the specific file you're working on.

@02_analysis.R fix the clustering in the main spec.
🗑️Start a new session for new tasks

Each new conversation in the Claude panel is a fresh context. Click the + button at the top of the Claude panel to start one, or type /clear to reset the current conversation — rather than continuing a long one for an unrelated task.

📊Check usage with /context

Type /context in the panel to see a breakdown of how your context window is being used and how much space remains.

CLAUDE.md helps here too. Because Claude reads your CLAUDE.md at the start of each session, you don't need to re-explain your project structure in every conversation — keeping prompts short and context usage low.