Skip to content

Repository-to-RLEnv

Repository-to-RLEnv converts real Python repositories into executable RL environments for code agents.

Core trick

Injects a small bug into a staged copy of a Python repo, then uses the real test suite's pass/fail as reward for a code agent's fix attempts.

Tags

Description

Repository-to-RLEnv converts real Python repositories into executable RL environments for code agents. With one Claude Code MCP command, it inspects a repo, finds a clean test scope, creates a staged copy, injects a small source-code bug, verifies the failing tests, generates task metadata, validates the environment, and deploys it to Hugging Face Spaces as a live OpenEnv environment. The result is a repo-level RL environment where an agent can read files, edit code, run tests, and submit fixes while receiving rewards from the real test suite. I also built a web UI for running episodes on deployed Spaces. The problem this solves is improving the quality of AI coding assistants for YOUR own codebase.
tema7707/Repository-to-RLenv★ 00 forksJupyter NotebookCreated Mar 8, 2026 · last push Mar 8, 2026

README excerpt

# Repository-to-RLenv

Repository-to-RLenv turns a Python repo into a live RL coding environment.

![Repository-to-RLenv UI](media/header.png)

## Install

```bash
pip install -e .
```

If you use Claude Code, register the MCP server:

```bash
claude mcp add --scope user repo2env -- .venv/bin/repo2env-mcp
```

## Use

Open the target repo in Claude Code and run:

```text
/mcp__repo2env__convert_to_rl_env
```

**One command kicks off the full conversion workflow.**

<details>
<summary>Inference</summary>
You can also run Repo2Env locally:

```bash
repo2env-openenv-server --port 8000
```

Smoke test a local or HF-hosted env:

```bash
repo2env-smoke-test --base-url http://127.0.0.1:8000
```

Run inference against an env:
```
repo2env-infer \
  --base-url https://tema7707-repo2env-toolz.hf.space \
  --model gpt-4o-mini \
  --model gpt-5 \
  --temperature 1 \
  --output toolz_infer_debug.json
```
</details>

## How It Works

Current one-command MCP workflow:

```text
start Claude Code
  ->
run /mcp__repo2env__convert_to_rl_env
  ->
AUTOMATIC: inspect repo structure and tests
  ->
AUTOMATIC: copy repo to /tmp/repo2env-<repo>-bug-<variant>-staged
  ->
AUTOMATIC: Claude introduces one small source-code bug in the staged copy
  ->
AUTOMATIC: rerun scoped tests to confirm the bug actually fails
  ->
AUTOMATIC: write task_spec.json on the staged copy
  ->
AUTOMATIC: Repo2Env analyze_repo on staged copy
  ->
AUTOMATIC: Repo2Env convert_repo on staged copy
  ->
AUTOMATIC: openenv validate

Team