Skip to content

Conversation

@bhauman
Copy link
Owner

@bhauman bhauman commented Nov 24, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a proxy wrapper tool for handling authenticated proxy connections with bidirectional data relay.
    • Added automated setup script to configure proxy settings for Maven, Gradle, and Java environments.
    • Streamlines development environment configuration with automatic process management and validation.
  • Documentation

    • Added detailed setup guide with step-by-step instructions, configuration examples, and troubleshooting tips for multiple platforms.

✏️ Tip: You can customize this high-level summary in your review settings.

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
@coderabbitai
Copy link

coderabbitai bot commented Nov 24, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary
Documentation
CLAUDE_CODE_WEB_SETUP.md
New guide detailing Claude Code authenticated proxy setup for Java/Clojure, including problem statement, local proxy wrapper solution, quick setup instructions, manual configuration steps, and troubleshooting.
Proxy Implementation
claude-code-setup/proxy-wrapper.py
New Python proxy wrapper with ProxyHandler class that parses upstream proxy URLs, handles HTTPS CONNECT requests with authentication, processes HTTP requests with injected Proxy-Authorization headers, and relays traffic bidirectionally using select-based I/O.
Environment Setup
claude-code-setup/setup-claude-code-env.sh
New Bash script that manages proxy-wrapper.py lifecycle, configures Maven settings.xml, Gradle gradle.properties, and JAVA_TOOL_OPTIONS environment variable to route HTTP/HTTPS traffic through the local proxy.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Proxy authentication logic: Verify Proxy-Authorization header construction from upstream URL credentials is correctly formatted and doesn't leak credentials in logs
  • Socket relay implementation: Confirm bidirectional select-based relay properly handles EOF, timeouts, and cleanup to prevent resource leaks
  • Bash configuration idempotency: Ensure Maven/Gradle file creation/update operations don't corrupt existing configurations and handle edge cases (missing directories, permission issues)
  • Environment variable handling: Validate that JAVA_TOOL_OPTIONS export doesn't conflict with existing user settings

Poem

🐰 A proxy wrapper spins with care,
Authentication secrets fair,
Local tunnel catches every flow,
Maven, Gradle—off they go!
Claude Code hops through, past the gate, 🛣️✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Setup environment for Claude Code Web explore' is vague and incomplete. It uses generic language ('explore') and doesn't clearly convey what environment is being set up or why. Revise the title to be more specific and descriptive, such as 'Add authenticated proxy setup for Claude Code Java/Clojure development' or 'Configure proxy environment for Claude Code Web integration'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/setup-environment-015AdbEGkkFM4fneetFy1WQK

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.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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.xml if 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.properties if 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 re module 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 request parameter is never used in this method, and the target variable (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 proxy

And 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:

  1. Line 156: The exception is caught but not logged, which could make debugging connection issues difficult.
  2. 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:
             pass

Based on static analysis hints from Ruff.


200-200: Add validation for port argument.

Line 200 will raise a ValueError if 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5dae6ed and 4d39ca3.

📒 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 1 instead of exit (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

@bhauman
Copy link
Owner Author

bhauman commented Nov 24, 2025

We're going to try this now that we no longer have free credits ...

@bhauman bhauman merged commit 4b201e1 into main Nov 24, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants