0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

herdr で新しいタブを開くたびに claude と打つ手間をなくす

0
Last updated at Posted at 2026-11-20

herdr で、1 回のキー操作で新しいタブを開いて Claude Code(claude)を立ち上げる設定を紹介します。
herdr tab create には、起動するコマンドを渡す引数がありません1。
そこで、キー割り当て [[keys.command]] から CLI の tab create と agent start を続けて呼びます。

動かした環境

次の 4 点がそろえば動きます。

  • herdr: v0.9.5
  • OS: WSL2(Linux x86_64)
  • jq: tab create の応答の JSON から、新しいペインの ID を取り出すのに使う
  • claude: PATH が通っている

Claude Code 連携(herdr integration install claude)は不要です。

config.toml にキー割り当てを 1 つ足す

下の設定を足すと、キーを押したときに次の順に動きます。

  1. tab create --focus が今の space に新しいタブを作ってそのタブへ移り、新しいペインの ID を JSON で返す1
  2. ペインの ID から、エージェント名(claude- で始まる名前)を作る
  3. agent start が、新しいペインのシェルで claude を起動する

~/.config/herdr/config.toml に、次の 5 行を足します。

~/.config/herdr/config.toml
[[keys.command]]
key = "prefix+shift+c"
type = "shell"
description = "new tab + claude"
command = 'p=$("$HERDR_BIN_PATH" tab create --workspace "$HERDR_ACTIVE_WORKSPACE_ID" --focus | jq -r .result.root_pane.pane_id) && n=claude-$(printf %s "$p" | sed "s/[A-Z]/_&/g" | tr "A-Z:" "a-z-") && "$HERDR_BIN_PATH" agent start "$n" --kind claude --pane "$p"'

herdr は、command のシェルに次の 2 つを環境変数で渡します2。

  • HERDR_BIN_PATH: herdr の実行ファイルのパス
  • HERDR_ACTIVE_WORKSPACE_ID: 今の space の ID

--kind claude は、起動するエージェントに claude を選びます1。

シェルで、設定を読み込み直します。

herdr server reload-config

Ctrl+B → Shift+C を押して、次の 3 点を確認します。

  • 新しいタブで claude が起動する
  • サイドバーの agents の欄に、そのエージェントが出る
  • 普通の新しいタブ(prefix+c)は、シェルのまま開く

名前を claude に決め打ちすると、1 回目が動いている間は 2 回目で失敗する

エージェント名は、起動のたびに変わる値から作ります。
agent start claude --kind claude のように名前を claude に決め打ちしたとします。
1 回目の claude が動いている間にもう一度押すと、次のエラーで失敗します。

{"error":{"code":"agent_name_taken","message":"agent name claude is already used; candidates: terminal_id=<terminal_id> pane_id=w3:pP workspace_id=w3 tab_id=w3:tP cwd=/home/<user>/<project> status=Idle"},"id":"cli:agent:start"}

エージェント名は、生きているエージェントの中で一意でなければなりません。
名前の形も決まっていて、[a-z][a-z0-9_-]{0,31} に合う必要があります1。

上の設定では、新しいペインの ID を名前の形に変換して使っています。

  • sed "s/[A-Z]/_&/g": 大文字の前に _ を足す
  • tr "A-Z:" "a-z-": 大文字を小文字に、: を - に替える

ペインの ID はタブごとに違うので、同じ space で 2 回目以降に押しても名前が重なりません。

まとめ

  • エージェント名は、新しいペインの ID のように起動ごとに変わる値から作る

参考

  1. herdr v0.9.5 の CLI reference(https://herdr.dev/llms-full.txt ・2026-11-20 に確認) ↩ ↩2 ↩3 ↩4

  2. herdr v0.9.5 の Custom command keybindings(https://herdr.dev/docs/configuration/ ・2026-11-20 に確認) ↩

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?