pw code
pw code
AI coding agent
Synopsis
Start an AI coding agent that can read, write, and edit files in your workspace. The agent uses tool-calling to execute tasks autonomously.
If no model is specified, you'll be prompted to choose one. Run 'pw ai models ls' to list the model IDs available to you.
Sessions are hosted by a per-user background daemon this command starts automatically; the terminal is a client of it, so exiting detaches and a running turn finishes in the background. Stop the daemon with pw code daemon stop. Attach to another machine's sessions with pw code attach.
Sessions are saved under ~/.local/state/pw/code-sessions and can be resumed with --resume. Browse every session on this machine with pw agents. Settings such as trusted workspaces live in ~/.config/pw/code.json. Manage MCP servers with pw code mcp.
With -p the agent runs one prompt and exits, auto-denying anything that needs approval. The daemon keeps running afterwards; scripts and CI jobs can stop it with pw code daemon stop.
pw code [flags] [model]Examples
pw code
# Start with a specific model (see 'pw ai models ls')
pw code Jake.Thayne:openai/gpt-5.2
# One-shot prompt
pw code -p "find all TODO comments" Jake.Thayne:openai/gpt-5.2
# JSON output for automation
pw code -p "list Go files" -o json Jake.Thayne:openai/gpt-5.2
# Resume the most recent session on its own model
pw code -r latest
# Pick a session to resume from a list
pw code --resume
# Read-only mode
pw code --permission-mode read-only Jake.Thayne:openai/gpt-5.2
# Use an org provider with a budget allocation
pw code --allocation PW-QA-TEST org:openai/gpt-5.2
# Think harder on every turn
pw code --effort high Jake.Thayne:openai/gpt-5.2
# Let the agent edit a directory outside the workspace
pw code --add-dir /data/shared Jake.Thayne:openai/gpt-5.2
# Run a custom agent as the main session
pw code --agent reviewer
# Pair with a notebook in your platform workspace and run code in its kernel
pw code --notebook workspace:analysis/eda.ipynb --kernel my-kernel
# Make this session viewable and drivable from the web app
pw code --remoteOptions
--add-dir strings Directories outside the workspace the agent may read, search, and edit without prompting (repeatable)
--agent string Run a custom agent definition as the main session (a name from .agents/agents, ~/.config/agents/agents, or --agents)
--agents string Ad-hoc agent definitions as JSON keyed by name, merged over the definition files, e.g. '{"reviewer":{"description":"Reviews diffs","prompt":"...","tools":["ReadFile","GrepSearch"]}}'
--allocation string Budget allocation name (required for org provider models)
--allowedTools strings Tools pre-approved without prompting, e.g. ReadFile, 'Bash(git status *)', or 'ReadFile(/data/**)' to allow reads outside the workspace (repeatable; quote rules that contain commas)
--dangerously-skip-permissions Start in bypass-permissions mode and keep it in the shift+tab cycle; every tool call runs without asking
--effort string Reasoning effort: default, none, minimal, low, medium, high, xhigh, or max (support varies by model)
-h, --help help for code
--kernel string The platform kernel the paired notebook runs on: the agent can run code in it (needs --notebook)
-m, --model string Model ID, e.g. Jake.Thayne:openai/gpt-5.2 or org:openai/gpt-5.2 (run 'pw ai models ls' to list)
--no-tools Disable tool calling (chat-only mode)
--notebook string Pair with this notebook (.ipynb), a local path or workspace:<path in your workspace> from any machine: the agent can read and edit its cells
-o, --output string Output format for -p runs: text (the answer on stdout, progress on stderr) or json (one result object) (default "text")
--permission-mode string Permission mode: read-only, accept-edits, auto, bypass-permissions, plan (default: the saved mode, else accept-edits)
-p, --prompt string Run one prompt non-interactively and exit; approvals are auto-denied, and the saved model and allocation apply when none is given
--remote Let this session be viewed and driven from the web app's Agents page (the same as /rc); --remote=false overrides the remoteControl.newSessions setting
-r, --resume string[="pick"] Resume a session on this machine: pass a session ID or 'latest', or use --resume alone to pick from a list. The session keeps its model unless one is given
-w, --workspace string Workspace root directory (default: current directory)Options inherited from parent commands
--context string The context to use. Overrides PW_CONTEXT environment variable and current context from config.
--platform-host string The Parallel Works ACTIVATE platform host to use. Overrides PW_PLATFORM_HOST environment variable and the current context's server.
-v, --verbose Enable verbose loggingSEE ALSO
- pw - The Parallel Works ACTIVATE CLI
- pw code attach - Attach the TUI to pw code sessions on a remote resource
- pw code daemon - Manage the pw code app-server daemon
- pw code mcp - Manage MCP servers for pw code