Pencil Gateway
Install, pair, and run Pencil-assigned work on your computer.
Pencil Gateway runs Pencil-assigned chats and tasks through your local Claude Code installation. Choose it when you want work to execute on a machine you control. Your Claude credentials stay local.
If you only want an external client to read or update Pencil through a hosted connection, go directly to Pencil MCP Server. Hosted MCP needs no gateway installation.
Install
For local task execution, install Node.js 20 or newer, npm, and a working, signed-in claude CLI on your PATH. Then install the gateway:
npm install -g @pencilink/gateway
The macOS and Linux double-click installers also install, pair, and start a user-level service. If you have an installer archive, extract it and open Install Pencil Gateway.command on macOS or Install Pencil Gateway.desktop on Linux. Linux may require Allow Launching. Neither installer needs sudo.
Pair and run
- Sign in to the Pencil account and select the workspace whose work should run on this computer. Open Settings → AI & Runtime → Local devices and select Generate pair code under Pencil Gateway local devices. Codes expire after 15 minutes and can be used once.
- Choose a unique local profile name for this account and workspace, such as
pencil. Runpencil-gateway pair --account penciland paste the code when prompted. - Run
pencil-gateway doctor --account pencilto check the local setup, thenpencil-gateway start --account pencilto start picking up eligible work. To run in the background and at sign-in instead, follow Run at sign-in below. - In Settings, choose Agent overrides or Assignee when available to route eligible work locally. The primary runtime remains the fallback when configured.
The pair code binds the device to the signed-in Pencil user and selected workspace. --account names the profile on this computer; it does not select or change the remote workspace. Use the same profile name for pairing, diagnostics, startup, and service commands. Omitting --account uses the shared default profile, so pairing again without it replaces that profile's saved pairing.
Leave the process running; Ctrl+C stops it. By default, the gateway runs up to three independent dispatches while keeping each task or chat thread serialized. Reduce local load with:
pencil-gateway start --account pencil --max-concurrency 1
Pairing stores a device token in ~/.pencil/gateway.pencil.json for the example profile, or ~/.pencil/gateway.json for the default profile, with user-only permissions. Treat it like a private key. Revoke a lost or unused device in Pencil settings. The paired-device list shows only devices belonging to your signed-in user in the current workspace.
Under Settings → AI & Runtime → Local devices → Paired devices, select Rename next to a device, enter a name, and select Save name. Names can contain up to 100 characters and must not be blank. Cancel or Escape discards the edit. The name is a display label; your pairing and local --account profile stay the same.
Self-hosted Pencil and multiple accounts or workspaces
Pair against your own Pencil host with:
pencil-gateway pair --account pencil --mc-url https://pencil.example.com
The saved URL is reused by start, status, doctor, and paired mcp. You can also set PENCIL_MC_URL before pairing.
Use a separate named profile for each Pencil account and workspace you want to run concurrently. Generate each code from the intended account and workspace before pairing:
pencil-gateway pair --account pencil
pencil-gateway start --account pencil
pencil-gateway pair --account other-workspace
pencil-gateway start --account other-workspace
pencil-gateway list
Profiles live in ~/.pencil/gateway.<account>.json. Use the same --account flag for diagnostics and services, and run one daemon per profile.
Run at sign-in
After a command-line installation and pairing:
pencil-gateway service install --account pencil
pencil-gateway service status --account pencil
This installs a user-level launchd service on macOS or systemd service on Linux. It starts at sign-in and restarts after unexpected failures. Double-click installers configure this automatically.
For global npm updates, run npm install -g @pencilink/gateway@latest, then pencil-gateway service install --account pencil again. The double-click installer can enable managed automatic updates. After re-pairing an already-running profile, reinstall its service with the same account name to restart it with the new pairing.
pencil-gateway service uninstall removes startup definitions while preserving pairing, work files, and logs. pencil-gateway unpair also removes the local pairing config.
Finding queued work and results
Open a task's Workflow panel. Configured steps describes its required workflow; “Work → Complete” does not mean those steps have happened. Agent progress shows the actual run and recorded execution steps without expanding Workflow details.
The Agent queue card identifies earlier work holding the same agent's slot, with a link and the next action. It follows the last manual Kanban or List ordering. Nudge retries delivery; it does not skip an active task, queue order or approval gates. Open the earlier task to answer a question, review a failure, inspect a finished run or check its runtime. Reorder waiting Inbox work or choose another available execution agent when priorities change. Large or restricted queues may omit an exact position or task details.
Recorded work shows linked output files and development references. Use View output files, View development and tests, or View activity to reach the work. No linked files means there are no recorded files, while comments or development references may still contain results. A finished run does not automatically complete the task; review the deliverable and status.
Troubleshooting
Expand the gateway indicator in the top toolbar for device health, agent routing issues, and tasks needing action. Each issue links to the task, agent, or settings page where it can be resolved. An online device can coexist with tasks waiting for an answer or plan approval; those task gates do not mean the gateway is broken.
If an agent selects an offline workspace-owner account while another account has an online gateway, open Choose operator for that agent and select the account paired to the online device in this workspace. Workspace admins with their own online gateway can use Use my online gateway directly in the panel. This changes one agent's operator; task approvals and pickup rules still apply. Other workspace members can inspect the guidance and ask an admin to change routing.
The queued count uses recorded dispatch state. An assigned task with no recorded dispatch is shown separately. Task and routing diagnostics are bounded samples; open the task board or full runtime map for older work and additional agents.
To see what local agents are doing, open another terminal:
pencil-gateway watch --account pencil
This shows recent and live updates with agent, task and run IDs, including safe tool milestones, brief agent-authored commentary, and run completion or failure. It also works while the gateway runs as a service. Use --task T-413 to filter one task, --lines 50 --no-follow for recent history, or --json for JSON Lines. Ctrl+C stops watching and leaves the service running. Commentary follows each agent's tool policy. A completed run does not itself approve or close a task.
The gateway must be updated and its service restarted to produce activity; older releases only have their existing service logs. Activity stays in user-only files under ~/.pencil/activity/, separated by profile, with about 4 MiB of bounded history. Watching does not contact Pencil or start another daemon.
| Symptom | What to check |
|---|---|
| No paired gateway | Run pencil-gateway status with the matching --account. |
| Settings shows no devices but the CLI says online | Check the signed-in Pencil user and selected workspace. Compare with pencil-gateway list; a local profile name does not prove which remote user or workspace is paired. Generate a code in the intended account/workspace and pair the intended profile, then restart its service. |
| Tasks or chats do not start | Check local-device routing in AI & Runtime, the running daemon, and pencil-gateway doctor --account pencil. |
| Expired Claude session | Sign in to Claude Code as the same OS user, restart the gateway, and select Resend in Pencil. |
| Device token returns 401 | Revoke the stale device in Pencil settings and pair again. |
| Service will not run | Check pencil-gateway service status; reinstall the service if Node or Claude moved. |
On macOS, inspect ~/.pencil/logs/gateway*.log. On Linux, use journalctl --user -u pencil-gateway.service for the default profile.
What to try next
Connect a client using Pencil MCP Server. The gateway's mcp command provides stdio access separately from the task daemon.