This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
pnpm build- Compile TypeScript to JavaScriptpnpm clean- Remove dist/ directorypnpm sample- Run example code from samples/
pnpm test- Run all tests (unit, integration, e2e)pnpm test:unit- Unit tests onlypnpm test:integration- Integration tests onlypnpm test:e2e- End-to-end tests onlypnpm test:watch- Unit tests in watch modepnpm test:integration:watch- Integration tests in watch modepnpm test:e2e:watch- E2E tests in watch mode
pnpm lint- Check code style and formattingpnpm lint:fix- Auto-fix linting issuespnpm format- Format code with Prettierpnpm format:check- Check formatting without changing files
Required before committing: Run pnpm lint, pnpm build, and pnpm test
This is a TypeScript client library for the Substack API using a service-oriented architecture:
- SubstackClient (
src/substack-client.ts) - Main client class that orchestrates services - Services (
src/internal/services/) - Business logic organized by domain (posts, notes, profiles, comments, etc.) - Domain Models (
src/domain/) - Entity classes with methods (Profile, Post, Note, Comment) - HTTP Layer (
src/internal/http-client.ts) - Abstraction over HTTP requests with error handling - Caching (
src/internal/cache/) - In-memory caching with decorator pattern
- Entity-based API: Domain objects have methods (e.g.,
post.comments(),profile.posts()) - Iterator Pattern: Pagination handled via async iterators (
for await (const post of profile.posts())) - Builder Pattern:
NoteBuilderfor constructing formatted notes - Service Layer: Separation of HTTP concerns from business logic
- Functional Programming: Uses fp-ts and io-ts for validation and error handling
- fp-ts: Functional programming utilities
- io-ts: Runtime type validation
- Jest: Testing framework with separate configs for unit/integration/e2e tests
- Unit tests: Mock HTTP responses, test business logic
- Integration tests: Real API calls with test data
- E2E tests: Full workflow tests requiring API credentials
src/domain/- Domain entities and builderssrc/internal/- Internal services, HTTP client, validation, typessrc/types/- Public type definitionstests/unit/- Unit teststests/integration/- Integration teststests/e2e/- End-to-end testssamples/- Example usage code
Follow Conventional Commits:
feat: add post schedulingfix: correct auth token refreshchore: update dependencies
Pull request titles should use the same format.