Skip to content

Commit 03054b9

Browse files
committed
Add CLAUDE.md
1 parent 3b5af3a commit 03054b9

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

CLAUDE.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Common Development Commands
6+
7+
- **Setup**: `bin/setup` - Installs gem dependencies via bundle install
8+
- **Tests**: `bundle exec rspec` - Runs the full test suite using RSpec
9+
- **Console**: `bin/console` - Opens IRB with the gem loaded for interactive testing
10+
- **Install locally**: `bundle exec rake install` - Installs gem to local machine
11+
- **Build**: `bundle exec rake build` - Builds the gem file
12+
- **Release**: `bundle exec rake release` - Creates git tag, pushes commits/tags, and publishes to RubyGems
13+
- **CLI**: `readwise` - Command-line tool to send HTML content to Readwise Reader
14+
15+
## Codebase Architecture
16+
17+
This is a Ruby gem that provides a client library for the Readwise API. The architecture follows standard Ruby gem conventions:
18+
19+
### Core Components
20+
21+
- **Client** (`lib/readwise/client.rb`): Main API client handling both V2 (Highlights) and V3 (Reader) APIs
22+
- V2 API (BASE_URL): Highlights, books, tags, daily review functionality
23+
- V3 API (V3_BASE_URL): Reader documents functionality
24+
- All HTTP requests use Net::HTTP with token-based authentication
25+
- Pagination handled automatically for export and document listing
26+
27+
- **Data Models**: Immutable structs representing API entities
28+
- `Book`: Represents a book with highlights, metadata, and tags
29+
- `Highlight`: Individual highlight with text, location, tags, and metadata
30+
- `Document`: Reader documents (articles, PDFs) with reading progress and categorization
31+
- `Tag`: Simple name/ID structure for organizing content
32+
- `Review`: Daily review sessions with associated highlights
33+
34+
### Key Patterns
35+
36+
- **Transformation Methods**: Private methods in Client (`transform_*`) convert API responses to Ruby objects
37+
- **Serialization**: Create/Update classes have `serialize` methods for API payloads
38+
- **Pagination**: Automatic cursor-based pagination for large result sets
39+
- **Error Handling**: Custom `Readwise::Client::Error` for API failures
40+
41+
### Test Structure
42+
43+
- Tests use RSpec with file fixtures from `spec/fixtures/`
44+
- JSON fixtures represent actual API responses for consistent testing
45+
- Test files mirror the lib directory structure
46+
- Uses `rspec-file_fixtures` gem for loading test data
47+
- CLI tests in `spec/readwise_spec.rb` test error handling and argument validation
48+
49+
### CLI Tool
50+
51+
The gem includes a `readwise` CLI command that reads HTML content from a file and sends it to Readwise Reader:
52+
53+
- Requires `READWISE_API_KEY` environment variable
54+
- Takes HTML file path as first argument
55+
- Supports all DocumentCreate parameters as flags
56+
- Example: `readwise --title="My Article" --location=later content.html`

0 commit comments

Comments
 (0)