Skip to content

Commit 5892ccd

Browse files
committed
docs: enhance CLAUDE.md with comprehensive development commands and module organization
- Add all CI-required commands with proper flags and annotations - Add code quality requirements checklist for pre-commit validation - Add module organization section grouping modules by purpose - Enhance core components documentation with key functions and details - Update development environment section with version requirements - Add command examples for directory-level testing - Note filename inconsistencies (superviser.ex vs supervisor) - Clarify when to use State vs Redux for state management
1 parent 771c2d9 commit 5892ccd

File tree

1 file changed

+60
-11
lines changed

1 file changed

+60
-11
lines changed

CLAUDE.md

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,35 @@ This is Phoenix.SessionProcess, an Elixir library that creates a process for eac
1010

1111
### Development Commands
1212
- `mix deps.get` - Install dependencies
13+
- `mix compile` - Compile the project
14+
- `mix compile --warnings-as-errors` - Compile with strict warnings (CI requirement)
1315
- `mix test` - Run all tests
1416
- `mix test test/path/to/specific_test.exs` - Run a specific test file
15-
- `mix compile` - Compile the project
16-
- `mix docs` - Generate documentation
17+
- `mix test test/phoenix/session_process/` - Run all tests in a directory
1718
- `mix format` - Format code
19+
- `mix format --check-formatted` - Check formatting without modifying files (CI requirement)
20+
- `mix credo --strict` - Run static code analysis with strict mode (CI requirement)
21+
- `mix dialyzer` - Run type checking (first run builds PLT cache)
22+
- `mix dialyzer --halt-exit-status` - Run type checking and exit with error code on issues (CI requirement)
23+
- `mix lint` - Run both Credo and Dialyzer (defined in mix.exs aliases)
24+
- `mix docs` - Generate documentation
1825
- `mix hex.publish` - Publish to Hex.pm (requires authentication)
1926

27+
### Code Quality Requirements
28+
Before committing, ensure code passes all CI checks:
29+
1. Compiles without warnings: `mix compile --warnings-as-errors`
30+
2. Properly formatted: `mix format --check-formatted`
31+
3. Passes Credo: `mix credo --strict`
32+
4. Passes Dialyzer: `mix dialyzer --halt-exit-status`
33+
2034
### Testing
21-
The test suite uses ExUnit. Tests are located in the `test/` directory. The test helper (test/test_helper.exs:3) automatically starts the supervisor.
35+
The test suite uses ExUnit. Tests are located in the `test/` directory. The test helper (test/test_helper.exs:3) automatically starts the supervisor and configures the default TestProcess module.
2236

2337
### Development Environment
24-
The project uses `devenv` for development environment setup with Nix. Key configuration:
25-
- Uses Elixir/BEAM 27
26-
- Runs `hello` script on shell entry for greeting
38+
The project uses `devenv` for development environment setup with Nix:
39+
- Elixir 1.18+ with OTP 28+ (minimum: Elixir 1.14, OTP 24)
2740
- Includes git, figlet, and lolcat tools
41+
- Run `devenv shell` to enter the development environment
2842

2943
### Benchmarking
3044
Performance testing available via:
@@ -38,37 +52,72 @@ Expected performance:
3852

3953
## Architecture
4054

55+
### Module Organization
56+
57+
The library is organized into several logical groups:
58+
59+
**Core API** (primary interface for users):
60+
- `Phoenix.SessionProcess` - Main public API
61+
- `Phoenix.SessionProcess.SessionId` - Plug for session ID generation
62+
63+
**Internals** (supervision and lifecycle management):
64+
- `Phoenix.SessionProcess.Supervisor` - Top-level supervisor (Note: filename is `superviser.ex`)
65+
- `Phoenix.SessionProcess.ProcessSupervisor` - Dynamic supervisor for sessions (Note: filename is `process_superviser.ex`)
66+
- `Phoenix.SessionProcess.Cleanup` - TTL-based cleanup
67+
- `Phoenix.SessionProcess.DefaultSessionProcess` - Default session implementation
68+
69+
**State Management Utilities**:
70+
- `Phoenix.SessionProcess.State` - Agent-based state storage
71+
- `Phoenix.SessionProcess.Redux` - Redux-style state with actions/reducers
72+
- `Phoenix.SessionProcess.MigrationExamples` - Migration examples for Redux
73+
74+
**Configuration & Error Handling**:
75+
- `Phoenix.SessionProcess.Config` - Configuration management
76+
- `Phoenix.SessionProcess.Error` - Error types and messages
77+
78+
**Observability**:
79+
- `Phoenix.SessionProcess.Telemetry` - Telemetry event emission
80+
- `Phoenix.SessionProcess.TelemetryLogger` - Logging integration
81+
- `Phoenix.SessionProcess.Helpers` - General utilities
82+
4183
### Core Components
4284

4385
1. **Phoenix.SessionProcess** (lib/phoenix/session_process.ex:1)
4486
- Main module providing the public API
4587
- Delegates to ProcessSupervisor for actual process management
4688
- Provides two macros: `:process` (basic) and `:process_link` (with LiveView monitoring)
89+
- Key functions: `start/1-3`, `call/2-3`, `cast/2`, `terminate/1`, `started?/1`, `list_session/0`
4790

4891
2. **Phoenix.SessionProcess.Supervisor** (lib/phoenix/session_process/superviser.ex:1)
4992
- Top-level supervisor that manages the Registry, ProcessSupervisor, and Cleanup
5093
- Must be added to the application's supervision tree
94+
- Supervises: Registry, ProcessSupervisor, and Cleanup GenServer
5195

5296
3. **Phoenix.SessionProcess.ProcessSupervisor** (lib/phoenix/session_process/process_superviser.ex:1)
5397
- DynamicSupervisor that manages individual session processes
5498
- Handles starting, terminating, and communicating with session processes
55-
- Performs session validation and limit checks
99+
- Performs session validation and limit checks (max sessions, rate limiting)
100+
- Emits telemetry events for all operations
56101

57102
4. **Phoenix.SessionProcess.SessionId** (lib/phoenix/session_process/session_id.ex)
58103
- Plug that generates unique session IDs
59-
- Must be placed after `:fetch_session` plug
104+
- Must be placed after `:fetch_session` plug in router pipeline
105+
- Assigns session_id to conn.assigns for use in controllers/LiveViews
60106

61107
5. **Phoenix.SessionProcess.Cleanup** (lib/phoenix/session_process/cleanup.ex:1)
62-
- Automatic TTL-based session cleanup
108+
- GenServer for automatic TTL-based session cleanup
63109
- Schedules session expiration on creation
110+
- Runs cleanup tasks periodically
64111

65112
6. **Phoenix.SessionProcess.Redux** (lib/phoenix/session_process/redux.ex:1)
66113
- Redux-style state management with actions and reducers
67114
- Provides time-travel debugging, middleware support, and action history
115+
- Best for complex applications requiring predictable state updates
68116

69117
7. **Phoenix.SessionProcess.State** (lib/phoenix/session_process/state.ex:1)
70-
- Agent-based state storage with Redux-style dispatch support
71-
- Used for simpler state management scenarios
118+
- Agent-based state storage with simple get/put operations
119+
- Also supports Redux-style dispatch for hybrid approaches
120+
- Best for simple state management scenarios
72121

73122
### Process Management Flow
74123

0 commit comments

Comments
 (0)