Run Claude Code and Set Up Claude Code Router in Termux(Android)
Introduction
I realize it’s been quite a while since I last posted - life has been incredibly hectic lately, and I’ve barely had time to tinker with fun projects. Claude Code, Anthropic’s official CLI tool that brings Claude’s capabilities directly to the terminal, and decided to explore how to get it running on Termux. As someone who regularly uses Cursor + Claude Code in my daily development workflow, I was already familiar with how powerful this combination can be.
It’s time to run claude code in Termux? The idea of having a full-fledged AI coding assistant running natively on my Android phone was just too interesting to pass up.(Good for those old phones running third party ROM lmao) Sure, it might not be the most practical setup for everyday development work, but there’s something genuinely exciting about pushing the boundaries of what’s possible on mobile devices.
Actually, let me be honest here - the whole setup took me about 15 minutes once I figured out the right approach. I successfully got Claude Code running on Termux and even managed to set up Claude Code Router to seamlessly switch between different AI models. It’s surprisingly simple once you know what you’re doing and its basically same as what you do with npm on your computer.
In this guide, I’ll walk you through the entire journey - from installing the necessary dependencies to configuring Claude Code Router for maximum flexibility. Whether you’re someone who loves experimenting with unconventional setups, a developer who occasionally needs AI assistance on the go, or just curious about what’s possible with modern mobile computing, this setup might spark your interest.
This post was written with Claude Code - yes, using the exact same Termux setup I just described. Pretty cool, right?
Feels like a better way to run ollama. Made me think about open interpreter. ye it’s been quiet a long time.
As you can see in the screenshot above, the entire workflow runs smoothly in Termux - from the initial installation process on the left, to the permission confirmation in the middle, to Claude Code Router actively helping with real tasks like trip planning on the right.
Prerequisites
Before diving into the Claude Code installation, let me walk you through what you’ll need to have ready. The good news is that most of this is pretty standard stuff if you’ve used Termux before.
What You’ll Need:
- An Android device with Termux installed
- A stable internet connection
- About 200MB of free storage space
First things first - make sure you have Termux installed from F-Droid, not from Google Play Store. The Play Store version is outdated and will cause you headaches. If you already have the Play Store version, uninstall it and grab the proper one from F-Droid: https://f-droid.org/en/packages/com.termux/
Once you’ve got Termux running, we need to set up the basic environment:
1 | #Change sources (you might need this) |
Note that npm comes bundled with Node.js, so you don’t need to install it separately. I should mention that Claude Code requires Node.js 18 or higher. The version that comes with Termux’s package manager should work fine, but if you run into any issues, that’s the first thing to check.
Installing Claude Code
Now download Claude code
1 | # Install Claude Code globally |
That’s it. Seriously. If you’ve used npm before, this is exactly what you’d expect. The installation might take a few minutes depending on your internet connection, but there’s nothing tricky about it.
Once installed, you can start Claude Code right away:
1 | # Start Claude Code - this should work immediately |
If you don’t want to use Claude’s own service, you can use the router instead. Otherwise, Claude Code will handle authentication automatically through Anthropic’s console, and you’ll be guided through any necessary setup steps interactively.
Setting Up Claude Code Router
Here’s where things get interesting. Claude Code Router is a community project that adds powerful model switching capabilities to Claude Code. It allows you to route different types of requests to different AI models - for example, using a fast local model for simple tasks and a powerful cloud model for complex reasoning.
First, let’s install Claude Code Router:
1 | # Install Claude Code Router |
The magic happens in the configuration file. Create the directory and config file:
1 | # Create the configuration directory |
According to the GitHub documentation (https://github.com/musistudio/claude-code-router), here’s a basic configuration that routes different types of tasks to different models:
1 | { |
This configuration does several smart things:
- Uses DeepSeek’s affordable model for general tasks
- Routes reasoning-heavy tasks to DeepSeek’s reasoning model
- Uses Gemini Pro for long context tasks (like analyzing large codebases)
- Logs everything so you can see what’s happening
Now start Claude Code with the router:
1 | # Start Claude Code using the router |
You can also switch models on the fly using slash commands:
1 | # Switch to a specific model during your session |
Practical Usage Examples
Once everything is set up, using Claude Code in Termux feels surprisingly natural. Here are some practical examples of how I use it:
Basic code assistance:
1 | # Ask Claude to help with a coding problem |
Model switching for different tasks:
1 | # Use a reasoning model for complex problems |
Long context analysis:
1 | # The router automatically uses Gemini Pro for large files |
The beauty of this setup is that Claude Code Router handles the complexity behind the scenes. When you’re working on simple tasks, it uses affordable models. When you need serious reasoning power or need to process large amounts of code, it automatically routes to more capable models.
Tips and Troubleshooting
Performance: On my phone, Claude Code runs smoothly even with larger codebases. The response times depend more on your internet connection and the model you’re using than on Termux itself.
Storage: Keep an eye on storage usage. The Node.js modules and logs can add up over time. You can clean up with:
1 | # Clear npm cache if needed |
Restarting the router: If you modify the configuration, remember to restart:
1 | ccr restart |
Final Thoughts
Setting up Claude Code with Claude Code Router in Termux turned out to be much more straightforward than I expected. Having an AI coding assistant that can intelligently route between different models - all running on my phone - feels like a glimpse into the future of mobile development.
While it’s not going to replace a full development setup, it’s surprisingly capable for many coding tasks. And honestly, there’s something satisfying about having this level of AI assistance running natively on Android.