Skip to main content
Run coding tasks from your terminal. Claude Code writes the code, creates the PR.
npx pr-agent run --repo owner/repo --task "add unit tests"

What It Does

  1. Spins up isolated sandbox
  2. Clones your repo
  3. Runs Claude Code on your task
  4. Commits changes
  5. Opens PR on GitHub
You get real-time streaming of what Claude is doing.

Installation

# Run directly (no install)
npx pr-agent run --repo owner/repo --task "your task"

# Or install globally
npm install -g pr-agent

Commands

run - Execute a task

pr-agent run --repo owner/repo --task "add unit tests for auth"
FlagRequiredDescription
--repoYesRepository (owner/repo)
--taskYesTask description
--branchNoBase branch (default: main)
--skillNoUse a built-in skill
Example tasks:
# Add tests
pr-agent run --repo acme/api --task "add Jest tests for UserService"

# Fix CI
pr-agent run --repo acme/app --task "fix TypeScript errors"

# Refactor
pr-agent run --repo acme/lib --task "convert callbacks to async/await"

# Documentation
pr-agent run --repo acme/sdk --task "add JSDoc to public APIs"

watch - Watch or replay jobs

Watch a running job in real-time, or replay a completed job.
# Watch a running job
pr-agent watch <jobId>

# Replay at 4x speed
pr-agent watch <jobId> --speed 4
Durable sessions: If your connection drops, reconnect and continue from where you left off. All events are persisted.

replay - Fast replay

Alias for watch --speed 4. Replay completed jobs quickly.
pr-agent replay <jobId>

jobs - List recent jobs

pr-agent jobs
pr-agent jobs --status running

snapshot - Code structure overview

Generate an AI-friendly code structure with refs.
pr-agent snapshot
pr-agent snapshot src/
pr-agent snapshot --interactive  # Only functions & classes
pr-agent snapshot --json
Output:
Code Snapshot
──────────────────────────────────────────────────────
Repo: owner/repo (main)
Stats: 12 functions, 3 classes, 8 modules
──────────────────────────────────────────────────────

├── src/
│   ├── index.ts [@m1] (2 items)
│   │   ├── fn main() [@f1]
│   │   └── fn init() [@f2]
│   ├── services/
│   │   └── auth.ts [@m2] (3 items)
│   │       ├── class AuthService [@c1]
│   │       ├── fn login() [@f3]
│   │       └── fn logout() [@f4]
Ref types:
  • @f1, @f2 - Functions
  • @c1, @c2 - Classes
  • @m1, @m2 - Modules/Files
  • @t1, @t2 - Types/Interfaces

show - View code ref

Display details for a specific ref.
pr-agent show @f1
pr-agent show @c1 --context 30

auth - GitHub authentication

pr-agent auth    # Start auth flow
pr-agent logout  # Clear auth
pr-agent status  # Check auth status
Required for private repos.

Skills

Built-in skills optimize Claude for specific tasks:
pr-agent run --repo owner/repo --skill test-writer --task "focus on auth"
pr-agent run --repo owner/repo --skill linter
SkillWhat it does
test-writerAdds comprehensive test coverage
code-reviewerReviews and improves code quality
type-fixerFixes TypeScript errors
linterFixes ESLint/Prettier issues
security-scannerAudits for vulnerabilities
docs-generatorAdds JSDoc comments

How It Works

┌─────────────────┐      ┌─────────────────┐      ┌─────────────────┐
│   CLI (npm)     │─────▶│  Invariant API  │─────▶│   E2B Sandbox   │
│  pr-agent run   │ HTTP │ /api/pr-agent/* │      │  Claude Code    │
└─────────────────┘  SSE └─────────────────┘      └────────┬────────┘


                                                    ┌──────────────┐
                                                    │   GitHub     │
                                                    │   PR API     │
                                                    └──────────────┘
  1. CLI sends request to Invariant API
  2. API creates isolated E2B sandbox
  3. Claude Code runs in sandbox, streams progress via SSE
  4. CLI displays real-time logs
  5. Result shows PR URL, cost, duration

Streaming Output

Watch Claude work in real-time:
pr-agent v1.1.0

Creating sandbox...
Cloning acme/api...
Running Claude Code...

──────────────────────────────────────────────────────
  14:32:51 Read package.json
  14:32:52 Read src/auth/index.ts
  14:32:53 Write src/auth/auth.test.ts
  14:32:56 Bash npm test
  14:33:02 Bash git commit -m "Add auth tests"
──────────────────────────────────────────────────────

✓ PR Created Successfully
  https://github.com/acme/api/pull/42

  2 files · +89 lines · $0.24 · 38s

Rate Limits

User TypeDaily Limit
Anonymous3 jobs
Authenticated10 jobs
PaidUnlimited
Typical cost: $0.20-0.50 per job (sandbox + Claude tokens).

Tips for Better Results

“Add input validation to /api/users POST endpoint” works better than “add validation”
“Update src/auth/login.ts to use bcrypt” helps Claude find the right code
“Use existing patterns, don’t add new dependencies” keeps changes focused
Split “refactor the entire codebase” into smaller, focused tasks

GitHub

View on GitHub

Star, fork, contribute