feat(me): add tmux-testing skill for TTY-required hook testing - #436
Conversation
Add new skill for testing SessionStart/SessionStop hooks and interactive CLI tools that require real TTY. Uses tmux for isolated terminal sessions with proper cleanup, unique naming, and polling-based waiting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughNew documentation file introducing a comprehensive tmux-based testing guide, covering requirements, usage scenarios, command references, helper functions, examples, anti-patterns, debugging tips, and CI/CD considerations for tmux-dependent tests. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@plugins/me/skills/tmux-testing/SKILL.md`:
- Around line 14-35: Add a blank line before and after each fenced code block in
the CRITICAL requirements section of SKILL.md so markdownlint MD031 is
satisfied; specifically, surround the code fences that show the trap cleanup
(trap "tmux kill-session -t '$SESSION_NAME' ..."), the tmux new-session example
(tmux new-session -d -s "$SESSION_NAME"), the SESSION_NAME example
(SESSION_NAME="test-$$-$RANDOM"), and the wait_for_output example
(wait_for_output "$SESSION_NAME" "expected" 10) with an empty line both above
the opening ``` and below the closing ``` for each block.
🧹 Nitpick comments (1)
plugins/me/skills/tmux-testing/SKILL.md (1)
76-94: Make output capture local and avoid regex matching in polling.
OUTPUTleaks to the caller scope, andgrep -q "$expected"treats the pattern as regex (surprising ifexpectedcontains regex metacharacters). Considerlocal OUTPUTandgrep -Ffor literal matches.♻️ Proposed fix
wait_for_output() { local session="$1" local expected="$2" local max_attempts="${3:-20}" local attempts=0 while [ $attempts -lt $max_attempts ]; do - OUTPUT=$(tmux capture-pane -t "$session" -p) - if echo "$OUTPUT" | grep -q "$expected"; then + local OUTPUT + OUTPUT=$(tmux capture-pane -t "$session" -p) + if echo "$OUTPUT" | grep -F -q "$expected"; then return 0 fi
| **MUST do for every tmux test:** | ||
|
|
||
| 1. **ALWAYS use trap cleanup** - Failed tests leave zombie sessions | ||
| ```bash | ||
| trap "tmux kill-session -t '$SESSION_NAME' 2>/dev/null || true" EXIT | ||
| ``` | ||
|
|
||
| 2. **ALWAYS use `-d` flag** - Without `-d`, session blocks your terminal | ||
| ```bash | ||
| tmux new-session -d -s "$SESSION_NAME" # NOT tmux new-session -s "$SESSION_NAME" | ||
| ``` | ||
|
|
||
| 3. **ALWAYS use unique session names** - Concurrent tests collide | ||
| ```bash | ||
| SESSION_NAME="test-$$-$RANDOM" # NOT SESSION_NAME="test-$$" or "test" | ||
| ``` | ||
|
|
||
| 4. **PREFER polling over sleep** - Fixed delays create slow/flaky tests | ||
| ```bash | ||
| wait_for_output "$SESSION_NAME" "expected" 10 # NOT sleep 5 (10 = 5 seconds with 0.5s intervals) | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Add blank lines around fenced code blocks (MD031).
Markdownlint flags missing blank lines around fences in the CRITICAL requirements section. Add a blank line before and after each fenced block.
✍️ Example fix (apply to each fenced block in this section)
1. **ALWAYS use trap cleanup** - Failed tests leave zombie sessions
+
```bash
trap "tmux kill-session -t '$SESSION_NAME' 2>/dev/null || true" EXIT
```
+🧰 Tools
🪛 markdownlint-cli2 (0.20.0)
[warning] 17-17: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
[warning] 22-22: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
[warning] 27-27: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
[warning] 32-32: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
🤖 Prompt for AI Agents
In `@plugins/me/skills/tmux-testing/SKILL.md` around lines 14 - 35, Add a blank
line before and after each fenced code block in the CRITICAL requirements
section of SKILL.md so markdownlint MD031 is satisfied; specifically, surround
the code fences that show the trap cleanup (trap "tmux kill-session -t
'$SESSION_NAME' ..."), the tmux new-session example (tmux new-session -d -s
"$SESSION_NAME"), the SESSION_NAME example (SESSION_NAME="test-$$-$RANDOM"), and
the wait_for_output example (wait_for_output "$SESSION_NAME" "expected" 10) with
an empty line both above the opening ``` and below the closing ``` for each
block.
Summary
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit