askill
tmux-ai-chat

tmux-ai-chatSafety 85Repository

[INTERNAL] Common tmux operations for AI chat integration. Provides split, send, capture, kill commands with marker-based output extraction. This is an internal base skill used by codex-collab, cursor-collab, ai-research, and claude-collab. NOT user-invocable directly - other AI collaboration skills reference this as a dependency.

0 stars
1.2k downloads
Updated 3/18/2026

Package Files

Loading files...
SKILL.md

tmux-ai-chat

tmux を使った AI チャット連携の共通基盤スキル。

スクリプト: tmux_ai.sh

場所

skills/tmux-ai-chat/scripts/tmux_ai.sh

サブコマンド

split - ペイン作成

tmux_ai.sh split --direction h --percent 50 --name <title> [--cmd <command>] --print-pane-id
オプション説明デフォルト
--direction, -d分割方向(h=水平, v=垂直)h
--percent, -p新ペインのサイズ(%)50
--name, -nペインタイトルなし
--cmd, -c実行するコマンドなし
--print-pane-idペインIDを出力なし

出力: --print-pane-id 指定時、新しいペインID(例: %12

send - テキスト送信

tmux_ai.sh send --pane <id> [--wrap] [--text <str> | --file <path>] --enter
オプション説明
--pane送信先ペイン(必須)
--text, -t送信するテキスト
--file, -f送信するファイル
--wrap, -wマーカーで囲む(シェルプロンプト専用
--enter, -e最後に Enter を送信

出力: --wrap 指定時、マーカーID(例: 20260204T120102-a1b2c3d4

⚠️ 重要: --wrapprintf コマンドを実行してマーカーを出力するため、 ペインがシェルプロンプト(bash等)でないと動作しません。 対話型 AI CLI(codex, gemini 等)では使用できません。

capture - 出力取得

tmux_ai.sh capture --pane <id> --between <marker_id> --wait-ms 30000
オプション説明デフォルト
--paneキャプチャ元ペイン(必須)
--between, -bマーカーID間をキャプチャ
--last-lines, -l最後のN行をキャプチャ
--wait-msタイムアウト時間(ミリ秒)8000
--interval-msポーリング間隔(ミリ秒)200

出力: キャプチャしたテキスト

kill - ペイン終了

tmux_ai.sh kill --pane <id>
オプション説明
--pane終了するペイン(必須)
--force, -f現在のペインも強制終了

エラーコード

コード意味対応
0成功-
64使い方エラー(不正引数)引数を確認
69外部要因(tmux未起動等)tmux セッション内で実行
72I/Oエラー(ファイル読み込み失敗)ファイルパスを確認
124タイムアウト--wait-ms を増やすか、手動確認

使用例

対話型 AI CLI との連携(推奨)

対話型 AI CLI(codex, gemini 等)では --wrap は使用せず、--last-lines でキャプチャします。

# 1. ペイン作成(AI CLI を起動)
pane=$(tmux_ai.sh split --direction h --percent 50 --name codex --cmd "codex" --print-pane-id)

# 2. AI CLI の起動を待機
sleep 5

# 3. 質問送信(wrap なし)
tmux_ai.sh send --pane "$pane" --text "設計について相談したい" --enter

# 4. 応答を待機してキャプチャ
sleep 60
response=$(tmux_ai.sh capture --pane "$pane" --last-lines 100)

# 5. ペイン終了
tmux_ai.sh kill --pane "$pane"

シェルコマンド実行(wrap 使用)

シェルプロンプトでワンショットコマンドを実行する場合は --wrap が使用できます。

# 1. シェルペイン作成(コマンドなし)
pane=$(tmux_ai.sh split --direction h --percent 50 --name shell --print-pane-id)

# 2. コマンド実行(マーカー付き)
id=$(tmux_ai.sh send --pane "$pane" --wrap --text "ls -la" --enter)

# 3. 結果をマーカー間から抽出
result=$(tmux_ai.sh capture --pane "$pane" --between "$id" --wait-ms 5000)

# 4. ペイン終了
tmux_ai.sh kill --pane "$pane"

ファイル経由で長文送信

# プロンプトをファイルに保存
cat > /tmp/prompt.txt << 'EOF'
以下のコードをレビューしてください:

```python
def calculate(x, y):
    return x + y

EOF

ファイルを送信

id=$(tmux_ai.sh send --pane "$pane" --wrap --file /tmp/prompt.txt --enter)


### タイムアウト処理

```bash
if ! response=$(tmux_ai.sh capture --pane "$pane" --between "$id" --wait-ms 60000); then
    case $? in
        124)
            echo "タイムアウト: 追加で待機するか、手動で確認してください"
            # フォールバック: 最後の100行を取得
            tmux_ai.sh capture --pane "$pane" --last-lines 100
            ;;
        *)
            echo "エラーが発生しました"
            ;;
    esac
fi

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

70/100Analyzed 3/22/2026

Well-structured technical reference for tmux automation with clear commands, options tables, and usage examples. However, explicitly marked as internal-only dependency not user-invocable, which significantly limits practical value. The Japanese content is well-organized but may reduce accessibility. Provides good error handling documentation and safety warnings.

85
75
90
85
80

Metadata

Licenseunknown
Version1.0.0
Updated3/18/2026
Publishersizukutamago

Tags

prompting