Metadata-Version: 2.5
Name: repoflow-mcp
Version: 0.2.0
Summary: MCP server that helps you learn an open-source Python repo before you contribute: understand the code, follow its rules, run its tests safely, and learn from real bugs.
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27
Requires-Dist: mcp>=2.3
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.8; extra == 'dev'
Description-Content-Type: text/markdown

<!-- mcp-name: io.github.LolPanda2004/repoflow -->

<div align="center">

# RepoFlow Lite

**Learn an open-source Python codebase before you touch it.**

An [MCP](https://modelcontextprotocol.io) server that helps you understand a repo, follow its contribution rules, run its tests safely, and learn from real bugs.

[![CI](https://img.shields.io/github/actions/workflow/status/LolPanda2004/repoflow/ci.yml?branch=main)](https://github.com/LolPanda2004/repoflow/actions)
[![PyPI](https://img.shields.io/pypi/v/repoflow-mcp)](https://pypi.org/project/repoflow-mcp/)
[![Python](https://img.shields.io/badge/python-3.11%2B-blue)](#requirements)
[![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
[![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen)](CONTRIBUTING.md)

<img src="docs/assets/demo.gif" width="900" alt="Terminal demo: RepoFlow Lite maps more-itertools, ranks hotspots, reads its contribution playbook (AI policy: banned), runs 772 tests in Docker, and turns a pyflakes hit into a teaching card.">

<sub>Real run on <a href="https://github.com/more-itertools/more-itertools/tree/aa9977698a5e6ae15d3fdfac08a5fc5621c4e179">more-itertools/more-itertools @ aa99776</a>, output trimmed. Regenerate with <code>scripts/make_demo_gif.py</code>.</sub>

[Quickstart](#quickstart) · [Features](#features) · [How it works](#how-it-works) · [Contributing](#contributing) · [Roadmap](#roadmap)

</div>

---

## Why RepoFlow?

Maintainers are flooded with low-effort, AI-generated pull requests. New contributors often want to help, but don't know where to start or what the project expects.

RepoFlow Lite takes a **"learn first"** approach:

- **Understand** the code before changing it.
- **Respect** each project's rules (CONTRIBUTING, AI policy, CLA/DCO, CI).
- **Find real problems with evidence**: failing tests, static-analysis hits, flaky tests.
- **Teach**: every finding becomes a plain-language teaching card.

RepoFlow Lite does **not** open issues or pull requests for you. It helps you learn enough to make a good contribution yourself.

## Features

| Area | What you get | Tools |
|---|---|---|
| 🗺️ **Understand** | Repo map, architecture overview, hotspots (files that change often) | `analyze_repo`, `get_architecture`, `find_hotspots` |
| 📜 **Contribution policy** | The project's playbook: CONTRIBUTING, security policy, AI-use policy, CLA/DCO, CI, templates | `get_contribution_playbook`, `check_ai_policy`, `get_contribution_steps`, `check_pr_readiness` |
| 🧪 **Discover** | Set up the environment, run tests, run static analysis, detect flaky tests | `setup_environment`, `run_tests`, `run_static_analysis`, `detect_flaky_tests` |
| 📦 **Sandbox** | Tests run inside Docker, so a repo's code doesn't run directly on your machine | `sandbox_status` |
| 🎓 **Teach** | Record findings, turn them into teaching cards, export a report | `record_finding`, `update_finding`, `list_findings`, `get_finding`, `explain_finding`, `export_report` |

Plus three JSON resources: `repo://{owner}/{name}/map` (repo map), `playbook://{owner}/{name}` (contribution playbook) and `findings://{owner}/{name}` (recorded findings).

## Quickstart

### Requirements

- Python **3.11+**
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) (recommended, for sandboxed test runs)
- An MCP client, for example [Claude Code](https://claude.com/claude-code)

### Install

```bash
git clone https://github.com/LolPanda2004/repoflow.git
cd repoflow
pip install -e ".[dev]"
```

### Register with Claude Code

```bash
claude mcp add repoflow -- repoflow
```

Then open Claude Code and run `/mcp` to check that `repoflow` is connected.

### Register with other MCP clients

For clients that support the `mcpServers` format, add this entry to their MCP configuration:

```json
{
  "mcpServers": {
    "repoflow": {
      "command": "repoflow",
      "args": [],
      "env": {
        "REPOFLOW_SANDBOX": "docker"
      }
    }
  }
}
```

On Windows, replace `repoflow` with the absolute path to `repoflow.exe` (use `\\` to escape backslashes in JSON). Find it with `(Get-Command repoflow).Source`.

`REPOFLOW_SANDBOX` is optional: `docker` (default) enables Docker sandboxing, `local` runs without Docker isolation, and `off` disables repository code execution.

### Try it

Start with a small Python repo:

```text
> Use repoflow to analyze owner/small-repo and explain its architecture.
> What does this project expect from contributors? Check its AI policy.
> Run its tests in the sandbox and explain any failure as a teaching card.
```

## How it works

```text
           ┌──────────────┐
  you ───▶ │  MCP client  │  (e.g. Claude Code)
           └──────┬───────┘
                  │ stdio
           ┌──────▼───────┐
           │   RepoFlow   │
           └──────┬───────┘
   ┌──────────┬───┴──────┬──────────┬─────────┐
   ▼          ▼          ▼          ▼         ▼
understand  policy   discover   sandbox    teach
 (map,     (rules,   (tests,    (Docker)  (cards,
 hotspots)  AI use)  static)              report)
```

Project layout (`src/repoflow/`):

| Module | Job |
|---|---|
| `core/` | Config, GitHub client (read-only), models, process runner, local store, workspace |
| `understand/` | Repo map, hotspots, architecture |
| `policy/` | Contribution playbook, AI policy, readiness checks |
| `discover/` | Environment setup, tests, static analysis, flaky tests |
| `sandbox/` | Docker runner |
| `teach/` | Findings, teaching cards, reports, prompts |
| `server.py` | MCP server entry point; registers each module's tools |

### Design principles

1. **Teach, don't submit.** The goal is a better contributor, not more PRs.
2. **Evidence over guesses.** A finding needs a failing test, a tool result, or a reproducible run.
3. **Respect the project.** Its rules come first, including any rules about AI.
4. **Safe by default.** Repo code runs in Docker. GitHub access is read-only.

## Guards (optional)

RepoFlow Lite never writes to GitHub. Your AI assistant might still try to, through its shell. `repoflow guards` adds Claude Code deny rules for direct GitHub writes (`gh pr create`, `gh api`, `git push` and similar), so those need a human.

```bash
repoflow guards install            # adds the rules to ~/.claude/settings.json
repoflow guards install --project  # or to ./.claude/settings.json
repoflow guards status             # shows which rules are present
repoflow guards remove             # takes them out again
```

`install` shows a diff and asks before writing (`--yes` skips the prompt). It keeps your other settings, backs up the old file, and refuses to touch a file that is not valid JSON.

## Development

```bash
pip install -e ".[dev]"
python -m pytest -q          # full suite; some tests need Docker running
python -m pytest -q tests/test_policy.py   # run one file
ruff check . && ruff format .            # lint and format
```

Import check:

```bash
python -c "import sys; sys.path.insert(0, 'src'); import repoflow.server"
```

## Contributing

Contributions are welcome, from typo fixes to new tools.

1. Read [CONTRIBUTING.md](CONTRIBUTING.md).
2. Look for issues labeled [`good first issue`](https://github.com/LolPanda2004/repoflow/labels/good%20first%20issue) or [`help wanted`](https://github.com/LolPanda2004/repoflow/labels/help%20wanted).
3. Comment on the issue before you start, so work isn't duplicated.
4. Keep PRs small, add tests, and make sure `python -m pytest -q` passes.
5. If you used AI tools, say so in the PR description.

Questions and ideas go in [GitHub Discussions](https://github.com/LolPanda2004/repoflow/discussions).

### Contributors

Thank you to everyone who has helped make RepoFlow better! Everyone with a merged PR shows up below. It updates by itself after every merge.

<a href="https://github.com/LolPanda2004/repoflow/graphs/contributors">
  <img src="https://raw.githubusercontent.com/LolPanda2004/repoflow/contributors/contributors.svg" alt="RepoFlow contributors" />
</a>

### Code of Conduct

This project follows the [Contributor Covenant](https://www.contributor-covenant.org/). See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).

### Security

Please don't report security problems in public issues. See [SECURITY.md](SECURITY.md).

## Roadmap

- [x] Repo understanding: map, hotspots, architecture
- [x] Contribution playbook and AI-policy checks
- [x] Tests, static analysis and flaky-test detection in Docker
- [x] Teaching cards and reports
- [ ] One "environment ready" check shared by all modules
- [ ] Better isolation for local (non-Docker) mode
- [ ] More teaching-card templates and beginner-friendly wording
- [ ] Support for more project layouts (monorepos, tox/nox-based setups)

Have an idea? [Open a discussion](https://github.com/LolPanda2004/repoflow/discussions).

## License

[MIT](LICENSE)

A separate hosted, paid version of RepoFlow also exists.

---

<div align="center">
Built for people who want to contribute well, and for the projects that receive it.
</div>
