smithery.ai

local-claude

Start a local Claude Code instance in tmux with interactive login. Use when the user wants to run a nested/second Claude Code instance, spawn a local claude, or needs to authenticate a separate Claude session.

First seen Mar 23, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Skill metadata

Parsed from SKILL.md frontmatter.

Declared agents claude-code

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 5,987 B
  • docs SUMMARY.md 229 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 1 installs

SKILL.md

Local Claude Code

A pre-warmed Claude Code TUI session runs in tmux, started automatically by the SessionStart hook.

Quick Reference

Send Query and Wait for Response

# Send query using -l (literal) for reliability with special characters
tmux send-keys -t claude-local -l 'your query here' && tmux send-keys -t claude-local Enter

# Wait for response to stabilize, then capture (recommended)
.claude/skills/local-claude/scripts/tmux-poll-wait.sh claude-local

The polling script waits until output stabilizes (3 consecutive unchanged polls at 3s intervals) or times out after 60s, then outputs the final capture.

Extract Response for Specific Command

The basic capture includes scrollback history. To extract just the response for a specific command, use pattern matching:

QUERY="your query here"
# Escape special regex characters in query
SAFE_QUERY=$(printf '%s' "$QUERY" | sed 's/[.[\*^$()+?|\\]/\\&/g')
tmux capture-pane -t claude-local -p -S -100 \
  | sed -n "/❯ $SAFE_QUERY/,/^❯ [a-z]/p" \
  | head -n -1 \
  | grep -v '^────' \
  | grep -v '⏵⏵'

How it works:

  • First escape special regex characters (. [ * ^ $ ( ) + ? | \) in the query
  • sed -n "/❯ $SAFE_QUERY/,/^❯ [a-z]/p" - extract from your command prompt to the next command
  • head -n -1 - remove the trailing "next command" line
  • grep -v - filter out UI chrome (separators, mode indicators)

Tips:

  • Add -J to capture-pane to join wrapped lines: tmux capture-pane -t claude-local -p -J -S -100
  • Set LC_ALL=C.UTF-8 before running to ensure consistent ❯ prompt matching across locales

Note: If the same query appears multiple times in scrollback, this captures ALL occurrences. To get only the most recent response, use this awk-based extraction:

QUERY="your query here"
SAFE_QUERY=$(printf '%s' "$QUERY" | sed 's/[.[\*^$()+?|\\]/\\&/g')
tmux capture-pane -t claude-local -p -S -200 \
  | awk -v q="$SAFE_QUERY" '
    /^❯ / { printing = ($0 ~ "^❯ " q "$"); if (printing) { delete out; n=0 } next }
    { if (printing) {
        if (/^❯ [a-z]/) { printing=0 }
        else if ($0 !~ /^────/ && $0 !~ /⏵⏵/) { out[++n]=$0 }
      }
    }
    END { for (i=1; i<=n; i++) print out[i] }'

Alternative Capture Methods

Clear history first (captures everything since clear):

tmux clear-history -t claude-local
tmux send-keys -t claude-local -l 'query' && tmux send-keys -t claude-local Enter
sleep 15
tmux capture-pane -t claude-local -p -S -

Pipe to file (real-time capture, includes ANSI codes):

tmux pipe-pane -t claude-local 'cat > /tmp/output.txt'
tmux send-keys -t claude-local -l 'query' && tmux send-keys -t claude-local Enter
sleep 15
tmux pipe-pane -t claude-local  # stop piping
# Strip ANSI escape codes for clean output
sed -r 's/\x1B\[[0-9;]*[A-Za-z]//g' /tmp/output.txt

Session Commands

Action Command
Check status tmux capture-pane -t claude-local -p -S -30
Send query tmux send-keys -t claude-local -l 'text' && tmux send-keys -t claude-local Enter
Wait for response .claude/skills/local-claude/scripts/tmux-poll-wait.sh claude-local
Wait (custom timeout) .claude/skills/local-claude/scripts/tmux-poll-wait.sh claude-local 120
Attach tmux attach -t claude-local
Restart tmux kill-session -t claude-local (will restart on next session)

How It Works

The .githooks/post-checkout hook (triggered by SessionStart) handles everything:

  1. Restores credentials from GitHub variable
  2. Configures Claude state (onboarding, bypass acceptance, trust dialog)
  3. Starts claude-local tmux session with --dangerously-skip-permissions

Only runs in remote environments (CLAUDECODEREMOTE=true).

Polling Script

The bundled scripts/tmux-poll-wait.sh intelligently waits for Claude to finish.

Requirements: tmux must be installed and the target session must exist.

Exit codes:

  • 0 - Output stabilized (success)
  • 1 - Session not found
  • 124 - Timeout (like GNU timeout)

Environment variables (optional):

Variable Default Description
TMUXPOLLINTERVAL 3 Seconds between polls
TMUXPOLLSTABLE 3 Consecutive unchanged polls required
TMUXPOLLLINES 100 Lines to capture for comparison
# Usage
.claude/skills/local-claude/scripts/tmux-poll-wait.sh <session> [timeout_seconds]

# Examples
.claude/skills/local-claude/scripts/tmux-poll-wait.sh claude-local      # 60s timeout
.claude/skills/local-claude/scripts/tmux-poll-wait.sh claude-local 120  # 120s timeout

# Check exit code to distinguish stable vs timeout
.claude/skills/local-claude/scripts/tmux-poll-wait.sh claude-local > output.txt
if [ $? -eq 124 ]; then echo "Timed out"; fi

OAuth Re-authentication

Only needed if credentials are revoked:

tmux new-session -d -s claude-reauth "bash -c 'unset CLAUDE_CODE_REMOTE CLAUDE_CODE_ENTRYPOINT CLAUDECODE CLAUDE_CODE_SESSION_ID CLAUDE_CODE_REMOTE_SESSION_ID CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR; exec claude /login'"
.claude/skills/local-claude/scripts/tmux-poll-wait.sh claude-reauth 30
# After user provides code:
tmux send-keys -t claude-reauth 'CODE_HERE' Enter
# Use base64 | tr -d '\n' for cross-platform compatibility (macOS/Linux)
gh variable set CLAUDE_CREDENTIALS --repo eastlondoner/claude --body "$(base64 ~/.claude/.credentials.json | tr -d '\n')"

Security note: For production use, consider using gh secret set instead of gh variable set for sensitive credentials, as secrets are encrypted and not visible in logs.