Skip to content

feat(me): add tmux-testing skill for TTY-required hook testing - #436

Merged
baleen37 merged 1 commit into
mainfrom
feat/tmux-skill
Feb 6, 2026
Merged

feat(me): add tmux-testing skill for TTY-required hook testing#436
baleen37 merged 1 commit into
mainfrom
feat/tmux-skill

Conversation

@baleen37

@baleen37 baleen37 commented Feb 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add tmux-testing skill for SessionStart/SessionStop hook testing
  • Enables automated testing of TTY-required interactive CLI tools
  • Provides polling-based waiting pattern instead of fixed sleep delays

Test plan

  • RED phase: Baseline testing showed agents use fixed sleep and non-unique session names
  • GREEN phase: Skill written with 4 CRITICAL requirements addressing baseline failures
  • REFACTOR phase: Verified agents comply with skill even under time pressure
  • All baseline violations (fixed sleep, test-$$ without $RANDOM) now addressed

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added comprehensive tmux-based testing guide covering best practices, critical requirements, and usage scenarios
    • Includes tmux command reference, concrete code examples, and debugging tips
    • Provides CI/CD considerations and guidance on timeout handling and environment setup
    • Documents common mistakes and when tmux-based testing is appropriate

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>
@coderabbitai

coderabbitai Bot commented Feb 6, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

New 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

Cohort / File(s) Summary
Tmux Testing Documentation
plugins/me/skills/tmux-testing/SKILL.md
New guide covering tmux testing best practices, including critical requirements (trap cleanup, detached sessions, unique names, polling patterns), usage scenarios, command references, mandatory wait_for_output helper function, baseline examples for session lifecycle and hook testing, common anti-patterns, debugging strategies, and CI/CD guidance.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 In tmux's halls where sessions bloom,
We test with care, no guesswork gloom,
With polling tricks and cleanup charms,
Our guide protects from timing harms.
Now every test runs true and straight—
No sleep commands, just polls first-rate!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a tmux-testing skill documentation for testing TTY-required hooks, which aligns with the primary focus of the new SKILL.md file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/tmux-skill

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

OUTPUT leaks to the caller scope, and grep -q "$expected" treats the pattern as regex (surprising if expected contains regex metacharacters). Consider local OUTPUT and grep -F for 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

Comment on lines +14 to +35
**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)
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

@baleen37
baleen37 merged commit b40ee3c into main Feb 6, 2026
5 checks passed
@baleen37
baleen37 deleted the feat/tmux-skill branch February 6, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant