Skip to content

Commit ca94563

Browse files
Add claude instrusctions
1 parent 0cf9698 commit ca94563

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

CLAUDE.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Development Commands
6+
7+
**Setup Development Environment:**
8+
```bash
9+
uv sync --dev
10+
```
11+
12+
**Run Tests:**
13+
```bash
14+
uv run pytest tests/
15+
```
16+
17+
**Run Specific Test:**
18+
```bash
19+
uv run pytest tests/test_<module_name>.py
20+
```
21+
22+
**Linting and Formatting:**
23+
```bash
24+
uv run ruff check
25+
uv run ruff format
26+
```
27+
28+
**Documentation:**
29+
```bash
30+
# Serve docs locally with auto-reload
31+
uv run mkdocs serve
32+
33+
# Build documentation
34+
uv run mkdocs build
35+
36+
# Export documentation dependencies for Read The Docs
37+
uv export --no-hashes --format requirements-txt --group documentation > docs/requirements.txt
38+
```
39+
40+
## Architecture Overview
41+
42+
This is an embeddable asyncio-based HTTPS forward proxy library designed for integration into Python applications rather than standalone use.
43+
44+
### Core Components
45+
46+
**Handler Pattern Architecture:**
47+
- `HTTPSProxyHandler`: Base class that applications subclass to implement custom proxy behavior
48+
- Each client connection creates a new handler instance
49+
- Key lifecycle methods: `on_client_connected()`, `on_request_received()`
50+
- Handlers control request forwarding and response streaming
51+
52+
**TLS Certificate Management:**
53+
- `TLSStore`: Manages dynamic certificate generation and signing for HTTPS interception
54+
- Self-signed CA certificate system for SSL/TLS traffic interception
55+
- Certificates generated on-demand for target hosts
56+
57+
**HTTP Processing Pipeline:**
58+
- `HTTPRequest`: Parses incoming HTTP requests (method, URL, headers, body)
59+
- `HTTPHeader`: Header parsing and manipulation utilities
60+
- `server.py`: Main server orchestration and connection handling
61+
- Request body streaming via async generators
62+
63+
**Key Integration Points:**
64+
1. Applications create custom handler classes inheriting from `HTTPSProxyHandler`
65+
2. Use `start_proxy_server()` with handler builder function and `TLSStore` instance
66+
3. Handler methods receive parsed `HTTPRequest` objects and control response flow
67+
4. Built-in support for both HTTP and HTTPS traffic interception
68+
69+
### Development Notes
70+
71+
- Python 3.13+ required
72+
- Uses `uv` for dependency management (not pip/poetry)
73+
- Pure asyncio implementation with streaming support
74+
- Only external dependency: `cryptography` for TLS operations
75+
- Test suite uses pytest with asyncio support

0 commit comments

Comments
 (0)