MiniPty lets a .NET app run a shell or a CLI tool in a PTY, a terminal without a window. The app types keys and reads the screen, as a person does. Each scene replays a recorded session and shows each call to MiniPty.

Next
shell 80 × 22
0 ms
Recorded on
MiniPty what the app writes and reads

WriteInputAsync00 B
ReadOutputAsync00 B
InputMode—
ExitStatusrunning
    The code the line that handles each event lights up
    
            

    Blue names are MiniPty. terminal is your UI, not part of MiniPty. Code that runs: README_MiniPty.cs starts, writes, resizes, and reads. WebTerminal.cs is a browser terminal.

    What happens

    Why MiniPty

    Measured in CI with 1,000 idle shells on the Linux runner and .NET 10, host process only. On Windows the host adds 10.3 MiB. The keystroke figure comes from the CI latency benchmark. How it was measured

    Knows when a program asks for a password

    On Linux and macOS, InputMode shows when sudo or ssh turns off echo for a password. An agent or a test script can stop there, ask a person, and keep the password out of its logs.

    Gets a command's result in one call

    CompleteAsync returns the output and the exit code. MiniPty.Capture also gives the time of each chunk. MaxOutputBytes ends a command that prints too much.

    Browser terminals that survive a restart

    PtyWebSocketBridge.RunAsync connects a shell to xterm.js in one call. When the shells run in a PTY host of their own, a web server restart does not end them. The page reconnects and gets the output it missed.

    Thousands of shells in one process

    A session that waits for output holds no thread. Reads, writes, and waits allocate nothing after the first call. So a web server or an agent host can keep thousands of shells open.

    Use MiniPty

    Add it to your app

    Start a shell or a CLI in a real PTY, type into it, and read its screen. MiniPty runs on .NET 10 on Windows, Linux, and macOS, and works with NativeAOT.

    dotnet add package MiniPty

    Build a terminal or an agent tool

    Samples show a browser terminal with xterm.js, a VS Code terminal, and a desktop terminal window. Other samples run commands and drive programs, as an AI agent does.

    Record your CLI for a README or a post

    scenetake runs a YAML scenario and records it as an asciinema .cast, an animated SVG, or an MP4. Its pty: true steps run through MiniPty. It also comes as a .NET tool and as a binary.

    npm install -g scenetake