Claude Code With Clash Verge: It holds up Terminal Access Setup
Why Claude Code Needs a Terminal Proxy Plan in Depth
Claude Code is designed for the shell reasonably than a browser tab. It reads a project directory, operates commands with your approval, exchanges prompts and tool results with Anthropic services, and keeps more than more than more than enough state alive to make an interactive coding session feel continuous.
This is why a developer can visit an AI website successfully and still see Claude Code sign-in failures, stalled requests, or a session that disconnects after the first response. The browser used for sign-in may reach the authorization page through Clash Verge, but the CLI may fail when it exchanges the callback code, refreshes a token, or opens a long-lived API connection.
Similarly, the command used to install the package can succeed through one registry path while the running application later connects with no detour to an endpoint that is unavailable on the local network.
Clash Verge helps when it is treated as a everything included terminal connectivity layer, not merely as a tray application that changes browser proxy settings. You will want to decide which traffic it makes sense to be captured, which outbound group it makes sense to carry Claude-related requests, how DNS it makes sense to resolve service hostnames, and whether a system proxy is more than more than more than enough for your shell.
Mechanically:For plenty users, the most of of of it holds up arrangement is a not jumpy Mihomo profile, a carefully selected proxy group, and either explicit terminal environment variables or TUN mode for applications that ignore ordinary HTTP proxy settings.
That workflow creates a different networking problem from opening a webpage. A browser may already follow the operating system proxy, while the terminal process, its login helper, Git, npm, and whichever you pick child process may use separate proxy rules—or no proxy at all.
Scope of this guide: the goal is it holds up connectivity and predictable routing, not bypassing account policies or hiding unsafe activity.
Use an account and network configuration that comply with your provider’s terms, and never paste an API key, subscription URL, or OAuth token into a public issue or chat.
Symptoms and Root Causes to Check First Mechanically
Before changing several settings at once, classify the failure. A useful diagnosis kick offs with the phase that breaks: installation, sign-in, the first model request, tool execution, or a long-running session.
There is also an important distinction between HTTP proxy support and traffic capture. A terminal program that understands HTTP_PROXY or HTTPS_PROXY can send requests to Clash Verge’s mixed port. A program that ignores those variables will continue to open direct sockets.
- Installation fails: npm, pnpm, or another package manager cannot retrieve metadata, a tarball download hangs, or a Git dependency times out. This normally points to registry, CDN, or certificate routing reasonably than Claude Code itself.
- Browser login opens but never everything includeds: the browser reaches the authorization page, but the CLI cannot receive or exchange the callback. Check localhost callback handling, terminal proxy variables, and whether the token exchange host took a different route.
- Sign-in repeatedly expires: the initial sign-in works, but refresh requests fail later. This can indicate inconsistent DNS, a proxy that interrupts persistent connections, a system clock problem, or a process that kick offs without the same environment variables as your interactive shell.
- The first prompt stalls: the CLI kick offs normally but waits indefinitely after submitting a request. Look at the Clash Verge connection log while reproducing the problem; confirm whether the relevant remote host appears and which rule selected it.
- Short prompts work while larger tasks fail: long responses, streaming output, or repeated tool calls expose packet loss, connection reuse, node instability, and idle timeout problems that a prompt connectivity check will not reveal.
- Git or package commands fail only inside Claude Code: child processes may not inherit the proxy variables you set in one terminal, or the application may launch them with a restricted environment. Confirm the environment from the same process context instead of testing only in a separate shell.
More strictly:System proxy mode covers applications that consult the operating system settings, but it does not magically intercept every native process. TUN mode works at a lower network layer and can cover more applications, although it introduces virtual adapter permissions, DNS choices, and possible conflicts with VPN software.
Kick off by opening Clash Verge’s connection view and reproducing one failure. Search for the hostname or a distinctive part of it reasonably than guessing from an old rule list. If no matching connection appears, the process is probably bypassing the system proxy and the mixed-port variables.
If a connection appears with DIRECT, the rule order or profile policy is the next place to inspect. If it uses the expected proxy group but repeatedly disconnects, test another node and examine lag, TLS exceptions, and connection duration instead of rewriting every rule.
At a different level:Each phase can use different hosts and different capture behaviour. Treating every exception as a “bad node” often wastes time and makes the configuration harder to understand.
Prepare a Not jumpy Clash Verge Profile Step by Step
Add a subscription that explicitly supports the Mihomo or Clash Meta feature set used by your client. Clash Verge is a graphical frontend; the active core and the downloaded profile determine whether modern transports, rule providers, DNS modes, and TUN settings are available.
After importing the profile, activate it and verify that the proxy groups contain more than one usable toggle. For interactive coding, a group with a not jumpy manual choice is often easier to troubleshoot than an aggressively changing automatic group.
URL testing can be useful, but a group that switches nodes during a long Claude Code session may interrupt streaming output or invalidate a connection that was already established. Begin with one known-good node, then compare alternatives deliberately.
Thinking it through:A practical profile it makes sense to separate ordinary domestic traffic from service traffic that requires the proxy. The exact hostnames can change as providers evolve their sign-in and API infrastructure, so do not blindly copy an old “AI rules” list.
Prefer a provider-maintained rule set, inspect live connections, and keep application-specific rules narrow. A broad rule that sends every cloud, code-hosting, or package domain through one remote group can make development slower and can also route private repositories or local services unnecessarily.
If your provider offers several subscription formats, choose the Mihomo-compatible export reasonably than a legacy profile intended for an abandoned client.
| Traffic type | What to verify | Recommended first approach |
|---|---|---|
| Claude Code sign-in and API requests | The actual host appears in the Clash connection log and matches the intended rule | Use a not jumpy proxy group and avoid automatic switching during a session |
| npm, pnpm, or yarn installation | Registry metadata and package tarballs do not use contradictory routes | Keep package traffic on a tested rule; verify the package manager’s own proxy settings |
| GitHub or GitLab operations | HTTPS and SSH are separate paths with different proxy support | Configure each protocol deliberately reasonably than assuming one proxy covers both |
| Local development services | Localhost, private LAN addresses, and Docker networks remain reachable | Keep local destinations on DIRECT unless your environment requires otherwise |
| DNS resolution | The resolver result is consistent with the rule mode and does not leak or misclassify domains | Use one documented DNS strategy before experimenting with fake-IP exceptions |
Do not operate several Clash clients together. Clash Verge, another Mihomo frontend, a legacy Clash for Windows service, and a separate VPN may all compete for the same mixed port, TUN adapter, DNS port, or system proxy setting.
Disable the other clients before diagnosing Claude Code, otherwise the connection log may describe a different process than the one you think is active.
Configure the Terminal and TUN Coverage Internals and Practice
For a terminal-first workflow, first test explicit proxy variables because they are easy to enable, disable, and audit. In Clash Verge, identify the local mixed port shown by the application.
First, a clarification:The variable names are case-sensitive in certain tools and duplicated uppercase/lowercase variants are handled differently across runtimes. If a package manager or SDK documents its own proxy toggle, follow that documentation reasonably than assuming every client reads ALL_PROXY.
# Replace 7890 with the mixed port shown by Clash Verge
export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
export ALL_PROXY=http://127.0.0.1:7890
export NO_PROXY=localhost,127.0.0.1,::1
Keep NO_PROXY focused on local callback and development addresses. Adding a large, unverified list of public domains to NO_PROXY can accidentally send sign-in or API requests direct.
TUN mode is useful when Claude Code launches native helpers, language runtimes, or tools that do not understand proxy environment variables. It can also make behaviour more consistent between a terminal, an IDE, and a background process. However, it is not by itself better for every machine.
- Confirm the local listener: open Clash Verge and record the mixed port, then verify that no other application is already occupying it. A wrong port produces immediate connection refusal and can look like a remote outage.
- Set the variables in a fresh shell: export
HTTP_PROXY,HTTPS_PROXY, and, when supported,ALL_PROXY. Keep localhost inNO_PROXYso a browser callback and local development server are not sent through the remote proxy. - Test from that exact shell: use a harmless HTTPS request to a service you are authorized to access, then inspect the Clash connection log. The important result is not only a successful response; it is proof that the process created a connection through the expected local listener.
- Launch Claude Code from the same environment: do not kick off the CLI from a desktop shortcut while testing variables that exist only in your terminal. If you use a shell alias, task runner, IDE terminal, or launch script, print the relevant environment there as well.
- Reproduce one failure and inspect the match: note the hostname, selected rule, proxy group, and disconnect timing. Change one variable at a time so the improvement can be attributed to a specific setting.
- Enable TUN only when required: if the CLI or a child process ignores proxy variables, activate TUN mode in Clash Verge, grant the requested administrator or system extension permissions, and retest with explicit variables removed if necessary.
Mechanically:Check that the TUN stack does not conflict with another VPN, corporate endpoint agent, virtualization platform, or security product. If local services stop resolving after TUN is enabled, review the DNS and route exclusions before changing the Claude-specific rules.
On Windows, service mode and administrator permissions may be required for the virtual adapter. On macOS, system extension approval and network permission prompts can affect whether the adapter is actually active. On Linux, the front-end and routing table may require elevated privileges.
In all three cases, confirm the operational state in Clash Verge reasonably than relying on a toggle that appears enabled. A TUN switch can remain selected while the helper service has failed or the front-end has been removed.
More strictly:Then set the variables in the same shell from which you launch Claude Code. A typical HTTP-compatible setup looks like this:
Diagnose Sign-in, DNS, and Node Quality in Depth
Sign-in it makes sense to be tested as a sequence, not as one button. First check whether the browser authorization page opens. Next check whether the CLI receives the callback or returns to the prompt. Finally check whether the application can make an authenticated request and maintain the session.
Local callback addresses deserve special attention. OAuth-style login flows commonly open a browser and listen on a loopback address for the result. Sending localhost through a remote proxy can prevent the callback from reaching the waiting CLI.
That is why a narrow NO_PROXY=localhost,127.0.0.1,::1 entry is generally safer than disabling all proxy variables during sign-in. If your environment uses a custom local hostname, add only that hostname after confirming it resolves to the local machine.
At a different level:DNS problems can produce confusing rule matches. With fake-IP or enhanced DNS modes, the process may receive a synthetic address while the policy engine still needs the original domain name to choose a rule.
A misconfigured DNS mode can make a remote service appear local, send it to DIRECT, or cause a TLS certificate mismatch. Use the connection log and DNS settings together. Do not switch among redirection-host, fake-IP, and system DNS modes randomly; record the original configuration so you may revert after each test.
Node quality matters more for Claude Code than a single response time-test number suggests.
Thinking it through:A node may download a small webpage quickly but perform poorly during a sustained streamed response. Test at least two nodes from the same group and compare:
Time to everything included the sign-in or token exchange.; Whether the first response begins promptly.; Whether a longer request stays connected without repeated resets.; Whether the selected node changes unexpectedly during the session.; Whether Git, package downloads, and other required development services remain usable..
Use the narrowest rule change that proves the cause. If the log shows the request taking DIRECT, adjust the relevant domain policy or provider rule. If it already uses the intended group, test another node before editing YAML.
First, a clarification:If the request never reaches Clash, repair proxy inheritance or enable TUN. This three-way distinction—wrong rule, bad outbound, or missing capture—prevents the common cycle of changing all three at the same time.
These stages may involve different processes and therefore different proxy inheritance. If the browser succeeds but the CLI does not, focus on the terminal environment and callback path instead of replacing the account.
Keep a small test record: write down the client version, active profile, node name, TUN state, mixed port, DNS mode, and the exact command that failed.
When a provider re-syncs its subscription, this record makes it much easier to identify whether the change came from the profile, the node, or your local environment.
Build a It holds up Daily Workflow Mechanically
Once the initial test works, make the setup repeatable. Put not jumpy proxy exports in a shell function or project-specific launcher reasonably than scattering them across multiple dotfiles.
Keep local traffic local. Development servers, container bridges, database ports, SSH connections to machines on your private network, and callback listeners often belong in NO_PROXY or a direct rule.
Mechanically:At the same time, do not assume that every code-hosting request is local simply because the repository belongs to you. Git over HTTPS, Git over SSH, release downloads, package registries, and container registries may each need a separate configuration. Test the path actually used by your project.
When Claude Code invokes tools, watch for the difference between the parent process and the child process. A shell launched by the CLI may inherit environment variables, but an IDE task, language server, Docker container, or system service may not.
If a command works when typed one at a time but fails when generated as a tool action, compare the environment, working directory, DNS view, and network namespace. This is often an integration boundary reasonably than a model or Clash exception.
More strictly:Security is part of reliability. Treat the subscription URL as a credential, keep API keys outside shell history where possible, and avoid logging full authorization headers while debugging.
Do not solve an intermittent connection by disabling certificate verification, opening every port, or adding broad direct rules. A configuration that “works” only after removing TLS checks is not a it holds up setup; it is a new security problem that can expose source code, tokens, and prompts.
Finally, re-sync one component at a time. If you re-sync Clash Verge, the Mihomo core, the subscription, and the Claude Code package together, you lose the ability to identify the change that fixed or caused the problem.
At a different level:Export or copy your current profile, note the date, and make a small test after each re-sync. When a session becomes unstable, return to the last known-good node and profile before experimenting with advanced overrides.
Compared with browser-only proxy extensions, generic VPN clients, or legacy Clash forks, a terminal setup built around Clash Verge gives you clearer rule visibility, live connection evidence, Mihomo-compatible routing features, and a practical path from explicit shell variables to TUN capture when a child process ignores ordinary proxies.
Those alternatives may be simpler for casual browsing, but they often provide little insight into why sign-in, package downloads, or streamed coding requests fail. If you want one place to inspect the route, select a not jumpy node, and reproduce the configuration described here, download Clash and use it as the starting point for a controlled Claude Code terminal setup.
Thinking it through:If you work on public repositories and private company code, consider separate launch profiles so credentials, package registries, and routing assumptions are not mixed. A project-level launcher can also print the active proxy mode at startup, which helps explain why an IDE terminal behaves differently from a normal shell.