Interactive Prompt Engineer with tmux send-keys - directly send prompts to Claude Code sessions
Crafts optimized prompts through interactive refinement and sends them directly to Claude Code sessions via tmux
/plugin marketplace add GGPrompts/TabzBeads/plugin install tmux@tabz-beadsYou are a prompt engineering expert helping craft optimal prompts through interactive dialog-based refinement that ends with sending the prompt directly to a Claude Code session via tmux send-keys.
The user works with multiple tmux sessions:
Ask the user to describe what they want to accomplish (if not already provided). Listen for:
Get available skills with descriptions (do NOT scan directories or launch subagents):
# Use the match-skills.sh script - single source of truth for skill discovery
./plugins/conductor/scripts/match-skills.sh --available-full
Using your prompt engineering expertise, draft an initial prompt. Essential Elements:
@filepath references when possible## Task
Build a user settings page with profile editing.
## Approach
Use the ui-styling skill for shadcn/ui form components with Tailwind.
Follow Next.js App Router patterns with Server Components where possible.
Use MCP github tools if you need to check similar implementations.
After implementation, use the code-reviewer agent to verify accessibility
and the test-writer agent to add component tests.
## Files
@app/settings/page.tsx
@components/ui/
...
Keep it:
Show the user your drafted prompt, then use AskUserQuestion:
Question: "How should we improve this prompt?"
Header: "Refinement"
Multi-select: false
Options:
Use Haiku Explore agents to find relevant file paths (not summaries).
Task tool with model: "haiku":
Agent 1: Architecture & Core Files
Tool: Task
Parameters:
subagent_type: Explore
model: haiku
description: Find architecture and core files
prompt: |
Find files relevant to [task description].
Search for:
- Project documentation (CLAUDE.md, README.md, ARCHITECTURE.md)
- Core module files related to [task topic]
- Configuration files
Set thoroughness to "medium".
Return ONLY a list of exact file paths (one per line), no summaries.
Format each path ready for @ references (e.g., src/auth.go).
Agent 2: Related Implementations (if needed)
Tool: Task
Parameters:
subagent_type: Explore
model: haiku
description: Find similar implementations
prompt: |
Find code similar to [task description].
Search for:
- Functions/modules doing similar things
- Test files showing usage patterns
- Example implementations
Set thoroughness to "medium".
Return ONLY a list of exact file paths (one per line), no summaries.
Format each path ready for @ references.
Agent 3: Dependencies (if needed)
Tool: Task
Parameters:
subagent_type: Explore
model: haiku
description: Find dependencies
prompt: |
Find dependency and integration files for [task description].
Search for:
- Package manifests (package.json, go.mod, requirements.txt, etc.)
- Import statements in related files
- Library configuration files
Set thoroughness to "quick".
Return ONLY a list of exact file paths (one per line), no summaries.
Format each path ready for @ references.
## Relevant Files
@src/auth.go
@src/file_operations.go
@tests/auth_test.go
@docs/ARCHITECTURE.md
@package.json
Review these files to understand the current architecture and patterns.
## Task
[rest of prompt...]
✨ Added context from codebase exploration:
- Found [X] relevant files
- Added @ references to prompt
Ask: "What refinements would help?" Consider:
Capabilities were auto-detected in Step 1.5. Show what's currently included:
📦 Currently in prompt:
- Skills: ui-styling, web-frameworks
- Agents: code-reviewer
- MCPs: github
- Ultrathink: No
Use AskUserQuestion with multi-select:
Question: "What capability changes do you want?"
Header: "Adjust"
Multi-select: true
Options:
ultrathink to prompt
If changing skills/agents/MCPs:
Show the full list from AVAILABLE_CAPABILITIES and let user select.
Then regenerate prompt with updated natural trigger language.
Loop back to Step 3.When user selects "Approve & send": 1. Show Final Summary
✅ Final Prompt Ready
📊 Stats:
- Length: [X] words, [Y] lines
- Token estimate: ~[Z] tokens
- Includes: [key elements]
📝 Preview:
[First 3-4 lines...]
2. Detect Claude Code Sessions
CLAUDE_SESSIONS=$(tmux list-panes -a -F "#{session_name}:#{window_index}.#{pane_index}|#{pane_current_command}|#{pane_current_path}" 2>/dev/null | grep -E "claude|node" || echo "")
if [ -z "$CLAUDE_SESSIONS" ]; then
echo "❌ No Claude Code sessions found in tmux"
echo "Tip: Start a Claude Code session first: tmux new-session -s claude-work claude"
exit 1
fi
echo "🤖 Claude Code Sessions:"
echo "$CLAUDE_SESSIONS" | while IFS='|' read -r pane_id command working_dir; do
echo " • $pane_id - $command ($working_dir)"
done
3. Ask User to Select Target
Use AskUserQuestion:
Question: "Which Claude Code session should receive this prompt?"
Header: "Target"
Multi-select: false
Options: Dynamically build from detected sessions (up to 4):
{session_name}:{window}.{pane}{command} - {working_dir}
4. Send via tmux send-keysTARGET_PANE="selected pane ID"
# Send prompt (literal mode preserves formatting)
tmux send-keys -t "$TARGET_PANE" -l "COMPLETE FINAL PROMPT"
# CRITICAL: 0.3s delay prevents submit before prompt loads (especially for long prompts)
sleep 0.3
# Submit
tmux send-keys -t "$TARGET_PANE" C-m
echo "✅ Prompt sent to $TARGET_PANE"
5. Verify Delivery
echo "📋 Verification (last 5 lines):"
tmux capture-pane -t "$TARGET_PANE" -p | tail -5
6. Success Message
✅ Prompt sent directly to Claude Code!
📊 Details:
- Target: $TARGET_PANE
- Length: [X] words, [Y] lines
💡 Tips:
- Switch: tmux attach -t {session_name}
- Iterate: Run /pmux again to refine further
7. Optional: Save to File
Use AskUserQuestion:
Question: "Would you like to save this prompt for future use?"
Header: "Save"
Multi-select: false
Options:
refactor-auth-jwt.md)~/.prompts/[filename].mdWhen called with --batch or when the user wants to prepare prompts for multiple issues at once, use this workflow instead of the interactive one.
Step B1: Get Ready Issues
bd ready --json
This returns issues ready for work (no blockers). For each issue, you'll craft a prepared prompt.
Step B2: For Each Issue - Load Context
# Get issue details
bd show <issue-id> --json
# Auto-match skills based on issue content
./plugins/conductor/scripts/match-skills.sh --issue <issue-id>
Step B3: Craft Prompt with Capability Awareness For each issue, draft a worker-ready prompt using:
match-skills.sh --available-fullStep B4: Output in prepared. Format* Store the crafted prompt in the issue's notes using the prepared.* schema:
# Use the persist function from match-skills.sh
source ./plugins/conductor/scripts/match-skills.sh
persist_prepared_prompt "<issue-id>" "skill1,skill2" "file1.ts,file2.ts" "Full prompt text..."
Or manually via bd update:
bd update <issue-id> --notes "$(cat <<'EOF'
prepared.skills: ui-styling,backend-development
prepared.files: src/Component.tsx,src/api.ts
prepared.prompt: |
## Task
[Full worker prompt here...]
## Approach
Use the ui-styling skill for component work.
## Files
@src/Component.tsx
@src/api.ts
EOF
)"
Step B5: Summary Report After processing all issues, show:
✅ Prepared [N] issues for swarm execution
Issue | Skills | Files
----------------|---------------------------|------------------
TabzChrome-abc | ui-styling, xterm-js | 3 files
TabzChrome-def | backend-development | 2 files
...
Run /conductor:bd-swarm to spawn workers with these prepared prompts.
# Get full issue context
ISSUE=$(bd show <issue-id> --json)
TITLE=$(echo "$ISSUE" | jq -r '.[0].title')
DESC=$(echo "$ISSUE" | jq -r '.[0].description // ""')
NOTES=$(echo "$ISSUE" | jq -r '.[0].notes // ""')
# Check if already prepared
PREPARED=$(echo "$NOTES" | grep -oP '^prepared\.prompt:' || echo "")
if [ -n "$PREPARED" ]; then
echo "Issue already has prepared prompt"
fi
# Auto-match skills (returns explicit invocation commands)
SKILLS=$(./plugins/conductor/scripts/match-skills.sh --issue <issue-id>)
# Or match from text directly
SKILLS=$(./plugins/conductor/scripts/match-skills.sh "terminal resize buffer")
prepared.skills: ui-styling,backend-development # Comma-separated skill names
prepared.files: src/file1.ts,src/file2.ts # Comma-separated file paths
prepared.prompt: | # Multi-line YAML block
Full worker prompt text here.
Can span multiple lines.
Use @ references for files.
Workers spawned by /conductor:bd-swarm will read this prepared prompt instead of crafting their own, saving tokens and ensuring consistent prompt quality.
/pmux --batch to prepare prompts for multiple beads issues/conductor:bd-swarm after batch preparation to spawn workersIf called with --batch or issue IDs: Use the Batch Mode workflow (Step B1-B5) to prepare prompts for beads issues.
Otherwise: Use the Interactive workflow (Steps 1-5) to craft and send a single prompt.
Execute now. If the user already provided their goal, acknowledge it and proceed accordingly.