Skip to content

Instantly share code, notes, and snippets.

@zerkz
Last active January 3, 2026 05:33
Show Gist options
  • Select an option

  • Save zerkz/a7cd6c1eb1c13141f8069699516272a8 to your computer and use it in GitHub Desktop.

Select an option

Save zerkz/a7cd6c1eb1c13141f8069699516272a8 to your computer and use it in GitHub Desktop.
claude code for "chromium" -- fix for extension not detected. tested on cachy-os + basic chromium
#!/bin/bash
: '
# Claude Code Browser Extension for Chromium-based Browsers (Linux)
A workaround script to enable the **Claude in Chrome** extension to work with Chromium-based browsers on Linux. This was generated in part by Claude!
https://gist.github.com/zerkz/a7cd6c1eb1c13141f8069699516272a8
## The Problem
Claude Code extension detection logic hardcodes the Google Chrome config path (`~/.config/google-chrome/`). If you use a different Chromium-based browser, the extension works but Claude Code cannot detect it.
## The Solution
This script creates the necessary symlinks and copies the native messaging config so Claude Code can find your extension.
## Tested Browsers
- Chromium (CachyOS, pacman installed user-level)
## Untested Browsers, may work
- Brave
- Vivaldi
- Microsoft Edge
- Opera
## Prerequisites
1. **Claude Code CLI** installed and run at least once
```bash
npm install -g @anthropic-ai/claude-code
claude --version
```
2. **Claude in Chrome extension** installed in your browser
- Install from: https://chromewebstore.google.com/detail/claude-code/fcoeoabgfenejglbffodgkkbkcdhcgfn
## Usage
```bash
# Auto-detect browser and set up
./claude-chromium-setup.sh
# Specify a browser
./claude-chromium-setup.sh -b brave
./claude-chromium-setup.sh -b chromium
# Use a different profile
./claude-chromium-setup.sh -p "Profile 1"
# Dry-run (preview changes without applying)
./claude-chromium-setup.sh -n
# Show help
./claude-chromium-setup.sh -h
# Show this full README
./claude-chromium-setup.sh --readme
```
## Options
| Option | Description |
|--------|-------------|
| `-b, --browser` | Specify browser (chromium, brave, vivaldi, edge, opera) |
| `-p, --profile` | Specify profile name (default: "Default") |
| `-n, --dry-run` | Show what would be done without making changes |
| `-h, --help` | Show help message |
| `--readme` | Display this full documentation |
## What It Does
1. **Copies native messaging config** from Chrome directory to your browser directory
2. **Creates a symlink** from your browser extension location to Chrome expected location
This allows Claude Code to detect the extension while it remains installed in your preferred browser.
## After Running
1. Restart your browser completely (close all windows)
2. Open Claude Code CLI
3. Run `/chrome` to verify connection
Expected output:
```
Status: Enabled
Extension: Installed
```
## Troubleshooting
### "Chrome native messaging host not found"
Claude Code CLI needs to be installed and run at least once to create the native messaging host config.
```bash
npm install -g @anthropic-ai/claude-code
claude
```
### "Claude extension not found"
Install the Claude in Chrome extension from the Chrome Web Store in your browser.
### Wrong profile
If you use a non-default profile, specify it with `-p`:
```bash
./claude-chromium-setup.sh -p "Profile 1"
```
Check your profile name in `~/.config/<browser>/` directory.
## Tested On
- **OS**: Linux (CachyOS)
- **Kernel**: 6.18.2-3-cachyos
- **Browser**: Chromium
Should also work on other Linux distributions with standard XDG config paths (`~/.config/`).
## References
- [GitHub Issue #14391](https://github.com/anthropics/claude-code/issues/14391) - Original Brave/macOS workaround
- [Claude in Chrome Extension](https://claude.ai/chrome)
## License
MIT
'
# --- Script starts here ---
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Default values
DRY_RUN=false
PROFILE="Default"
BROWSER=""
# Native messaging host filename
NATIVE_HOST_FILE="com.anthropic.claude_code_browser_extension.json"
# Browser config paths (relative to ~/.config/)
declare -A BROWSER_PATHS=(
["chromium"]="chromium"
["brave"]="BraveSoftware/Brave-Browser"
["vivaldi"]="vivaldi"
["edge"]="microsoft-edge"
["opera"]="opera"
)
declare -A BROWSER_NAMES=(
["chromium"]="Chromium"
["brave"]="Brave"
["vivaldi"]="Vivaldi"
["edge"]="Microsoft Edge"
["opera"]="Opera"
)
# Display the embedded README (extract from the multiline comment above)
show_readme() {
sed -n "/^: '/,/^'/p" "$0" | sed '1d;$d'
}
usage() {
cat << 'EOF'
Claude Code Browser Extension Setup for Chromium-based Browsers (Linux)
Usage: claude-chromium-setup.sh [OPTIONS]
Options:
-b, --browser BROWSER Specify browser (chromium, brave, vivaldi, edge, opera)
If not specified, will auto-detect installed browsers
-p, --profile PROFILE Specify profile name (default: "Default")
-n, --dry-run Show what would be done without making changes
-h, --help Show this help message
--readme Show full documentation in markdown
Examples:
claude-chromium-setup.sh # Auto-detect browser
claude-chromium-setup.sh -b brave # Setup for Brave
claude-chromium-setup.sh -b chromium -n # Dry-run for Chromium
claude-chromium-setup.sh -p "Profile 1" # Use non-default profile
claude-chromium-setup.sh --readme # View full documentation
Requirements:
- Claude Code CLI installed (provides native messaging host)
- Claude in Chrome extension installed in your browser
Based on: https://github.com/anthropics/claude-code/issues/14391
EOF
}
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[OK]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
run_cmd() {
if [ "$DRY_RUN" = true ]; then
echo -e "${YELLOW}[DRY-RUN]${NC} $*"
else
"$@"
fi
}
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-b|--browser)
BROWSER="$2"
shift 2
;;
-p|--profile)
PROFILE="$2"
shift 2
;;
-n|--dry-run)
DRY_RUN=true
shift
;;
-h|--help)
usage
exit 0
;;
--readme)
show_readme
exit 0
;;
*)
log_error "Unknown option: $1"
usage
exit 1
;;
esac
done
# Validate browser choice if specified
if [ -n "$BROWSER" ] && [ -z "${BROWSER_PATHS[$BROWSER]:-}" ]; then
log_error "Unknown browser: $BROWSER"
echo "Supported browsers: ${!BROWSER_PATHS[*]}"
exit 1
fi
# Check for Chrome native messaging host config
CHROME_NATIVE_HOST_DIR="$HOME/.config/google-chrome/NativeMessagingHosts"
CHROME_NATIVE_HOST="$CHROME_NATIVE_HOST_DIR/$NATIVE_HOST_FILE"
if [ ! -f "$CHROME_NATIVE_HOST" ]; then
log_error "Chrome native messaging host not found at:"
echo " $CHROME_NATIVE_HOST"
echo ""
echo "This file is created by Claude Code CLI. Please ensure:"
echo " 1. Claude Code is installed (npm install -g @anthropic-ai/claude-code)"
echo " 2. Run 'claude' at least once to initialize"
echo " 3. The native messaging host was registered"
exit 1
fi
log_success "Found Chrome native messaging host config"
# Auto-detect browser if not specified
detect_browser() {
for browser in "${!BROWSER_PATHS[@]}"; do
local browser_path="$HOME/.config/${BROWSER_PATHS[$browser]}"
if [ -d "$browser_path" ]; then
echo "$browser"
return 0
fi
done
return 1
}
if [ -z "$BROWSER" ]; then
log_info "Auto-detecting browser..."
if BROWSER=$(detect_browser); then
log_success "Detected ${BROWSER_NAMES[$BROWSER]}"
else
log_error "No supported Chromium-based browser found"
echo "Looked for: ${!BROWSER_NAMES[*]}"
echo "Use -b to specify browser manually"
exit 1
fi
fi
BROWSER_CONFIG_PATH="$HOME/.config/${BROWSER_PATHS[$BROWSER]}"
BROWSER_NAME="${BROWSER_NAMES[$BROWSER]}"
# Verify browser directory exists
if [ ! -d "$BROWSER_CONFIG_PATH" ]; then
log_error "$BROWSER_NAME config directory not found at:"
echo " $BROWSER_CONFIG_PATH"
exit 1
fi
# Find Claude extension in browser
find_extension() {
local extensions_dir="$BROWSER_CONFIG_PATH/$PROFILE/Extensions"
if [ ! -d "$extensions_dir" ]; then
log_error "Extensions directory not found: $extensions_dir"
echo "Make sure the profile name is correct (current: $PROFILE)"
return 1
fi
local manifest
manifest=$(find "$extensions_dir" -name "manifest.json" -exec grep -l -i "claude" {} \; 2>/dev/null | head -n1)
if [ -z "$manifest" ]; then
log_error "Claude extension not found in $BROWSER_NAME"
echo ""
echo "Please install the Claude in Chrome extension:"
echo " 1. Open $BROWSER_NAME"
echo " 2. Go to: https://chromewebstore.google.com/detail/claude-code/fcoeoabgfenejglbffodgkkbkcdhcgfn"
echo " 3. Click 'Add to $BROWSER_NAME'"
echo " 4. Re-run this script"
return 1
fi
# Extract extension ID from path
# Path format: .../Extensions/EXTENSION_ID/VERSION/manifest.json
local extension_id
extension_id=$(echo "$manifest" | sed -E 's|.*/Extensions/([^/]+)/.*|\1|')
echo "$extension_id"
}
log_info "Looking for Claude extension in $BROWSER_NAME..."
if ! EXTENSION_ID=$(find_extension); then
exit 1
fi
log_success "Found extension: $EXTENSION_ID"
# Step 1: Copy native messaging config to browser
BROWSER_NATIVE_HOST_DIR="$BROWSER_CONFIG_PATH/NativeMessagingHosts"
BROWSER_NATIVE_HOST="$BROWSER_NATIVE_HOST_DIR/$NATIVE_HOST_FILE"
log_info "Copying native messaging config to $BROWSER_NAME..."
run_cmd mkdir -p "$BROWSER_NATIVE_HOST_DIR"
run_cmd cp "$CHROME_NATIVE_HOST" "$BROWSER_NATIVE_HOST"
log_success "Native messaging config copied"
# Step 2: Create Chrome extensions directory structure
CHROME_EXTENSIONS_DIR="$HOME/.config/google-chrome/$PROFILE/Extensions"
log_info "Ensuring Chrome extensions directory exists..."
run_cmd mkdir -p "$CHROME_EXTENSIONS_DIR"
log_success "Chrome extensions directory ready"
# Step 3: Create symlink for extension detection
BROWSER_EXTENSION_PATH="$BROWSER_CONFIG_PATH/$PROFILE/Extensions/$EXTENSION_ID"
CHROME_EXTENSION_LINK="$CHROME_EXTENSIONS_DIR/$EXTENSION_ID"
log_info "Creating symlink for Claude Code detection..."
if [ -L "$CHROME_EXTENSION_LINK" ]; then
log_warn "Symlink already exists, updating..."
run_cmd rm "$CHROME_EXTENSION_LINK"
elif [ -e "$CHROME_EXTENSION_LINK" ]; then
log_error "Path exists but is not a symlink: $CHROME_EXTENSION_LINK"
echo "Please remove it manually and re-run this script"
exit 1
fi
run_cmd ln -sf "$BROWSER_EXTENSION_PATH" "$CHROME_EXTENSION_LINK"
log_success "Symlink created"
# Summary
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}Setup complete!${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo "Configuration:"
echo " Browser: $BROWSER_NAME"
echo " Profile: $PROFILE"
echo " Extension: $EXTENSION_ID"
echo ""
echo "Next steps:"
echo " 1. Restart $BROWSER_NAME completely (close all windows)"
echo " 2. Open Claude Code CLI"
echo " 3. Run /chrome to verify connection"
echo ""
if [ "$DRY_RUN" = true ]; then
echo -e "${YELLOW}This was a dry run. No changes were made.${NC}"
echo "Run without -n to apply changes."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment