Skip to content

Persistent PTY Sessions

Lets the agent drive interactive terminal programs (REPLs, sudo, ssh prompts) with state kept across calls

Repository
aden-hive/hive
Stars
11,132
Licence
Apache-2.0
Files
1 file

What it does

This skill teaches an AI agent how to keep a live terminal session open and talk to interactive programs such as Python's REPL, mysql, psql, or ssh, which normally expect a human at a keyboard. Once installed, the agent knows when a persistent session is worth the cost, how to wait for a prompt, how to send raw input and read the response, and how to close sessions so they don't pile up against a fixed limit. It also documents a policy of always using bash on macOS rather than zsh.

Great for

  • Developers who want an AI agent to run multi-step terminal work where directory changes or environment variables must persist
  • Users who need an agent to drive a database shell or Python REPL and read results
  • Teams running the Hive agent framework that need consistent shell behavior across Linux and macOS

Skip it if

  • Simple one-off shell commands, where the skill itself says the simpler terminal_exec tool is better
  • Environments where the agent should not type passwords or accept host-key prompts, since the examples send sudo passwords and answer 'yes' to ssh host-key confirmations and passwords end up in a buffer
  • Users who are not running the Hive framework or a compatible tool set, because the skill depends on terminal_pty_open, terminal_pty_run and terminal_pty_close tools that this file does not provide

Try asking

  • “Open a persistent shell, cd into /var/log, and list the log files without losing the directory between commands”
  • “Start a Python REPL, set x = 42, then print x squared and report the result”
  • “Connect to a remote host over ssh, accept the host-key prompt, and reach the password prompt”
  • “Run a sudo command that asks for a password and continue once the prompt appears”
Step-by-step guide: how to use Persistent PTY SessionsInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 1 original files, the Apache-2.0 licence and an attribution note.

    terminal-tools-pty-sessions.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip terminal-tools-pty-sessions.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip terminal-tools-pty-sessions.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Always call terminal_pty_close when finished, because leaked sessions count against the session cap and idle reaping should not be relied on
  • Use terminal_exec for simple commands and reserve persistent sessions for state-dependent or interactive work
  • Avoid putting real passwords into commands; the skill warns they are retained in the ring buffer, so review any sudo or ssh session carefully

What's inside

  • SKILL.md

Redistributed unmodified from aden-hive/hive under the Apache-2.0 licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.