Add compiled binary support with env var config

- Read CLAUDE_REMOTE_SECRET and CLAUDE_REMOTE_SERVER from env
- Make -- separator optional (all args pass through to claude)
- Add --help support (shows wrapper info, passes to claude if configured)
- Update README with binary build/install instructions
- Add binary to .gitignore
This commit is contained in:
Jared Miller 2026-01-28 16:59:36 -05:00
parent 84a29445c6
commit 2a41a3302b
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C
3 changed files with 59 additions and 28 deletions

1
.gitignore vendored
View file

@ -37,3 +37,4 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# Finder (MacOS) folder config
.DS_Store
claude-remote

View file

@ -11,10 +11,19 @@ just dev
# 2. create a device (one-time setup)
just seed dev "My Phone"
# 3. run claude through the wrapper (from any project directory)
bun /path/to/claude-remote/src/cli.ts --secret dev -- --dangerously-skip-permissions
# 3. build the binary + symlink to ~/bin
bun build --compile src/cli.ts --outfile claude-remote
ln -sf $(pwd)/claude-remote ~/bin/claude-remote
# 4. open browser
# 4. set your secret
export CLAUDE_REMOTE_SECRET=dev # add to .bashrc/.zshrc
# 5. use it like claude
claude-remote
claude-remote -r
claude-remote --dangerously-skip-permissions
# 6. open browser/phone
open http://localhost:7200
```
@ -44,40 +53,38 @@ Default if you just run `just seed`:
### run claude
Instead of running `claude` directly, run it through the wrapper:
With the binary installed and `CLAUDE_REMOTE_SECRET` set, just use `claude-remote` like `claude`:
```bash
bun /path/to/claude-remote/src/cli.ts --secret <your-secret> -- <claude args>
claude-remote # interactive
claude-remote -r # resume
claude-remote --help # shows help
claude-remote -p "explain this" # print mode
```
Examples:
All arguments pass through to claude.
### configuration
Environment variables (add to .bashrc/.zshrc):
```bash
# basic
bun src/cli.ts --secret dev -- --dangerously-skip-permissions
# resume
bun src/cli.ts --secret dev -- --dangerously-skip-permissions -r
# any other claude args
bun src/cli.ts --secret dev -- --help
export CLAUDE_REMOTE_SECRET=dev # required
export CLAUDE_REMOTE_SERVER=ws://localhost:7200/ws # optional, this is the default
```
The wrapper can be run from any directory - it passes through to claude with your current working directory.
Or use flags to override:
```bash
claude-remote --secret other-device --server ws://remote:7200/ws
```
### shell aliases
If you have aliases like:
```bash
alias cd!='claude --dangerously-skip-permissions'
alias cdr='cd! -r'
```
Create equivalent remote aliases:
```bash
alias crd='bun /path/to/claude-remote/src/cli.ts --secret dev -- --dangerously-skip-permissions'
alias cr='claude-remote'
alias crr='claude-remote -r'
alias crd='claude-remote --dangerously-skip-permissions'
alias crdr='crd -r'
```

View file

@ -14,8 +14,10 @@ interface Args {
function parseArgs(): Args {
const args = process.argv.slice(2);
let server = "ws://localhost:7200/ws";
let secret = "";
// Read config from env vars first
let server = process.env.CLAUDE_REMOTE_SERVER || "ws://localhost:7200/ws";
let secret = process.env.CLAUDE_REMOTE_SECRET || "";
const claudeArgs: string[] = [];
let i = 0;
@ -26,7 +28,28 @@ function parseArgs(): Args {
} else if (args[i] === "--secret" && i + 1 < args.length) {
secret = args[i + 1] as string;
i += 2;
} else if (args[i] === "--help") {
// If we have a secret, show brief info then pass through to claude
if (secret) {
console.log("claude-remote: PTY wrapper for claude CLI");
console.log("Streaming to:", server);
console.log("\nPassing through to claude:\n");
claudeArgs.push(args[i] as string);
i++;
} else {
// No secret configured, just show our help
console.log("claude-remote: PTY wrapper for claude CLI");
console.log("\nConfiguration:");
console.log(" CLAUDE_REMOTE_SECRET - authentication secret (required)");
console.log(" CLAUDE_REMOTE_SERVER - server URL (default: ws://localhost:7200/ws)");
console.log("\nFlags:");
console.log(" --secret <secret> - override CLAUDE_REMOTE_SECRET");
console.log(" --server <url> - override CLAUDE_REMOTE_SERVER");
console.log("\nAll other arguments are passed through to claude.");
process.exit(0);
}
} else if (args[i] === "--") {
// -- separator is optional, just skip it
claudeArgs.push(...args.slice(i + 1));
break;
} else {
@ -36,7 +59,7 @@ function parseArgs(): Args {
}
if (!secret) {
console.error("Error: --secret is required");
console.error("No secret configured. Set CLAUDE_REMOTE_SECRET or use --secret");
process.exit(1);
}