AgentSkillsCN

project-init

以标准化的结构初始化新的经济学研究项目。当您开始一项新研究时,可选用此技能来创建文件夹结构、配置文件以及样板代码。同时设置Git、Rix环境、Makefile,并与Dropbox/Overleaf进行集成。

SKILL.md
--- frontmatter
name: project-init
description: Initialize new economics research projects with standardized structure. Use when starting a new research project to create folder structure, configuration files, and boilerplate code. Sets up git, rix environment, Makefile, and connects to Dropbox/Overleaf.

Project Initialization

Quick Start

Run the initialization script:

bash
bash scripts/init_project.sh "project-name" "/path/to/projects"

Or manually create structure following the template below.

Standard Project Structure

code
project-name/
├── .git/
├── .gitignore
├── .here
├── CLAUDE.md               # AI assistant instructions
├── Makefile
├── README.md
├── generate_env.R          # rix environment definition
│
├── code/
│   ├── build/
│   │   └── .gitkeep
│   └── analysis/
│       └── .gitkeep
│
├── data/
│   ├── raw/
│   │   └── .gitkeep
│   ├── build/
│   │   └── .gitkeep
│   └── proc/
│       └── .gitkeep
│
└── output/
    ├── figures/
    │   └── .gitkeep
    ├── tables/
    │   └── .gitkeep
    └── paper/
        └── .gitkeep

Configuration Files

.gitignore

gitignore
# Data
data/raw/*
data/build/*
data/proc/*
!data/*/.gitkeep

# Outputs (regenerated by code)
output/tables/*.tex
output/tables/*.html
output/figures/*.pdf
output/figures/*.png
!output/*/.gitkeep

# Nix
result
result-*
.direnv/

# R
.Rhistory
.RData
.Rproj.user/
*.Rproj

# Python
__pycache__/
*.pyc
.ipynb_checkpoints/

# Julia
*.jl.cov
*.jl.mem

# LaTeX
*.aux
*.log
*.out
*.bbl
*.blg
*.fls
*.fdb_latexmk
*.synctex.gz

# OS
.DS_Store
Thumbs.db

# Editor
*.swp
*.swo
*~
.vscode/
.idea/

generate_env.R (starter template)

r
library(rix)

rix(
  r_ver = "4.3.2",
  r_pkgs = c(
    # Core
    "data.table",
    "here",
    
    # Econometrics
    "fixest",
    
    # Output
    "modelsummary",
    "ggplot2"
  ),
  system_pkgs = NULL,
  ide = "none",
  project_path = ".",
  overwrite = TRUE
)

Makefile (starter template)

makefile
.PHONY: all clean data analysis paper

all: analysis

# ============== DATA ==============
data/proc/analysis.rds: code/build/01-build-data.R
	nix-shell --run "Rscript $<"

data: data/proc/analysis.rds

# ============== ANALYSIS ==============
output/tables/main.tex output/figures/main.pdf: code/analysis/01-main.R data/proc/analysis.rds
	nix-shell --run "Rscript $<"

analysis: output/tables/main.tex

# ============== PAPER ==============
paper: output/paper/paper.pdf

output/paper/paper.pdf: output/paper/paper.qmd analysis
	nix-shell --run "quarto render $<"

# ============== CLEAN ==============
clean:
	rm -f data/build/* data/proc/*
	rm -f output/tables/* output/figures/*

Dropbox Integration

Symlink data from Dropbox

bash
# Remove empty data folder
rm -rf data

# Create symlink to Dropbox
ln -s ~/Dropbox/Projects/project-name/data data

Symlink output to Overleaf

bash
# For paper folder only
rm -rf output/paper
ln -s ~/Dropbox/Apps/Overleaf/MyPaper output/paper

Git Setup

bash
cd project-name
git init
git add .
git commit -m "Initial project structure"

# Add remote
git remote add origin git@github.com:username/project-name.git
git push -u origin main

Starting New Scripts

R Script Header

r
# ============================================================
# Script: 01-build-data.R
# Purpose: [Brief description]
# Author: [Name]
# Date: [Date]
# Inputs: data/raw/[files]
# Outputs: data/proc/[files]
# ============================================================

# Setup
library(data.table)
library(here)

# Paths
raw_dir  <- here("data", "raw")
proc_dir <- here("data", "proc")

# [Code here]

Julia Script Header

julia
#=
Script: 01-estimation.jl
Purpose: [Brief description]
Author: [Name]
Date: [Date]
Inputs: data/proc/[files]
Outputs: output/[files]
=#

using DataFrames, CSV
using FixedEffectModels
using Optim

# Paths
const DATA_DIR = joinpath(@__DIR__, "..", "data", "proc")
const OUT_DIR = joinpath(@__DIR__, "..", "output")

# [Code here]

Python Notebook First Cell

python
"""
Notebook: 01_analysis.ipynb
Author: [Name]
Email: [Email]
Date Modified: [Date]
Description: [Brief description]
Inputs: [List inputs]
Outputs: [List outputs]
"""

import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# Directories
TOP_DIR     = os.path.join(os.path.expanduser("~"), "Dropbox/Projects/project-name")
DATA_DIR    = os.path.join(TOP_DIR, "data", "proc")
OUTPUT_DIR  = os.path.join(TOP_DIR, "output")

Checklist for New Projects

  • Create folder structure
  • Initialize git repository
  • Set up .gitignore
  • Create .here file
  • Set up generate_env.R with required packages
  • Run nix-build to test environment
  • Create initial Makefile
  • Set up Dropbox symlinks (if applicable)
  • Add project-specific CLAUDE.md