Skip to content

Commit 48ed689

Browse files
gavinrozziclaude
andcommitted
Add CLAUDE.md for Claude Code guidance
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ba0cca9 commit 48ed689

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

CLAUDE.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Package Overview
6+
7+
zipcodeR is an R package that simplifies working with U.S. ZIP codes. It provides an offline database of 41,877 ZIP codes with 24 attributes each, plus functions for geographic search, distance calculations, and Census data integration.
8+
9+
## Development Commands
10+
11+
```bash
12+
# Run all tests
13+
devtools::test()
14+
15+
# Run a single test file
16+
testthat::test_file("tests/testthat/test-01-zip-lookups.R")
17+
18+
# Check package (as CRAN would)
19+
devtools::check()
20+
21+
# Build documentation from roxygen comments
22+
devtools::document()
23+
24+
# Install package locally for testing
25+
devtools::install()
26+
27+
# Load package during development (without installing)
28+
devtools::load_all()
29+
```
30+
31+
## Architecture
32+
33+
### Data Layer (`data/`)
34+
Three bundled `.rda` datasets loaded lazily:
35+
- `zip_code_db` - Main ZIP code database (41,877 rows, 24 columns)
36+
- `zcta_crosswalk` - ZCTA-to-Census Tract mapping (148,897 rows)
37+
- `zip_to_cd` - ZIP-to-Congressional District mapping (45,914 rows)
38+
39+
### Source Files (`R/`)
40+
- `data.r` - Roxygen documentation for the three datasets
41+
- `zip_lookups.r` - 14 search/lookup functions that filter the datasets
42+
- `zip_helper_functions.R` - Utility functions: `normalize_zip()`, `zip_distance()`, `geocode_zip()`
43+
- `download_data.r` - `download_zip_data()` to fetch updated data from upstream
44+
- `globals.r` - Global variable declarations for NSE compliance
45+
46+
### Function Patterns
47+
All lookup functions return tibbles and accept vectors for batch operations. They use tidyverse-style programming with dplyr and the `.data` pronoun for NSE.
48+
49+
## Testing
50+
51+
Tests are in `tests/testthat/` using testthat v3:
52+
- `test-01-zip-lookups.R` - Tests for all 14 lookup functions
53+
- `test-02-data.R` - Data integrity tests
54+
- `test-03-helper-functions.R` - Utility function tests
55+
56+
## CI/CD
57+
58+
GitHub Actions workflows in `.github/workflows/`:
59+
- `R-CMD-check.yaml` - Runs `R CMD check` on Windows, macOS, and Ubuntu with multiple R versions
60+
- `pkgdown.yaml` - Builds and deploys documentation site to GitHub Pages

0 commit comments

Comments
 (0)