Convert merged GitHub PRs into Harbor tasks automatically.
Automates task creation from real bug fixes in open-source GitHub repos. Works with any programming language: Claude Code analyzes the repo to detect language, build system, and test framework.
Each task reverses a merged PR to recreate the buggy state, verifies tests fail on baseline, and pass after applying the fix. Fully containerized with all dependencies installed at build time.
- [01/2026] π₯ SWE-gen-JS released: 1,000 JS/TS task dataset generated with SWE-gen
# Install
uv pip install swegen
# Generate a task from a merged PR
swegen create --repo axios/axios --pr 7150
# Or farm all PRs from a repo
swegen farm fastapi/fastapiuv pip install swegenEnsure these environment variables are set:
export GITHUB_TOKEN=<gh-token>
export OPENAI_API_KEY=<api-key>
export ANTHROPIC_API_KEY=<api-key> # or CLAUDE_CODE_OAUTH_TOKENNote: Cloud sandbox environments (Daytona, E2B, Modal, etc.) require additional API keys.
Commands:
swegen createβ Generate a task from a merged PRswegen farmβ Continuously process PRs from a repositoryswegen validateβ Validate existing task (NOP + Oracle)swegen analyzeβ Deep analysis with agent trials to verify task quality
swegen create --repo <owner/repo> --pr <num>Options
--output PATHβ Output directory for generated tasks (default:tasks)--state-dir PATHβ State directory for cache/logs (default:.swegen)--cc-timeout Nβ Claude Code session timeout in seconds (default: 3200)--env, -e TYPEβ Environment type:docker,daytona,e2b,modal,runloop,gke(default:docker)--no-validateβ Skip Harbor validations--forceβ Bypass local dedupe and regenerate--no-cacheβ Disable cached artifacts from previous tasks--no-require-minimum-difficultyβ Skip 3+ file and LLM substantiality checks--min-source-files Nβ Minimum number of source files required (default: 3, tests excluded)--max-source-files Nβ Maximum number of source files to avoid large refactors (default: 10, tests excluded)--no-require-issueβ Allow PRs without linked issues (uses PR body/title for instructions)-v, --verbose/-q, --quiet
Stream through entire PR history, process each sequentially with state persistence.
swegen farm fastapi/fastapi
swegen farm fastapi/fastapi --resume-from 2024-01-15Options
--output PATHβ Output directory for generated tasks (default:tasks)--state-dir PATHβ State directory for cache/logs (default:.swegen)--timeout Nβ Timeout per PR in seconds (default: 300)--cc-timeout Nβ Claude Code session timeout (default: 3200)--task-delay Nβ Delay between tasks in seconds (default: 60)--api-delay Nβ Delay between GitHub API calls in seconds (default: 0.5)--env, -e TYPEβ Environment type:docker,daytona,e2b,modal,runloop,gke(default:docker)--resume-from DATEβ Resume from date or timestamp--resetβ Reset state and start from beginning--dry-runβ Preview without generation--forceβ Regenerate even if task already exists (default: true)--no-validateβ Skip Harbor validation step--require-issue/--no-require-issueβ Require PRs to have linked issues (default: True)--no-require-minimum-difficultyβ Skip 3+ file and LLM checks--min-source-files Nβ Minimum number of source files required (default: 3, tests excluded)--max-source-files Nβ Maximum number of source files to avoid large refactors (default: 10, tests excluded)--no-cacheβ Disable cached artifacts--docker-prune-batch Nβ Run docker cleanup after every N PRs (default: 5, 0 to disable)--skip-list PATHβ Path to file with task IDs to skip (one per line)-v, --verbose
Verify that a task passes NOP (baseline fails) and Oracle (solution succeeds) agents:
swegen validate <task_id>Options
--task, -t IDβ Task ID when path points to dataset root--agent TYPEβboth,nop, ororacle(default:both)--jobs-dir PATHβ Directory to store Harbor job artifacts (default:.swegen/harbor-jobs)--env, -e TYPEβ Environment type:docker,daytona,e2b,modal,runloop,gke(default:docker)--timeout-multiplier Nβ Multiply default timeouts--max-parallel Nβ Max parallel validations (default: 8)--show-passedβ Show passed tasks in batch mode--output, -o PATHβ Write results to file as they complete (batch mode only)--docker-prune-batch Nβ Run docker cleanup after every N tasks (default: 5, 0 to disable)-v, --verbose/-q, --quiet
Run agent trials to verify a task is well-specified and solvable:
swegen analyze <task_id>
swegen analyze <task_id> -k 5 -a claude-codeWhat analyze does
- Static quality check (
harbor tasks check) - Baseline validation (nop fails, oracle passes)
- Run N agent trials
- Trial classification (identifies TASK vs AGENT problems)
- Task verdict synthesis with actionable recommendations
Classification categories:
GOOD_SUCCESSβ Agent solved it correctlyBAD_SUCCESSβ Agent cheated or tests too permissiveGOOD_FAILUREβ Agent failed due to its own limitationsBAD_FAILUREβ Agent failed due to task issues (underspecified, brittle tests, etc.)HARNESS_ERRORβ Infrastructure problem
Options
-a, --agent TYPEβ Agent to run trials (default:claude-code)-m, --model MODELβ Model for agent trials (default:anthropic/claude-sonnet-4-5)-k, --n-trials Nβ Number of trials (default: 3)-n, --n-concurrent Nβ Number of concurrent trials (default: 3, 1=sequential)--jobs-dir PATHβ Directory to store job artifacts (default:.swegen/analyze-jobs)--analysis-model MODELβ Model for Claude Code classification (default:claude-sonnet-4-5)--env, -e TYPEβ Environment type:docker,daytona,e2b,modal,runloop,gke(default:docker)--skip-quality-checkβ Skip static quality check--skip-baselineβ Skip baseline validation (nop/oracle)--skip-classifyβ Skip AI-powered classification--save-to-dirβ Write trajectory-analysis.{md,json} to each trial directory (for CI integration)--classification-timeout Nβ Timeout per trial classification in seconds (default: 300)--verdict-timeout Nβ Timeout for verdict synthesis in seconds (default: 180)--timeout-multiplier Nβ Multiply default timeouts-v, --verbose
Valid PR criteria
Languages: Any (Python, JavaScript, TypeScript, Go, Rust, Ruby, Java, etc.)
Valid PRs must:
- Be merged to primary branch with accessible fork
- Include test changes and corresponding fix
- Have a linked issue for high-quality instructions (bypass with
--no-require-issue) - Modify 3-10 source files (configurable with
--min-source-filesand--max-source-files, bypass with--no-require-minimum-difficulty) - Pass LLM substantiality evaluation (bypass with
--no-require-minimum-difficulty) - Fail tests on reversed baseline, pass after applying fix
- Exclude documentation-only, formatting-only, or version-bump-only changes
Pipeline details
The pipeline uses a language-agnostic approach:
- Fetch & Analyze β Get PR metadata via GitHub API, clone repo, identify test files
- Evaluate β LLM evaluates PR substantiality and generates task instructions
- Generate Skeleton β Create Dockerfile and test.sh with TODOs for Claude Code
- Claude Code Completion β CC analyzes repo, detects language/runtime/build system, fills in skeleton
- Validation β Run NOP (reward=0) and Oracle (reward=1) agents
- Iteration β CC iterates until both agents pass
Key Details:
- Dockerfile clones at HEAD, then applies
bug.patchto revert to buggy BASE state - Test files stored in
task/tests/and copied at runtime (prevents agent tampering) fix.patch(solution) excludes tests/CI, contains all other PR changes- Dependencies installed at build time; runtime doesn't require internet access
- Successful tasks are cached as references to speed up future tasks from the same repo
- PR evaluation uses LLM to check substantiality and generate instructions