pty
PTY sessions for long-running processes, interactive input, signal sending (Ctrl+C), and live output tailing — use instead of bash when the process can't be run to completion synchronously
What it does
When to Use PTY
Use pty_spawn instead of bash when:
- The process runs in the background or long-running (dev servers, watchers, etc.)
- The command requires interactive input
- You need to send signals (Ctrl+C, Ctrl+D) mid-run
- You want to tail output while the process is still running
Key Sequences
| Action | Data |
|---|---|
| Ctrl+C (interrupt) | \x03 |
| Ctrl+D (EOF) | \x04 |
| Ctrl+Z (suspend) | \x1a |
| Enter | \n |
Send with pty_write: data="\x03"
Reading Output
Use the pattern parameter in pty_read to filter lines by regex:
pattern="error|ERROR" # find errors
pattern="ERROR|WARN|FATAL" # find warnings and errors
pattern="failed.*connection" # more specific match
pattern filters first, then offset/limit apply to the matches — original line numbers are preserved.
Checking Status
pty_list— see all running/exited sessionspty_readwith highoffsetor omit offset to see latest output- To tail last N lines:
offset = totalLines - N
Cleanup
pty_killwithcleanup=false(default) — stops process, keeps buffer for readingpty_killwithcleanup=true— stops process and frees buffer entirely
notifyOnExit
Set notifyOnExit=true to receive a message when the process exits, including exit code and last output line. Useful for build processes where you want to be notified on completion rather than polling.
Capabilities
Install
Quality
deterministic score 0.45 from registry signals: · indexed on github topic:agent-skills · 6 github stars · SKILL.md body (1,428 chars)