agentpen-cli
v0.1.2
Published
The team room for your coding agents - share live Claude Code / Codex sessions with your whole company
Maintainers
Readme
Agentpen
The team room for your coding agents. Run Claude Code, Codex or any terminal agent exactly as you do today. Every session shows up on a shared team page where teammates can watch, steer, or unblock it from a browser.
npm install -g agentpen-cli # the command is `agentpen`
agentpen install # or share one session: agentpen claudeHosted at agentpen.app. The npm package is agentpen-cli (the bare name agentpen belongs to an unrelated project).

Why a company buys this
Coding agents made every engineer a manager of long-running work, but the work is trapped in one person's terminal. When the agent stops to ask a question and its owner is in a meeting, it sits there. Nobody else can see it, help it, or learn from it.
| Problem | What Agentpen does |
| --- | --- |
| Agents wait on one person | The session turns amber ("Needs a human") on the team page and posts to Slack. Any teammate answers from a browser or phone. |
| Pairing on an agent needs screen share | Teammates click a session and are in the real terminal. Nothing to install, no codes, no tunnels, no VPN. |
| Nobody knows what agents are doing | One page: who is running what, on which repo and branch, working / idle / stuck. |
| Security asks "who told it to do that?" | Prompts sent by teammates are attributed and logged. Every session is recorded and replayable. Per-workspace audit trail. |
| Rollout friction | npx agentpen-cli claude, approve once in the browser. Everyone with the company email domain lands in the workspace automatically. |
How it works
your laptop Agentpen teammates
┌──────────────────┐ outbound ┌───────────────┐ browser ┌──────────────┐
│ agentpen claude │────wss─────▶│ hub + API │◀────wss──────│ watch / type │
│ └ PTY ─ claude │ (masked) │ SQLite + casts│ │ chat / prompt│
└──────────────────┘ └───────────────┘ └──────────────┘- The CLI wraps your agent in a PTY. Your terminal behaves exactly as before.
- It only dials out to the server, so it works behind corporate firewalls.
- Values found in
.env*files are masked before the stream leaves the machine. - The browser renders the host's exact terminal grid and scales it to fit, so viewers never resize the host's agent.
Two ways in, one team page
Developers split between a terminal agent and a desktop app. Both land on the same workspace page, with the same people, chat, permissions, audit trail and "needs a human" signal.
| | Claude Code and other terminal agents | Codex desktop app |
| --- | --- | --- |
| Start sharing | agentpen claude (or codex, aider, anything) | agentpen codex-app, pick a conversation |
| What teammates see | The live terminal, exactly as the host sees it | The conversation: messages, commands run, files edited |
| How teammates take part | Type in the terminal, or send an attributed prompt | Send a prompt; it is queued into the conversation under their name |
| "Needs a human" | Heuristic on terminal output | Exact: Codex reports when it is waiting for approval or input |
| After it ends | Terminal replay | Saved transcript |
The Codex bridge talks to the app's own local control socket. It reads only the conversation you picked, never shares reasoning or system instructions, and never answers a tool approval: those stay with the host in the app.
No prefix to remember
Most developers will keep typing claude and keep using the Codex app. One command makes both share on their own:
agentpen install- Claude Code: a small hook in your shell file makes plain
claudestart a shared session. It prints one quiet line with the link and otherwise behaves as before. One-off commands (claude -p,claude mcp …,claude update), scripts and pipes are never shared. - Codex app (macOS): a background helper watches the app and shares a conversation while it is active, then stops once it has been quiet for 20 minutes. Only conversations inside a git repository are shared, so general chat stays out. On other systems, keep
agentpen watchrunning.
It is built to stay out of the way. If the server is unreachable, you are signed out, or Agentpen is removed from the machine, claude simply runs as normal, after at most a couple of seconds' wait.
| To | Run |
| --- | --- |
| Stop sharing new sessions for now | agentpen pause (and agentpen resume) |
| Keep one session private | AGENTPEN_OFF=1 claude |
| Undo everything | agentpen uninstall |
Everyone in the workspace can see shared sessions, so install is something each developer chooses to run, and it says so when it finishes.
Share a session that is already running
Sometimes the agent is an hour into something before you think to share it. You do not have to restart it. Inside Claude Code, type:
/agentpenThe session appears on the team page, and teammates can prompt it. (/agentpen stop stops sharing, /agentpen --private starts it visible only to you.)
Agentpen did not start that session, so it has no terminal to stream or type into. Two things stand in for it:
- What the team sees is the conversation, read from the file Claude Code keeps on disk: your messages, the agent's replies, the commands it ran with their output, and which files it read or edited. Reasoning and file contents are not shared, and
.envvalues are masked. - How a teammate's prompt gets in is a Claude Code hook that
/agentpenregisters for the rest of that session. Each time Claude finishes a turn, the hook waits in the background; when a teammate sends a prompt, it hands it to Claude under their name, waking Claude if it was idle. A prompt sent while Claude is busy shows as queued and goes in when the turn ends.
Who may prompt follows the same setting as every other session ("Teammates can prompt" or "Teammates watch only"), and a teammate's prompt runs with whatever permissions that Claude Code session has, so read "can prompt" as "people I would hand my laptop to". An invited agent cannot be handed the wheel in these sessions.
agentpen share, run from another terminal in the same folder, shares the conversation too, but watch-only: without /agentpen there is no hook inside the session to deliver prompts. Typing /agentpen later opens prompting up on the same share. Sharing stops when Claude Code exits, after 30 quiet minutes, or with agentpen share stop.
/agentpen is a personal Claude Code skill (~/.claude/skills/agentpen/), added by agentpen login and agentpen install on machines where Claude Code has run, and removed by agentpen uninstall. Installing the npm package does not write outside its own folder.
Bring another agent into the session
A session does not have to depend on one model any more than on one person. An admin connects the agents the team may invite, under Settings:
| Agent | From | Needs | Invite with |
| --- | --- | --- | --- |
| Claude | Anthropic | an API key | @claude |
| Grok | xAI | an API key and a model name | @grok |
| Muse | Meta | an API key and a model name | @muse |
Once one is connected, anyone in a session can:
- Ask for a second opinion. Start a chat message with the agent's name ("@claude is this migration safe?", "@grok do you agree?"). It reads what the session shows, plus the prompts and chat so far, and answers in the chat for everyone.
- Get caught up. "Catch me up" writes a short note: the goal, what is done, where things stand, and the next step. It is kept with the session, shown to whoever opens it, and printed by
agentpen pickup. - Hand over the wheel (host only). Give Claude a goal and it steers your agent, one instruction at a time, for up to eight steps. Every instruction is attributed ("Claude (for Ana)") and logged. Anyone who can manage the session can take the wheel back at any moment.
The guardrail that matters: an invited agent never answers an approval prompt. If your agent stops to ask a human something, the invited agent says so in chat and waits; it does not even plan a next move until a person has answered. It also has no access to the machine. All it can do is type an instruction to the agent that is already running, as a teammate could.
Each of these sends the visible part of that session to the chosen agent's provider under the workspace's key, and only when a person asks. With more than one agent connected, the session page has a picker for which one to ask, hand over to, or have write the catch-up. Keys are stored encrypted and are never returned by the API. Private sessions stay with their host.
Claude goes through the Anthropic SDK. Grok and Muse both offer an OpenAI-compatible Chat Completions endpoint (api.x.ai/v1, api.meta.ai/v1) and share one adapter in server/agents.js; any other model with that kind of endpoint is one more entry there. For Grok and Muse you type the model name yourself, exactly as the provider lists it, because their model names change often.
Search every session
The search box on the Sessions page looks through everything past sessions recorded: terminal output, Codex conversations, prompts teammates sent, chat, and catch-up notes. "Has anyone's agent hit this error before?" becomes a query. Sessions are indexed when they end; private ones are found only by their host.
Who can see a session
Every session has one of three settings, and its host can change it at any moment from the session page:
| Setting | Who sees it | | --- | --- | | Private | Only the host. It is not listed, cannot be opened, and is not announced to anyone, workspace admins included. | | Teammates watch | The workspace can see it; only the host types. | | Teammates can type | The workspace can see it, type, and send prompts. |
Switching a live session to private shows everyone else out at once, kills any guest link, and takes down alerts the team had about it. A private session's recording, checkpoint and activity stay private after it ends, until the host makes it visible.
How a session starts is decided in this order: a flag on the command (--private, --watch-only), then your own default for this machine (agentpen default private), then the workspace's default (Settings). A workspace that wants sharing to be opt-in sets its default to "Private until shared".
When the laptop is shut
The session with all the context is on a machine that just went to sleep, and something needs doing now. Agentpen keeps a checkpoint so that is not a dead end.
While a Claude Code session runs through Agentpen, the CLI saves two things to the workspace about every 20 seconds, and once more on exit:
- The conversation: Claude Code's own session file, with
.envvalues masked. - The code: everything the team's remote does not already have. Unpushed commits plus uncommitted and new files, captured as a hidden commit. The host's branch, index and stash are not touched, and ignored files (
.env,node_modules) are never included.
Any workspace member can then carry on from their own clone:
agentpen pickup https://agentpen.yourco.com/s/k3Pq9xTz # add --worktree to use a separate folderThat creates a pickup/… branch at the host's commit, restores their uncommitted work as uncommitted work, puts the conversation where Claude Code looks for it, and starts claude --resume as a new shared session. The agent remembers everything up to the checkpoint. The original host is notified and the pickup is in the audit trail. The session page shows the command whenever a checkpoint exists, and says so when the host went offline mid-session.
Admins can turn checkpoints off for a workspace (Settings), and a host can skip them for one session with --no-handoff. Checkpoints are deleted 14 days after a session ends. On macOS the CLI also keeps an idle laptop awake while the agent is running; a closed lid still sleeps.
Notifications and the Mac app
The server decides who hears what and writes the words, so the web app, the Mac app and anything later behave the same.
| When | Who is told | | --- | --- | | Your agent stops to ask something | You, immediately, with the question itself. Marked urgent. | | It is still waiting a minute later | The rest of the workspace ("Ana's agent is stuck") | | Someone answers it | Everyone's alert is taken down automatically | | Your agent finishes a long stretch of work | You | | Someone joins, prompts your agent, or messages you | You (the host is usually in a terminal and would never see chat otherwise) | | A teammate goes live | Off by default |
Each kind can be switched off per person (Settings, or the Mac app). Nobody is notified about their own actions, and a client that was offline is caught up when it reconnects.
Web: in-app cards, plus browser notifications when the tab is in the background (turn on under Settings).
Mac menu bar app (mac/, macOS 13+): the menu bar shows how many agents are waiting on a human; the panel lists live sessions across your workspaces. Native notifications can be answered in place, so "Do you want to proceed?" gets a typed reply without leaving what you are doing. Alerts about your own agent skip the banner while your terminal or Codex is already in front.
cd mac && ./build-app.sh # needs the Xcode command line tools; full Xcode makes it universal
open dist/Agentpen.appCI builds the app on every push and attaches Agentpen.zip to the workflow run. It is ad-hoc signed, not notarized: first launch needs right-click, Open.
Run it locally
Needs Node 22.13+.
npm install
npm start # http://localhost:4400Open the page, enter an email, and click the on-screen sign-in link (shown only in local dev, when no mailer is configured). Create a workspace, then in any project directory:
npm link # once, to get the `agentpen` command
export AGENTPEN_URL=http://localhost:4400 # the CLI defaults to the hosted service
agentpen claude # or: agentpen codex, agentpen aider, agentpen -- npm run dev
agentpen codex-app # share a conversation from the Codex desktop appFirst run prints a code and opens the browser to approve the machine. The session then appears on the workspace page.
agentpen [agent] [args...] share a terminal agent (default: claude)
agentpen codex-app share a Codex desktop app conversation
agentpen share [stop] share a Claude Code session that is already running (/agentpen from inside it)
agentpen install | uninstall share automatically: plain `claude`, and the Codex app
agentpen pause | resume stop or restart automatic sharing on this machine
agentpen default private|watch|type|workspace how your sessions start on this machine
agentpen watch share active Codex app conversations (what install runs in the background)
agentpen pickup LINK carry on a teammate's Claude Code session here
--worktree pick up into a separate folder, leaving this one alone
--no-handoff (when sharing) do not checkpoint this session
--latest | --thread ID skip the picker
-t, --title TEXT name the session
-w, --workspace SLUG pick a workspace
--watch-only teammates can watch but not type
--private only you can see it until you share it
--share-secrets do not mask .env values
agentpen login | logout | whoamiDeploy
One process, one SQLite file, one volume. The same image is the hosted product and the self-hosted enterprise install.
docker build -t agentpen .
docker run -p 8080:8080 -v agentpen-data:/data \
-e AGENTPEN_URL=https://agentpen.yourco.com \
-e RESEND_API_KEY=re_... \
-e AGENTPEN_MAIL_FROM="Agentpen <[email protected]>" \
agentpen| Variable | Purpose |
| --- | --- |
| AGENTPEN_URL | Public address. Used in emails, links and cookie security. |
| RESEND_API_KEY, AGENTPEN_MAIL_FROM | Sends sign-in and invite emails through Resend. Without a key, links are only written to the server log. |
| AGENTPEN_DATA | Directory for the database and recordings (default ./data). |
| AGENTPEN_TRUST_PROXY=1 | Believe X-Forwarded-For (set when behind a load balancer). |
| AGENTPEN_SECRET | Encrypts stored provider keys. If unset, a key file is created beside the database. |
| ANTHROPIC_API_KEY | Optional, for self-hosting: one Claude credential for every workspace, instead of a key per workspace. |
| AGENTPEN_UPGRADE_URL | Where the "Upgrade" button sends admins (for example a Stripe payment link). |
| PORT | Listen port (default 4400; 8080 in the image). |
The published CLI talks to the hosted service at https://agentpen.app. Point it at your own deployment with agentpen login --server https://agentpen.yourco.com.
render.yaml is the Blueprint for the hosted service on Render: the same image, one persistent disk mounted at /data.
Security model
- Sign-in is by single-use emailed link; sessions are httpOnly cookies. CLI machines are approved in the browser and hold a revocable token. All tokens are stored hashed.
- A session is visible to members of its workspace only. Guest links are view-only, unguessable, and die with the session.
- The host, or a workspace admin, can switch a session to watch-only or end it at any time. Removing a member closes their open connections immediately.
- Anyone allowed to type in a session is typing into a real terminal on the host's machine. "Teammates can type" should be read as "people I would hand my laptop to"; workspaces can default to watch-only.
.envmasking is literal byte matching. It catches a straycat .env, not a secret that is encoded or split.- The server can read terminal output (it records it). End-to-end encryption is not implemented.
What is real and what is not yet
Working and covered by npm test (real server, real CLI, real PTY): accounts, workspaces, company-domain sign-up, email and link invites, roles, seat limits, live streaming, typing, attributed prompts, chat, watch-only, guest links, recordings and replay, audit trail, "needs a human" detection, Slack webhook, host reconnect, surviving a server restart, Codex app conversations (against a simulated Codex control socket), and checkpoint and pickup (against a stand-in for Claude Code; also run once by hand with the real one).
Not built:
- Billing. Plans and seat limits are enforced, but a plan is changed by editing the
plancolumn. There is no Stripe integration, only an upgrade link. - SSO / SAML / SCIM. Email links only.
- Horizontal scaling. Live sessions are held in one process. Past one node this needs a pub/sub layer and Postgres.
- Codex desktop app, verified only against the Codex app-server daemon. Listing, reading and queueing prompts were exercised against a real
codex app-server(0.171) on Linux, without a signed-in account, so no real agent reply was seen. It has not been run against the desktop app's window on a Mac. The bridge relies on Codex's experimental app-server API, polls for changes, and depends on the app picking up queued prompts. - The Mac app has been compiled by CI but never run. Nothing here can launch a Mac app, so sign-in, the menu bar panel and real notification banners have not been seen working. It has no app icon, is not notarized, and "time sensitive" delivery needs an Apple Developer entitlement it does not have.
- Invited agents have only been run against a simulated Anthropic API. The request the server sends was checked field by field and the flows are covered end to end, but no real reply from Claude, Grok or Muse has been seen. The Grok and Muse request shape was taken from search summaries of their docs, because those docs sites could not be opened from the build environment; xAI also describes Chat Completions as its legacy endpoint. What an invited agent reads from a terminal session is a plain-text capture of a terminal UI, and only its most recent part, so answers about long sessions can miss early context.
- Search covers ended sessions only, and terminal sessions are indexed from the same plain-text capture, so full-screen programs produce noisy matches.
- Automatic sharing is tested with bash and a simulated Codex app. The shell hook has not been run under zsh, the Mac default, and the macOS background helper (a launchd agent) has never been loaded on a real Mac. The helper finds coding conversations by whether Codex reports a git repository for them.
- Sharing a running session has no "needs a human" signal. The conversation file does not say when Claude Code is waiting on an approval, so such a session shows as working or idle, never amber. Teammates' prompts ride on Claude Code's background hooks (
asyncRewake), which are thinly documented: this was run once for real against Claude Code 2.1.331 (share with the skill, prompt from the page, idle session woke and answered) and is otherwise covered against a stand-in. Claude sees a teammate's prompt labelled as hook feedback rather than as something typed. If the session sits idle for more than 12 hours the waiting hook times out, and prompts then queue until the host's next turn./clearor/resumedrops the hook until/agentpenis typed again. - Pickup is Claude Code only, and only for sessions started through Agentpen. Codex sessions are not checkpointed. It moves the work to another person's machine; it does not keep the agent running in the cloud while every laptop is shut. Up to about 20 seconds of work before the lid closed can be missing. If the original host comes back and keeps going, the two copies diverge and are reconciled with git like any two branches.
- Checkpoints put source code on the Agentpen server, unencrypted at rest. That is the trade for being able to pick up; workspaces that cannot accept it should turn the setting off.
- No phone push. Notifications reach open browser tabs and the Mac app only.
- No Claude desktop app support. Claude Code is shared from the terminal only.
- "Needs a human" is a heuristic for terminal sessions: the terminal went quiet and the last lines look like a question. Agent-native hooks would be exact.
- Per-session privacy within a workspace, retention policies, and E2E encryption.
Layout
server/index.js HTTP API, static files, WebSocket upgrade, auth
server/hub.js live sessions: host <-> viewers, replay buffer, recording, status
server/db.js SQLite schema and helpers
cli/agentpen.js the `agentpen` command
cli/codex-app.js bridge to the Codex desktop app's control socket
cli/install.js `agentpen install`: the shell hook and the macOS background helper
cli/handoff.js checkpoints and `agentpen pickup`
cli/claude-share.js `agentpen share`: follow a running Claude Code conversation
cli/redact.js .env masking
server/notify.js who is notified about what; per-user stream and preferences
server/agents.js invited agents: Claude via the Anthropic SDK (second opinion, summary, steering)
server/search.js full-text search over ended sessions
mac/ the menu bar app (SwiftUI)
web/ the web app (no build step)
test/e2e.test.js end-to-end testsCredits
Inspired by manycode (MIT), a peer-to-peer tool for sharing a live agent terminal with a short code. Agentpen is a separate codebase built around accounts, workspaces and a hosted relay; the .env masking approach and the join-time repaint trick are adapted from it.
