Claude Code Quick Reference

Copy-paste templates, file locations, and syntax for skills, hooks, MCP servers, and agents.


File Locations Summary

All Claude Code configuration uses two locations: project-local (applies to one project) and global (applies everywhere).

Component Project-Local Global
Skills .claude/skills/ ~/.claude/skills/
Hooks .claude/settings.json ~/.claude/settings.json
MCP Servers .mcp.json ~/.claude/settings.json
Context CLAUDE.md ~/.claude/CLAUDE.md

Resolution order: Claude Code checks project-local first, then global. Project-local settings override global ones with the same name.


Skills: Template & Syntax

File Location

Project: .claude/skills/skill-name.md
Global: ~/.claude/skills/skill-name.md

Skill File Template

# Skill Name

## Purpose

One sentence describing what this skill does.

## Prerequisites

- What must be true before running
- Files that must exist
- Data that must be loaded

## Workflow

1. **Step name:** Description of first step
2. **Step name:** Description of second step
3. **Present for review:** Show results before saving
4. **Final step:** Complete the task

## Success Criteria

- How we know the skill succeeded
- What the output should contain
- Verification checks to run

## Parameters (optional)

- `--option`: What this option does
- `--format`: Output format (latex, markdown, html)

Running Skills

# Basic invocation
/skill-name

# With options
/skill-name --option value

# With arguments
/skill-name table-3

When to Use Project vs. Global

Project-Local Skills

Use when workflow depends on project-specific details: variable names, data structure, identification strategy, sample definitions.

Examples: balance-table, main-regression, sensitivity-check

Global Skills

Use when workflow is the same regardless of project: general research practices, writing standards, verification procedures.

Examples: lit-search, citation-verify, style-pass, reg-table


Hooks: Configuration

File Location

Project: .claude/settings.json
Global: ~/.claude/settings.json

Basic Hook Configuration

{
  "hooks": {
    "precommit": {
      "script": ".claude/hooks/pre-commit-checks.sh",
      "description": "A quick reference for Claude Code: the skills, hooks, MCP servers, sub-agents, and slash-commands worth knowing, with a one-line note on each.",
      "async": false
    }
  }
}

Multiple Hooks with Order

{
  "hooks": {
    "precommit": [
      {
        "name": "syntax",
        "script": ".claude/hooks/stata-syntax.sh",
        "order": 1
      },
      {
        "name": "paths",
        "script": ".claude/hooks/check-paths.sh",
        "order": 2
      }
    ]
  }
}

Hook Trigger Points

Trigger When It Fires Use Case
precommit Before saving to version control Syntax checks, path validation
postedit After files are modified Update documentation, validate changes
session_start When Claude Code launches Load context, show status
session_end When session closes Log activity, capture decisions
pattern When pattern appears in content Validate citations, document variables

Hook Script Template

#!/bin/bash
# .claude/hooks/example-hook.sh

set -e  # Stop on errors
trap 'echo "Hook failed at line $LINENO"' ERR

# Get staged files (for precommit hooks)
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)

# Skip if no relevant files
if [ -z "$STAGED_FILES" ]; then
    echo "No relevant files. Skipping."
    exit 0
fi

# Run checks
echo "Running checks..."

# Your validation logic here

# Report results
if [ -n "$ERRORS" ]; then
    echo "Problems found:"
    echo "$ERRORS"
    exit 1  # Block the action
fi

echo "All checks passed."
exit 0  # Allow the action

MCP Servers: Setup

File Location

Project: .mcp.json (in project root)
Global: ~/.claude/settings.json (add mcpServers section)

Project-Local Configuration (.mcp.json)

{
  "mcpServers": {
    "fred": {
      "command": "npx",
      "args": ["-y", "@anthropic/fred-mcp-server"],
      "env": {
        "FRED_API_KEY": "your-api-key-here"
      }
    },
    "census": {
      "command": "npx",
      "args": ["-y", "@anthropic/census-mcp-server"],
      "env": {
        "CENSUS_API_KEY": "your-api-key-here"
      }
    }
  }
}

Global Configuration (~/.claude/settings.json)

{
  "mcpServers": {
    "fred": {
      "command": "npx",
      "args": ["-y", "@anthropic/fred-mcp-server"],
      "env": {
        "FRED_API_KEY": "your-api-key-here"
      }
    }
  },
  "hooks": {
    // hooks go here
  }
}

Common MCP Servers for Economics Research

Service What It Provides API Key Source
FRED 800,000+ economic time series fred.stlouisfed.org
Census ACS, decennial, economic surveys census.gov/developers
BLS Employment, wages, CPI bls.gov/developers
Google Scholar Paper search, citations Varies by implementation

Agents: Creation

Natural Language (Simplest)

Just describe what we want. Claude creates the agent automatically if delegation is appropriate.

"Research alternative estimators for difference-in-differences
with staggered treatment timing. Compare Callaway and Sant'Anna,
Sun and Abraham, and Borusyak et al."

Explicit Delegation (More Control)

"Create a helper to research this. I want it to run in the
background while we continue discussing the identification strategy."
"Spawn a research agent to explore synthetic control methods.
Have it focus on inference approaches and return a comparison
of permutation tests vs. conformal inference."

Running Multiple Agents

"Create three helpers in parallel:
1. Research Callaway-Sant'Anna implementation in Stata
2. Find papers using staggered DiD in minimum wage studies
3. Summarize the Goodman-Bacon decomposition"

Agent Types

Type Best For
Research/Explore Literature review, comparing approaches, gathering information
Implementation Writing code, building scripts, creating files
Documentation Generating docs, reviewing code, creating codebooks

The Delegation Heuristic

Delegate When:

We can name the task precisely AND we can verify the result independently.

"Find five empirical papers published 2020-2024 using staggered DiD with heterogeneity-robust estimators in labor economics, noting which estimator each uses."

Keep Local When:

We need iteration, refinement, or back-and-forth to clarify what we want.

Building a regression specification, debugging code, developing an identification strategy.


CLAUDE.md: Structure

File Location

Project: CLAUDE.md (in project root)
Global: ~/.claude/CLAUDE.md

CLAUDE.md Template for Research Projects

# Project: [Research Paper Title]

## Current Status
[One sentence on where we are in the research process]

## Research Question
[The core question this paper addresses]

## Identification Strategy
[Brief description of causal identification approach]
- Treatment: [what varies]
- Control: [comparison group]
- Threats: [main concerns]

## Data Sources
- [Dataset 1]: [description, years, key variables]
- [Dataset 2]: [description, years, key variables]

## Key Variables
| Variable | Definition | Source |
|----------|-----------|--------|
| outcome_var | Description | Dataset |
| treatment_var | Description | Dataset |

## Current Analysis Phase
[exploratory / first draft / revision / resubmission]

## Active Decisions
- [Decision 1 we are currently working on]
- [Decision 2 under consideration]

## Coding Conventions
- Standard errors: [clustering level and rationale]
- Fixed effects: [what we include and why]
- Sample restrictions: [who is excluded and why]

## File Structure
- code/: Analysis scripts
- data/raw/: Original data files
- data/processed/: Cleaned datasets
- output/: Tables and figures

What to Include vs. Exclude

Include

Information needed to make correct decisions: identification strategy, variable definitions, sample restrictions, coding conventions, current status.

Exclude

Information that wastes context: full literature review, complete regression output, lengthy background. Link to external docs instead.


← Back to Claude Code Guide