claude-code-termux 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Claude Code Termux Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,198 @@
1
+ # Claude Code Termux
2
+
3
+ A community wrapper for [Claude Code CLI](https://github.com/anthropics/claude-code) that fixes compatibility issues on **Termux** (Android terminal emulator).
4
+
5
+ ## Features
6
+
7
+ This wrapper addresses the following issues when running Claude Code on Termux:
8
+
9
+ | Issue | Status | Description |
10
+ |-------|--------|-------------|
11
+ | Sharp module failure | Fixed | Uses WebAssembly fallback for android-arm64 |
12
+ | Ripgrep binary missing | Fixed | Auto-downloads or links to system ripgrep |
13
+ | Custom slash commands | Fixed | Normalizes paths for Termux filesystem |
14
+ | PostToolUse hooks | Fixed | Patches event emission for Android |
15
+ | OAuth token storage | Fixed | Provides encrypted file-based fallback |
16
+
17
+ ## Requirements
18
+
19
+ - **Termux** from [F-Droid](https://f-droid.org/en/packages/com.termux/) (NOT Google Play)
20
+ - **Node.js** 18-24 (v25+ has compatibility issues)
21
+ - **4GB+ RAM** recommended
22
+
23
+ ## Quick Install
24
+
25
+ Run this one-liner in Termux:
26
+
27
+ ```bash
28
+ curl -fsSL https://raw.githubusercontent.com/findingjimoh/claude-cli-termux/main/scripts/setup-termux.sh | bash
29
+ ```
30
+
31
+ Or install manually:
32
+
33
+ ```bash
34
+ # Update packages
35
+ pkg update && pkg upgrade -y
36
+
37
+ # Install dependencies
38
+ pkg install nodejs git ripgrep -y
39
+
40
+ # Install Claude Code Termux
41
+ npm install -g claude-code-termux
42
+
43
+ # Install Sharp WASM for image support
44
+ npm install -g @img/sharp-wasm32 --force
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ ### API Key Authentication (Recommended)
50
+
51
+ ```bash
52
+ # Set your API key
53
+ export ANTHROPIC_API_KEY=your-api-key
54
+
55
+ # Start Claude Code
56
+ claude
57
+ ```
58
+
59
+ To persist across sessions:
60
+
61
+ ```bash
62
+ echo 'export ANTHROPIC_API_KEY=your-api-key' >> ~/.bashrc
63
+ ```
64
+
65
+ ### OAuth Authentication (Experimental)
66
+
67
+ ```bash
68
+ claude login
69
+ ```
70
+
71
+ Note: OAuth has known issues on Termux. API key authentication is more reliable.
72
+
73
+ ## Verification
74
+
75
+ Run the verification script to check your installation:
76
+
77
+ ```bash
78
+ npx claude-code-termux verify
79
+ # or
80
+ node /path/to/claude-code-termux/scripts/verify-install.js
81
+ ```
82
+
83
+ ## Troubleshooting
84
+
85
+ ### Sharp Module Error
86
+
87
+ ```
88
+ Error: Could not load the "sharp" module using the android-arm64 runtime
89
+ ```
90
+
91
+ **Solution:**
92
+ ```bash
93
+ npm install -g @img/sharp-wasm32 --force
94
+ npm install -g sharp --force
95
+ ```
96
+
97
+ ### Ripgrep Not Found
98
+
99
+ ```
100
+ Error: spawn .../vendor/ripgrep/arm64-android/rg ENOENT
101
+ ```
102
+
103
+ **Solution:**
104
+ ```bash
105
+ pkg install ripgrep
106
+ ```
107
+
108
+ ### Custom Slash Commands Not Loading
109
+
110
+ Ensure your commands are in the correct directory:
111
+
112
+ ```bash
113
+ mkdir -p ~/.claude/commands
114
+ # Create your command files here
115
+ ```
116
+
117
+ ### Memory/Crash Issues
118
+
119
+ If you experience crashes:
120
+
121
+ 1. Ensure you have enough free RAM (4GB+ recommended)
122
+ 2. Try using an older Node.js version:
123
+ ```bash
124
+ pkg install nodejs-lts
125
+ ```
126
+ 3. Set DEBUG=1 for verbose output:
127
+ ```bash
128
+ DEBUG=1 claude
129
+ ```
130
+
131
+ ### Shell Not Found Error
132
+
133
+ ```
134
+ Error: No suitable shell found
135
+ ```
136
+
137
+ **Solution:**
138
+ ```bash
139
+ export SHELL=/data/data/com.termux/files/usr/bin/bash
140
+ ```
141
+
142
+ Add to ~/.bashrc for persistence.
143
+
144
+ ## Known Limitations
145
+
146
+ 1. **Image reading** - Works but requires Sharp WASM installation
147
+ 2. **GitHub App installation** - `/install-github-app` may not work properly
148
+ 3. **Some hooks** - PostToolUse hooks may have issues on some devices
149
+ 4. **Performance** - Slightly slower than desktop due to mobile hardware
150
+
151
+ ## How It Works
152
+
153
+ This package is a **wrapper** around the official `@anthropic-ai/claude-code` package. It:
154
+
155
+ 1. Installs the official Claude Code as a dependency
156
+ 2. Applies runtime patches for Termux compatibility
157
+ 3. Sets up necessary binaries and configurations
158
+ 4. Provides fallback mechanisms for unsupported features
159
+
160
+ This approach means you automatically get updates from the official package while maintaining Termux compatibility.
161
+
162
+ ## Debug Mode
163
+
164
+ Enable debug output:
165
+
166
+ ```bash
167
+ DEBUG=1 claude
168
+ ```
169
+
170
+ For hook-specific debugging:
171
+
172
+ ```bash
173
+ DEBUG_HOOKS=1 claude
174
+ ```
175
+
176
+ ## Contributing
177
+
178
+ Contributions are welcome! Please:
179
+
180
+ 1. Fork this repository
181
+ 2. Create a feature branch
182
+ 3. Submit a pull request
183
+
184
+ ## Related Issues
185
+
186
+ - [Sharp WASM Support #2248](https://github.com/anthropics/claude-code/issues/2248)
187
+ - [Custom Commands #9435](https://github.com/anthropics/claude-code/issues/9435)
188
+ - [PostToolUse Hooks #15617](https://github.com/anthropics/claude-code/issues/15617)
189
+ - [Memory Corruption #12160](https://github.com/anthropics/claude-code/issues/12160)
190
+ - [Ripgrep/Auth #6244](https://github.com/anthropics/claude-code/issues/6244)
191
+
192
+ ## License
193
+
194
+ MIT License - see [LICENSE](LICENSE) for details.
195
+
196
+ ## Disclaimer
197
+
198
+ This is a community project and is not officially supported by Anthropic. Use at your own risk.
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Claude Code Termux Wrapper
5
+ *
6
+ * This wrapper applies Termux/Android-specific patches before loading
7
+ * the official Claude Code CLI. It fixes issues with:
8
+ * - Sharp module (uses WASM fallback on android-arm64)
9
+ * - Ripgrep binary (ensures ARM64 binary is available)
10
+ * - Path resolution (handles Termux's non-standard paths)
11
+ * - OAuth token storage (provides fallback when keychain unavailable)
12
+ */
13
+
14
+ 'use strict';
15
+
16
+ const path = require('path');
17
+ const fs = require('fs');
18
+
19
+ // Detect if running on Termux/Android
20
+ const isTermux = process.platform === 'android' ||
21
+ process.env.PREFIX?.includes('com.termux') ||
22
+ process.env.HOME?.includes('com.termux');
23
+
24
+ // Apply runtime patches for Termux
25
+ if (isTermux) {
26
+ console.log('[claude-code-termux] Detected Termux environment, applying patches...');
27
+
28
+ try {
29
+ // Apply all patches
30
+ require('../src/patches/apply-all');
31
+ } catch (err) {
32
+ console.error('[claude-code-termux] Warning: Some patches could not be applied:', err.message);
33
+ }
34
+ }
35
+
36
+ // Find the Claude Code CLI entry point
37
+ let claudeCodePath;
38
+ try {
39
+ // Try to resolve the claude-code package
40
+ claudeCodePath = require.resolve('@anthropic-ai/claude-code/cli.mjs');
41
+ } catch (err) {
42
+ // Fallback: look in node_modules
43
+ const possiblePaths = [
44
+ path.join(__dirname, '..', 'node_modules', '@anthropic-ai', 'claude-code', 'cli.mjs'),
45
+ path.join(__dirname, '..', '..', '@anthropic-ai', 'claude-code', 'cli.mjs'),
46
+ path.join(process.env.PREFIX || '/usr', 'lib', 'node_modules', '@anthropic-ai', 'claude-code', 'cli.mjs'),
47
+ ];
48
+
49
+ for (const p of possiblePaths) {
50
+ if (fs.existsSync(p)) {
51
+ claudeCodePath = p;
52
+ break;
53
+ }
54
+ }
55
+
56
+ if (!claudeCodePath) {
57
+ console.error('[claude-code-termux] Error: Could not find @anthropic-ai/claude-code');
58
+ console.error('Please ensure it is installed: npm install @anthropic-ai/claude-code');
59
+ process.exit(1);
60
+ }
61
+ }
62
+
63
+ // Import and run Claude Code
64
+ // Use dynamic import since cli.mjs is an ES module
65
+ import(claudeCodePath).catch(err => {
66
+ console.error('[claude-code-termux] Error loading Claude Code:', err.message);
67
+
68
+ if (err.message.includes('sharp')) {
69
+ console.error('\nSharp module error detected. Try running:');
70
+ console.error(' npm install @img/sharp-wasm32 --force');
71
+ console.error(' npm install sharp --force');
72
+ }
73
+
74
+ if (err.message.includes('ENOENT') && err.message.includes('ripgrep')) {
75
+ console.error('\nRipgrep binary not found. Try running:');
76
+ console.error(' pkg install ripgrep');
77
+ }
78
+
79
+ process.exit(1);
80
+ });
@@ -0,0 +1,136 @@
1
+ # Installation Guide
2
+
3
+ This guide provides detailed installation instructions for Claude Code on Termux.
4
+
5
+ ## Prerequisites
6
+
7
+ ### 1. Install Termux
8
+
9
+ **Important:** Install Termux from [F-Droid](https://f-droid.org/en/packages/com.termux/), NOT the Google Play Store. The Play Store version is outdated and may not work properly.
10
+
11
+ 1. Download F-Droid from https://f-droid.org/
12
+ 2. Search for "Termux" in F-Droid
13
+ 3. Install Termux
14
+
15
+ ### 2. Grant Storage Permission
16
+
17
+ After installing Termux, run:
18
+
19
+ ```bash
20
+ termux-setup-storage
21
+ ```
22
+
23
+ This allows Termux to access your device storage.
24
+
25
+ ## Installation Methods
26
+
27
+ ### Method 1: One-Line Install (Recommended)
28
+
29
+ ```bash
30
+ curl -fsSL https://raw.githubusercontent.com/findingjimoh/claude-cli-termux/main/scripts/setup-termux.sh | bash
31
+ ```
32
+
33
+ ### Method 2: Manual Installation
34
+
35
+ #### Step 1: Update Packages
36
+
37
+ ```bash
38
+ pkg update && pkg upgrade -y
39
+ ```
40
+
41
+ #### Step 2: Install Node.js
42
+
43
+ ```bash
44
+ pkg install nodejs -y
45
+ ```
46
+
47
+ Verify the version:
48
+
49
+ ```bash
50
+ node --version
51
+ ```
52
+
53
+ You need Node.js 18-24. If you have v25+, install the LTS version:
54
+
55
+ ```bash
56
+ pkg install nodejs-lts -y
57
+ ```
58
+
59
+ #### Step 3: Install Git
60
+
61
+ ```bash
62
+ pkg install git -y
63
+ ```
64
+
65
+ #### Step 4: Install Ripgrep
66
+
67
+ ```bash
68
+ pkg install ripgrep -y
69
+ ```
70
+
71
+ Verify it works:
72
+
73
+ ```bash
74
+ rg --version
75
+ ```
76
+
77
+ #### Step 5: Install Claude Code Termux
78
+
79
+ ```bash
80
+ npm install -g claude-code-termux
81
+ ```
82
+
83
+ #### Step 6: Install Sharp WASM (for image support)
84
+
85
+ ```bash
86
+ npm install -g @img/sharp-wasm32 --force
87
+ ```
88
+
89
+ ## Post-Installation Setup
90
+
91
+ ### Set API Key
92
+
93
+ Get your API key from https://console.anthropic.com/
94
+
95
+ ```bash
96
+ export ANTHROPIC_API_KEY=sk-ant-api03-...
97
+ ```
98
+
99
+ To make it persistent:
100
+
101
+ ```bash
102
+ echo 'export ANTHROPIC_API_KEY=sk-ant-api03-...' >> ~/.bashrc
103
+ source ~/.bashrc
104
+ ```
105
+
106
+ ### Verify Installation
107
+
108
+ ```bash
109
+ node $(npm root -g)/claude-code-termux/scripts/verify-install.js
110
+ ```
111
+
112
+ ### Start Claude Code
113
+
114
+ ```bash
115
+ claude
116
+ ```
117
+
118
+ ## Updating
119
+
120
+ To update to the latest version:
121
+
122
+ ```bash
123
+ npm update -g claude-code-termux
124
+ ```
125
+
126
+ ## Uninstalling
127
+
128
+ ```bash
129
+ npm uninstall -g claude-code-termux
130
+ npm uninstall -g @anthropic-ai/claude-code
131
+ ```
132
+
133
+ ## Next Steps
134
+
135
+ - Read the [Troubleshooting Guide](TROUBLESHOOTING.md) if you encounter issues
136
+ - Check [Known Issues](KNOWN-ISSUES.md) for current limitations
@@ -0,0 +1,135 @@
1
+ # Known Issues
2
+
3
+ This document tracks known issues and limitations when running Claude Code on Termux.
4
+
5
+ ## Current Status
6
+
7
+ | Feature | Status | Notes |
8
+ |---------|--------|-------|
9
+ | Basic CLI | Working | Core functionality works |
10
+ | Bash commands | Working | File and git operations work |
11
+ | Code search (ripgrep) | Working | Requires `pkg install ripgrep` |
12
+ | Image reading | Partial | Requires Sharp WASM installation |
13
+ | Custom slash commands | Partial | May require manual setup |
14
+ | Hooks (Pre/Post) | Partial | PostToolUse has issues |
15
+ | OAuth login | Experimental | API key recommended |
16
+ | MCP support | Working | Model Context Protocol works |
17
+
18
+ ## Open Issues
19
+
20
+ ### 1. PostToolUse Hooks Not Firing
21
+
22
+ **Issue:** [#15617](https://github.com/anthropics/claude-code/issues/15617)
23
+
24
+ PostToolUse hooks don't trigger on Termux/Android, while other hook types work correctly.
25
+
26
+ **Status:** Partially mitigated with event patching
27
+
28
+ **Workaround:** Use PreToolUse hooks where possible
29
+
30
+ ---
31
+
32
+ ### 2. Custom Slash Commands Not Loading
33
+
34
+ **Issue:** [#9435](https://github.com/anthropics/claude-code/issues/9435)
35
+
36
+ Custom slash commands in `.claude/commands/` are not discovered on Termux.
37
+
38
+ **Status:** Partially mitigated with path normalization
39
+
40
+ **Workaround:** Ensure correct permissions and absolute paths
41
+
42
+ ---
43
+
44
+ ### 3. Image Reading Requires Extra Setup
45
+
46
+ **Issue:** [#2248](https://github.com/anthropics/claude-code/issues/2248)
47
+
48
+ Sharp module fails to load on android-arm64.
49
+
50
+ **Status:** Fixed with WASM fallback
51
+
52
+ **Solution:** `npm install @img/sharp-wasm32 --force`
53
+
54
+ ---
55
+
56
+ ### 4. GitHub App Installation Stuck
57
+
58
+ **Issue:** [#3585](https://github.com/anthropics/claude-code/issues/3585)
59
+
60
+ `/install-github-app` command doesn't progress past organization input.
61
+
62
+ **Status:** Not fixed
63
+
64
+ **Workaround:** Use GitHub CLI (`gh`) directly or configure on desktop
65
+
66
+ ---
67
+
68
+ ### 5. Memory Corruption on Some Devices
69
+
70
+ **Issue:** [#12160](https://github.com/anthropics/claude-code/issues/12160)
71
+
72
+ "double free or corruption" crash on ARM64.
73
+
74
+ **Status:** Partially mitigated
75
+
76
+ **Workaround:**
77
+ - Use Node.js v24.11.1+
78
+ - Use older Claude Code version (0.2.114)
79
+
80
+ ---
81
+
82
+ ### 6. OAuth Token Persistence
83
+
84
+ **Issue:** [#6244](https://github.com/anthropics/claude-code/issues/6244)
85
+
86
+ OAuth tokens don't persist across sessions.
87
+
88
+ **Status:** Partially mitigated with file-based storage
89
+
90
+ **Workaround:** Use API key authentication
91
+
92
+ ---
93
+
94
+ ### 7. Node.js v25+ Incompatibility
95
+
96
+ Node.js v25+ removed the SlowBuffer API that Claude Code depends on.
97
+
98
+ **Status:** Known issue
99
+
100
+ **Workaround:** Use Node.js 18-24
101
+
102
+ ---
103
+
104
+ ## Feature Limitations
105
+
106
+ ### Compared to Desktop
107
+
108
+ 1. **Performance** - Slower due to mobile hardware
109
+ 2. **Memory** - Limited by device RAM
110
+ 3. **IDE integration** - Not applicable on mobile
111
+ 4. **GUI features** - No visual diff, no browser integration
112
+
113
+ ### Termux-Specific
114
+
115
+ 1. **Storage access** - Requires `termux-setup-storage`
116
+ 2. **Background execution** - May be killed by Android
117
+ 3. **Notifications** - Limited notification support
118
+ 4. **Clipboard** - Requires Termux:API addon
119
+
120
+ ## Reporting New Issues
121
+
122
+ When reporting issues, include:
123
+
124
+ ```
125
+ Termux version: (from pkg list-installed termux-\*)
126
+ Node.js version: (node --version)
127
+ Claude Code version: (npm list -g @anthropic-ai/claude-code)
128
+ Android version: (getprop ro.build.version.release)
129
+ Device: (getprop ro.product.model)
130
+ Architecture: (uname -m)
131
+ ```
132
+
133
+ File issues at:
134
+ - **Termux-specific:** This repository
135
+ - **General Claude Code:** [anthropics/claude-code](https://github.com/anthropics/claude-code/issues)