Self-optimize worker context by analyzing issue, identifying skills, and restarting with enhanced prompt
Optimizes worker context by analyzing issues, matching skills, and resetting with enhanced prompts.
/plugin marketplace add GGPrompts/TabzBeads/plugin install conductor@tabz-beadsWorkers call this command to optimize their context before starting real work.
Flow:
1. Analyze current issue (from bd show or provided ID)
2. Identify relevant skills based on keywords
3. Find key files (quick search, size-checked)
4. Craft enhanced prompt with skill triggers
5. Trigger context reset (/clear) and auto-submit enhanced prompt
Use /conductor:worker-init when:
If you have an issue ID from your prompt, get the details:
ISSUE_ID="TabzChrome-xxx" # From your initial prompt
bd show "$ISSUE_ID" --json 2>/dev/null || bd show "$ISSUE_ID"
Extract key fields:
Use the central skill matching script (single source of truth):
# Find the script (works from project root or with CLAUDE_PLUGIN_ROOT)
MATCH_SCRIPT="${CLAUDE_PLUGIN_ROOT:-./plugins/conductor}/scripts/match-skills.sh"
# Get skill hints for an issue (reads from notes if persisted, or matches on-the-fly)
SKILL_HINTS=$($MATCH_SCRIPT --issue "$ISSUE_ID")
# Or match directly from text:
SKILL_HINTS=$($MATCH_SCRIPT "$TITLE $DESCRIPTION $LABELS")
Key mappings (see scripts/match-skills.sh for complete list):
Combine multiple matches if the issue spans domains.
Do a fast, targeted search (max 30 seconds):
# Find files matching keywords from title
KEYWORD="terminal" # Main keyword from title
grep -rl "$KEYWORD" --include="*.ts" --include="*.tsx" . 2>/dev/null | head -5
# Check file sizes (skip if >500 lines)
wc -l /path/to/file.ts
Rules:
extension/ and backend/ over testsBuild the enhanced prompt using this exact structure:
Fix beads issue ISSUE-ID: "Title"
## Context
[Description from bd show - explains WHY and provides implementation hints]
## Key Files
- path/to/file1.ts (brief note on relevance)
- path/to/file2.ts
[Or: "Explore as needed based on the issue description."]
## Approach
[Skill triggers woven naturally:]
Use the xterm-js skill for terminal rendering. Reference existing patterns in Terminal.tsx for consistency.
After implementation, verify the build passes and test the changes work as expected.
## When Done
Run: /conductor:bdw-worker-done ISSUE-ID
This command will: build, run code review, commit changes, and close the issue.
Key principles:
Save the enhanced prompt to a temp file and trigger context reset:
# Save enhanced prompt
PROMPT_FILE="/tmp/worker-init-$$.txt"
cat > "$PROMPT_FILE" << 'EOF'
[YOUR ENHANCED PROMPT HERE]
EOF
# Detect tmux pane
TMUX_PANE=$(tmux display-message -p '#{session_name}:#{window_index}.#{pane_index}' 2>/dev/null)
if [ -n "$TMUX_PANE" ]; then
# Copy to clipboard as backup
if command -v clip.exe &> /dev/null; then
cat "$PROMPT_FILE" | clip.exe
elif command -v xclip &> /dev/null; then
cat "$PROMPT_FILE" | xclip -selection clipboard -i &>/dev/null &
sleep 0.2
fi
echo "WORKER-INIT: Enhanced prompt ready, resetting context in 5 seconds..."
# Schedule the wipe and resubmit
(
sleep 5
# Cancel any pending operation
tmux send-keys -t "$TMUX_PANE" C-c
sleep 1
# Clear terminal scrollback
tmux clear-history -t "$TMUX_PANE"
tmux send-keys -t "$TMUX_PANE" C-l
sleep 0.5
# Send /clear command
tmux send-keys -t "$TMUX_PANE" '/'
sleep 0.5
tmux send-keys -t "$TMUX_PANE" -l 'clear'
sleep 0.3
tmux send-keys -t "$TMUX_PANE" C-m
# Wait for /clear to process
sleep 8
# Load and paste enhanced prompt
tmux load-buffer "$PROMPT_FILE"
sleep 0.3
tmux paste-buffer -t "$TMUX_PANE"
sleep 0.3
tmux send-keys -t "$TMUX_PANE" C-m
sleep 1
rm -f "$PROMPT_FILE"
) &
else
echo "ERROR: Not running in tmux!"
echo "Enhanced prompt saved to: $PROMPT_FILE"
echo "Manual steps: /clear then paste from file"
fi
Run this bash script with run_in_background: true, then say:
"Worker-init: Enhanced prompt ready, resetting context in 5 seconds. Backup copied to clipboard."
And stop. The background script will handle the rest.
For issue: "Fix terminal resize corruption when sidebar narrows quickly"
Fix beads issue TabzChrome-xyz: "Fix terminal resize corruption when sidebar narrows quickly"
## Context
Rapidly narrowing the Chrome sidebar during heavy terminal output causes text wrapping corruption. This is a race condition between resize events and xterm.js buffer updates.
## Key Files
- extension/components/Terminal.tsx (resize handling, FitAddon)
- extension/hooks/useTerminalSessions.ts (session lifecycle)
## Approach
Use the xterm-js skill for terminal rendering and resize handling. Focus on debouncing resize events and ensuring FitAddon.fit() completes before new output arrives. Reference the existing resize observer pattern in Terminal.tsx.
After implementation, verify the build passes and test rapid sidebar resizing with heavy output.
## When Done
Run: /conductor:bdw-worker-done TabzChrome-xyz
Skip worker-init if: