Headless Agent Execution Pipelines That Deliver Pull Requests From Cursor and Claude Code Without Human Babysitting
How Claude Code and Cursor ship unattended PRs through triggers, sandboxes, and review.

To run Claude Code in the cloud without managing infrastructure, use cloud sessions on Anthropic-managed infrastructure if the plan’s access rules and compliance restrictions allow it. For Claude Code and Cursor alike, reliable headless execution requires more than a remote agent. It requires a pipeline that connects triggers, isolated execution, structured results, and pull request delivery so that task submission no longer depends on a developer watching the terminal.
Why headless agent execution is an architectural shift, not a workflow tweak
An AI assistant you talk to and an agent you dispatch have different contracts. The first depends on a person approving steps in a synchronous session. The second accepts a task and returns a pull request later. The change is self-supervision, as agents respond to events, keep a goal across long-running sessions, and move ahead without a person stepping in at each loop.
That independence concentrates risks previously spread across a developer’s attention. Permission decisions must be encoded before execution because an action otherwise runs automatically or stalls. Cost requires explicit bounds because an unattended loop, multiplied across parallel jobs, can spend money without anyone noticing. Audit records must be captured deliberately because no observer remains to reconstruct what happened.
The four components every headless pipeline must wire together
A headless pipeline runs from trigger to sandboxed execution to structured output to pull request delivery. Each stage requires a choice about responsibility. The trigger determines which events justify a run, whether a Git push, PR comment, Slack message, Linear assignment, schedule, or PagerDuty alert.
Execution determines where the agent works and what it can reach. A cloud VM or fresh container provides isolation, while the cloned repository, network controls, and credential boundaries define the working environment. Structured output then determines what the surrounding pipeline can understand without a person interpreting terminal prose. The final stage turns that result into a branch, diff, and description that a reviewer can evaluate.
How Claude Code's three entry points map onto a headless pipeline
Claude Code offers three entry points for unattended execution, each suited to a different orchestration layer. The headless CLI, claude -p, reads a prompt, runs to completion, prints a result, and exits. It fits shell scripts and CI steps where other commands assemble the task, such as a build error log piped into the agent. The process boundary is simple and explicit.
For machine-readable results, --output-format json returns result text, a session ID, and metadata including total_cost_usd, is_error, duration_ms, and num_turns. Sessions persist per project, so --continue resumes the most recent session, while --resume <session-id> selects a specific one. Execution controls include --max-turns, --allowedTools, --disallowedTools, and --permission-mode acceptEdits. These settings control how much the process can do on its own.
The Agent SDK embeds the same engine in TypeScript or Python when orchestration needs branching, error handling, and state management. By contrast, the official GitHub Action, anthropics/claude-code-action@v1, handles the comment, commit, and PR plumbing for issues and pull requests initiated through @claude mentions or a fixed prompt. That convenience has a defined scope. The Action covers GitHub-triggered work, while shell pipelines, scheduled jobs, and non-GitHub hosts require the CLI or SDK.
How to run Claude Code in the cloud instead of on a laptop
Claude Code Docs describe cloud sessions as execution on Anthropic-managed infrastructure, or a self-hosted environment when routed there. With the managed path, a developer can let the laptop sleep and watch or steer the work from another device, including mobile. Scheduled and triggered tasks each run as cloud sessions, making automation part of the execution model.
The credential boundary changes with that move. GitHub credentials remain encrypted on Anthropic’s servers and never enter the session VM. GitHub operations pass through a proxy that attaches the credential server-side. This separates repository authentication from the environment in which the agent changes files.
Cloud sessions draw on the plan’s usage limits alongside other Claude usage, with no separate charge for the cloud VM. Access includes Pro, Max, Ultra, and Team plans, plus Enterprise users with premium seats or Chat + Claude Code seats. Custom roles need the role-based permission that allows access.
The claude-dev-env repository provides a concrete example of headless execution inside a cloud session. An October 2026 merged PR lets the broker gate pass a direct claude -p invocation when CLAUDE_CODE_REMOTE=true, because the session already has exactly one account. The test that comes with it checks the cloud-session bypass, while machines outside cloud sessions still use the gate.
Cursor's headless architecture: subscriptions, automations, and the coordinator agent
Cursor’s architecture emphasizes finishing dispatched work, including following a pull request through CI and addressing feedback. Cursor Automations, launched March 5, 2026, provide scheduled runs and event-driven starts from sources including Slack messages, newly created Linear issues, merged GitHub PRs, and PagerDuty incidents. The trigger is only the beginning of the lifecycle. Subscriptions extend orchestration beyond the initial request so that later events can keep work moving without a person reopening the conversation.
Cursor Projects, introduced in September 2026, extends that model to a feature, migration, or full application with context maintained over months. Its coordinator agent runs on its own cloud computer and can watch a Slack channel, follow a schedule, or track PRs through subscriptions. The coordinator does not write code itself. Its role is orchestration, separating oversight of the goal from implementation work.
Review is also divided into distinct functions. Bugbot reviews PRs for bugs and code quality problems, while the separate Security Review bot, launched September 23, 2026, handles security issues. Security Agents look for security bugs and risky patterns. PR Routing & Approval assigns reviewers using code ownership and commit history and can approve low-risk PRs when configured criteria are met. Automated approval therefore remains conditional when an agent is allowed to open a PR.
OpenCode's headless server and why model-agnostic routing matters for multi-agent pipelines
OpenCode meets a different need by routing agents to different model providers while keeping the pipeline around them in place. Its October 12, 2026 version 2.0 rebuild made it a background service that terminal, web, and desktop clients can connect to simultaneously. An OpenAPI surface and TypeScript SDK provide programmatic control. The service, rather than an individual terminal session, becomes the integration point.
Built-in MCP support handles local and remote connections, and each agent can be set to use a different model for jobs such as lint fixes and test fixes. That breadth is useful when one CI pipeline must support several providers. It does not settle the hosting decision. OpenCode, Claude Code, and Cursor are execution harnesses, while the environment hosting them is a separate layer responsible for isolation and operational visibility.
Connecting triggers to agents: Slack, Linear, GitHub, GitLab, and Sentry as pipeline entry points
Ramp’s Inspect demonstrates what a trigger-to-PR workflow looks like when it uses existing engineering context. Built on Linear’s API, it traces a customer complaint through a product specification to the relevant code, writes a fix, tests it against Ramp’s actual feature flags and telemetry, and opens a pull request. Ramp reports that Inspect writes a majority of the pull requests it merges.
Coinbase’s Forge, built on Linear’s Agent SDK, operates across Slack, GitHub, and Linear using context already present in those systems. Coinbase describes Linear as “the place where agents go to get their bearings before starting a task.” By using Claude Code and OpenCode internally, Linear saw a clear rise in PRs per author and issues per author from January to February 2026. A majority of its agent-generated PRs were mergeable.
With Linear’s June 11, 2026 coding capabilities, sessions with Claude Code and Codex can start through issue assignment, chat comments, or Slack threads. For bug triage, Linear Agent can gather evidence from Sentry or Datadog through MCP, trace the root cause in the codebase, and attempt a fix before an engineer receives the issue. Existing context becomes part of the task input. This reduces the gap between reporting a problem and dispatching work on it.
Cursor Automations support GitHub, GitLab, Bitbucket Cloud, Slack, webhooks, Linear, Sentry, and PagerDuty as event sources. For Bitbucket workflows, Atlassian’s April 8, 2026 announcement added Bitbucket Cloud support to the Rovo MCP server, including tools to create, inspect, merge, approve, and comment on pull requests. The integration choice depends on where work originates and where review happens. A pipeline need not make GitHub its entry point simply because one agent offers a convenient GitHub Action.
The permission, security, and compliance constraints that govern what a headless agent can touch
For unattended execution, the recommended default is the narrowest --allowedTools list that lets the task finish, combined with --max-turns and structured output parsing. --disallowedTools provides explicit exclusions, while --permission-mode acceptEdits approves file edits without automatically approving other actions. Edit permission is not unrestricted execution permission. --dangerously-skip-permissions belongs only in throwaway sandboxes with no real credentials.
Repository access also requires a deliberate choice. GitHub App authentication and gh CLI tokens have different repository reach, so the authentication method helps define what the agent can touch. Self-hosted GitHub Enterprise Server instances are supported on Team and Enterprise plans. Support for these repository hosts has separate rules from access to managed cloud sessions.
Claude Code cloud sessions are unavailable to organizations with Zero Data Retention enabled, the HIPAA configuration applied, or customer-managed encryption keys. These platform constraints apply regardless of how permissive an agent command is. Cursor’s HIPAA/BAA limitation likewise belongs in the architecture decision. Teams with those requirements have ways to self-host, so where they run the agent is a matter of compliance as well as their choice of infrastructure.
Auditability requires a separate capture policy for structured JSON, session IDs, diffs, and telemetry. The session ID links later work to an earlier run, and cost and turn metadata let teams check how the run went. Reviewable code is only part of that record. An incident review cannot draw on what happened in a terminal if nobody watched it and the pipeline never saved it.
What separates teams running agents occasionally from teams running them reliably at scale
The pipeline must give triggers a clear role, keep execution sandboxed and observable, make results structured and reviewable, and keep environments consistent from one run to the next. A capable agent cannot compensate for an execution contract that leaves permissions, termination, or delivery unresolved.
The lesson for task design is to make each dispatch independently completable. Adding unit tests for one module, fixing a bug in another, and updating documentation can run in parallel when the tasks do not depend on one another. A headless task must supply everything the agent needs through its prompt, readable files, or permitted tools. An instruction that ends with “let me know if you want me to also update the tests” still assumes an interactive exchange.
Teams can review the proposed change, inspect its execution record, and decide whether it should merge without supervising every intermediate action. Human judgment remains at the review boundary. The unit of measurement is pull requests shipped and merged.


