-
-
Notifications
You must be signed in to change notification settings - Fork 62
Setup environment for Claude Code Web explore #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup environment for Claude Code Web explore #133
Conversation
This commit adds support for running Clojure in Claude Code's authenticated proxy environment by implementing a local proxy wrapper solution. Files added: - proxy-wrapper.py: Local HTTP/HTTPS proxy that adds authentication headers to requests before forwarding to Claude Code's authenticated proxy - setup-claude-code-env.sh: Automated setup script that configures Maven, Gradle, and Java system properties to use the local proxy - CLAUDE_CODE_SETUP.md: Documentation explaining the setup process and troubleshooting steps The solution addresses Java's limitation where it cannot send authentication headers during HTTPS CONNECT requests, which prevents Clojure CLI from accessing Maven repositories through Claude Code's proxy. Based on: https://github.com/michaelwhitford/claude-code-explore
- Move proxy-wrapper.py and setup-claude-code-env.sh to claude-code-setup/ folder - Rename CLAUDE_CODE_SETUP.md to CLAUDE_CODE_WEB_SETUP.md - Update all documentation references to reflect new file locations
WalkthroughAdds documentation and tooling to configure Claude Code's authenticated proxy environment for Java/Clojure projects. Includes a Python HTTP/HTTPS proxy wrapper that forwards traffic with authentication credentials, a Bash setup script that configures Maven/Gradle/Java system properties, and comprehensive setup documentation. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Build Tool
participant LocalProxy as Local Proxy<br/>(proxy-wrapper.py)
participant UpstreamProxy as Upstream<br/>Authenticated Proxy
participant Server as Remote Server
Client->>LocalProxy: HTTP/HTTPS Request
LocalProxy->>LocalProxy: Parse upstream proxy URL<br/>Extract credentials
LocalProxy->>UpstreamProxy: Forward with<br/>Proxy-Authorization Header
alt CONNECT Request (HTTPS)
UpstreamProxy->>Server: Establish tunnel
Server-->>UpstreamProxy: 200 Connection Established
UpstreamProxy-->>LocalProxy: 200 Response
LocalProxy-->>Client: 200 Response
Note over LocalProxy,UpstreamProxy: Bidirectional relay<br/>via select() loop
else Regular HTTP Request
UpstreamProxy->>Server: HTTP Request
Server-->>UpstreamProxy: Response
UpstreamProxy-->>LocalProxy: Response
LocalProxy-->>Client: Response
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (7)
CLAUDE_CODE_WEB_SETUP.md (1)
135-135: Format URL as proper markdown link.The bare URL should be formatted as a markdown link for better readability and to satisfy markdown linting rules.
Apply this diff:
-https://github.com/michaelwhitford/claude-code-explore +[https://github.com/michaelwhitford/claude-code-explore](https://github.com/michaelwhitford/claude-code-explore)Based on static analysis hints from markdownlint.
claude-code-setup/setup-claude-code-env.sh (2)
54-90: Consider preserving existing Maven settings.The script overwrites
~/.m2/settings.xmlif it doesn't contain "127.0.0.1". This could discard existing proxy configurations or other Maven settings users may have.For the Claude Code environment use case, this straightforward approach is probably acceptable, but consider adding a backup step or merging logic if users might have existing configurations worth preserving.
98-115: Consider preserving existing Gradle settings.Similar to the Maven configuration, this overwrites
~/.gradle/gradle.propertiesif it doesn't contain "127.0.0.1", potentially discarding existing proxy or other Gradle settings.The straightforward overwrite approach aligns with the script's purpose for Claude Code setup, but consider whether a backup or merge strategy would be beneficial.
claude-code-setup/proxy-wrapper.py (4)
20-20: Remove unused import.The
remodule is imported but never used in the code.Apply this diff:
import sys -import re from urllib.parse import urlparse
70-78: Remove unused parameter and variable.The
requestparameter is never used in this method, and thetargetvariable (line 78) is extracted but never used. This is likely dead code from development.Apply this diff:
- def handle_connect(self, client_socket, request, first_line): + def handle_connect(self, client_socket, first_line): """Handle CONNECT requests for HTTPS tunneling.""" # Extract target host:port from CONNECT line parts = first_line.split() if len(parts) < 2: client_socket.close() return - target = parts[1] - # Connect to upstream proxyAnd update the call site at line 61:
- self.handle_connect(client_socket, request, first_line) + self.handle_connect(client_socket, first_line)Based on static analysis hints from Ruff.
156-163: Improve exception handling.Two issues with the exception handling:
- Line 156: The exception is caught but not logged, which could make debugging connection issues difficult.
- Line 162: The bare
except:should be more specific.Apply this diff:
except Exception as e: + print(f"[ERROR] Relay error: {e}") break try: client_socket.close() upstream_socket.close() - except: + except Exception: passBased on static analysis hints from Ruff.
200-200: Add validation for port argument.Line 200 will raise a
ValueErrorif a non-numeric port is provided. Consider adding validation to provide a clearer error message.Apply this diff:
# Get local port from command line or use default - local_port = int(sys.argv[1]) if len(sys.argv) > 1 else 8888 + try: + local_port = int(sys.argv[1]) if len(sys.argv) > 1 else 8888 + if not (1 <= local_port <= 65535): + print(f"ERROR: Port must be between 1 and 65535, got {local_port}") + sys.exit(1) + except ValueError: + print(f"ERROR: Invalid port number: {sys.argv[1]}") + sys.exit(1)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
CLAUDE_CODE_WEB_SETUP.md(1 hunks)claude-code-setup/proxy-wrapper.py(1 hunks)claude-code-setup/setup-claude-code-env.sh(1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
CLAUDE_CODE_WEB_SETUP.md
135-135: Bare URL used
(MD034, no-bare-urls)
🪛 Ruff (0.14.5)
claude-code-setup/proxy-wrapper.py
66-66: Do not catch blind exception: Exception
(BLE001)
70-70: Unused method argument: request
(ARG002)
78-78: Local variable target is assigned to but never used
Remove assignment to unused variable target
(F841)
156-156: Do not catch blind exception: Exception
(BLE001)
156-156: Local variable e is assigned to but never used
Remove assignment to unused variable e
(F841)
162-162: Do not use bare except
(E722)
162-163: try-except-pass detected, consider logging the exception
(S110)
🔇 Additional comments (9)
claude-code-setup/setup-claude-code-env.sh (5)
1-14: LGTM!The script initialization is well-structured with appropriate error handling (
set -e), configurable proxy port with sensible default, and correct script directory resolution for sourced scripts.
21-26: LGTM!The environment check provides helpful context without blocking execution, which is appropriate since the tools might work in non-Claude Code environments.
28-52: LGTM!The proxy wrapper management logic is sound:
- Correctly checks for existing process using port-specific pattern
- Validates startup after launching
- Uses
return 1instead ofexit(appropriate for sourced scripts)- The 2-second sleep provides a reasonable balance between startup time and reliability
92-96: LGTM!Java system properties are correctly configured with proxy settings and the thread limit to avoid overwhelming the proxy.
117-135: LGTM!The completion message provides clear, actionable next steps with relevant examples for the Clojure project context.
claude-code-setup/proxy-wrapper.py (4)
23-44: LGTM!The proxy configuration parsing correctly handles URL parsing, credential extraction, and Base64 encoding for Basic authentication.
45-68: LGTM!The client handling logic is appropriate:
- Sets reasonable timeout to prevent hanging
- Correctly routes CONNECT vs regular HTTP requests
- The broad exception catch at line 66 is acceptable for a proxy that needs to handle various network errors gracefully
Note: Static analysis flagged the broad Exception catch, but this is intentional for robustness.
113-130: LGTM!The HTTP request handling correctly injects the Proxy-Authorization header when needed and forwards traffic appropriately.
166-188: LGTM!The proxy server setup is secure and appropriate:
- Listens only on localhost (security)
- SO_REUSEADDR enables quick restarts
- Daemon threads ensure clean shutdown
- KeyboardInterrupt handling allows graceful termination
|
We're going to try this now that we no longer have free credits ... |
Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.