---
name: shell_session_operator
description: Use when asked to drive live terminal sessions inside Cerebra for listeners, shells, PTY upgrades, or other interactive command-line work where shell compatibility, output waits, and control keys matter.
owner-feature: terminal
primary-job: Operate live terminal sessions with shell-aware sequencing inside Cerebra.
allowed-tools:
  - mcp__cerebra__workspace_snapshot
  - mcp__cerebra__hosts_list
  - mcp__cerebra__hosts_get
  - mcp__cerebra__workspace_open_tab
  - mcp__cerebra__workspace_open_pane
  - mcp__cerebra__terminal_read_history
  - mcp__cerebra__terminal_write
  - mcp__cerebra__terminal_send_control
  - mcp__cerebra__terminal_wait_for_pattern
  - mcp__cerebra__terminal_write_and_wait
---

# Mission

Use this skill for live terminal operations in Cerebra when shell behavior, interactive sequencing, or session control matters.

This skill only works inside a Cerebra AI session with the Cerebra MCP server available. If those MCP tools are unavailable, say that this skill only works inside Cerebra and stop.

Read [references/session-patterns.md](references/session-patterns.md) when shell compatibility, PTY stabilization, or interactive shell handling is central to the task.

## What This Skill Owns

- Live terminal execution loops that depend on recent output
- Listener setup, shell delivery, shell stabilization, and PTY upgrade flows
- Adapting commands to the observed shell or runtime instead of assuming a shell family
- Interrupting or steering running terminal sessions with real control keys

## What This Skill Does Not Own

- Large workspace layout composition across many panes or tabs
- Runbook persistence
- Cherry Notes persistence as the main task
- Browser, RDP, or VNC control loops

## Workflow

1. Start with `workspace_snapshot` so you know which panes and sessions already exist.
2. Open a fresh tab or pane only when the task genuinely needs a new live session and an existing suitable pane is not available.
3. Read the target terminal history before acting. Use `stripAnsi: true` whenever you need parseable output rather than exact terminal fidelity.
4. Infer the current shell or runtime from observed prompts, output, or a lightweight probe before relying on shell-specific behavior.
5. When you are sending a command and immediately waiting for output, prefer `terminal_write_and_wait`.
6. When you need a separate incremental wait, use `terminal_wait_for_pattern` with `sinceCursor`.
7. Use `terminal_send_control` for Ctrl-key actions like interrupting a listener or escaping a stuck interactive command.
8. After meaningful actions, re-read or re-wait so the next step stays grounded in the real session state.

## Operating Rules

- Do not invent intermediate setup steps, tools, or payload stages that were not observed or explicitly requested.
- Do not assume Bash, Zsh, or another shell family on a remote session without evidence.
- When shell-specific behavior matters, prefer explicit interpreter invocation over relying on the current shell implicitly.
- Keep multi-host work explicit: identify which pane or host each command targets before sending it.
- Distinguish operator control sessions from target shell sessions so commands do not cross the wrong boundary.
- Prefer small reversible commands over speculative one-shot chains when session state is uncertain.

## Completion Check

- The correct live session or sessions were targeted.
- Shell-specific assumptions were grounded in evidence, not guesswork.
- Output-dependent steps used `terminal_write_and_wait` or cursor-based waits where needed.
- Control-key input used `terminal_send_control`, not literal escape text.
