show-code
npx skills add https://github.com/acron0/skills --skill show-code
Agent 安装分布
Skill 文档
<execution_style> Be silent and fast. Combine commands into as few Bash calls as possible. Do not narrate what you are doing â just do it. Only speak to the user if something goes wrong or you need information. No commentary between steps. </execution_style>
<quick_start>
- Infer file path and line number from conversation context
- Resolve editor preference from
~/.claude/preferences.json - Verify tmux session and ensure a second pane exists
- Open the file in the editor via
tmux send-keys</quick_start>
From the conversation context, determine:
- The absolute file path being discussed
- The line number (exact or best approximation)
If either cannot be determined, ask the user. Use the Read tool or Grep tool to confirm the file exists and the line number is correct before proceeding.
Read ~/.claude/preferences.json using the Read tool and look for the editor key.
If the file doesn’t exist or has no editor key, ask the user using AskUserQuestion:
- Question: “What terminal editor should I use to show code?”
- Options: “micro”, “vim”, “nano”, “nvim”
Then save their choice. Use Bash:
python3 -c "
import json, os
path = os.path.expanduser('~/.claude/preferences.json')
try:
with open(path) as f: data = json.load(f)
except (FileNotFoundError, json.JSONDecodeError): data = {}
data['editor'] = 'CHOSEN_EDITOR'
with open(path, 'w') as f: json.dump(data, f, indent=2)
"
Replace CHOSEN_EDITOR with the user’s selection.
Check if running inside tmux:
echo "$TMUX"
If $TMUX is empty, tell the user: “Sorry, this requires a tmux session. Please start tmux and try again.” Then stop – do not proceed further.
Count panes in the current window:
tmux list-panes -F '#{pane_id} #{pane_active}'
-
If only 1 pane exists, create a second one:
tmux split-window -h tmux last-paneThe split creates a side-by-side pane.
last-panereturns focus to the original pane (where Claude is running). Remember that the pane was newly created â this affects the command in the next step. -
If 2+ panes exist, use the first inactive pane as the target. The pane is pre-existing.
Determine the target pane ID (the pane that is NOT active):
tmux list-panes -F '#{pane_id} #{pane_active}' | grep ' 0$' | head -1 | awk '{print $1}'
Send the editor command to the target pane. Most terminal editors support +LINE syntax.
If the pane was newly created in the previous step, append && exit so the pane closes automatically when the editor exits:
tmux send-keys -t TARGET_PANE 'EDITOR +LINE FILEPATH && exit' Enter
If the pane was pre-existing, do NOT append && exit:
tmux send-keys -t TARGET_PANE 'EDITOR +LINE FILEPATH' Enter
Replace:
TARGET_PANEwith the pane ID from the previous stepEDITORwith the user’s preferred editorLINEwith the line numberFILEPATHwith the absolute file path
Examples:
# Newly created pane â closes when editor exits
tmux send-keys -t %3 'micro +641 /home/user/project/main.ts && exit' Enter
# Pre-existing pane â stays open
tmux send-keys -t %3 'micro +641 /home/user/project/main.ts' Enter
<edge_cases>
- If the target pane has a running process (not a shell prompt), warn the user before sending keys
- If the editor is not installed, inform the user and suggest installing it
- If the line number exceeds the file length, open at the last line (most editors handle this gracefully)
- If multiple files are being discussed, ask which one to open </edge_cases>
<success_criteria>
- File opens in the correct editor at the specified line
- Editor appears in a tmux pane (reusing existing or creating new)
- Editor preference is persisted in
~/.claude/preferences.json - Graceful exit with message when not in tmux </success_criteria>