---
name: scan-ralph
description: >
Scan agent-fork branches for unmerged implementations from ralph_code overnight runs.
Reports changed files and inferred spec IDs. Use with "/loop 5m /scan-ralph" to poll
continuously for new work.
allowed-tools: Read, Edit, Bash(git *), Bash(python3 *), Bash(scripts/scan-ralph-candidates *), Bash(grep *), Bash(date *)
---
# /scan-ralph
scan-ralph
You are reporting on unmerged implementations from overnight ralph_code agent runs.
## Pre-gathered context
### Scan timestamp
!`date +"%Y-%m-%d %H:%M"`
### Candidate branches (fetched from agent-fork now)
!`scripts/scan-ralph-candidates 2>&1`
### Recent main commits (last 5)
!`git log --oneline -5 main 2>/dev/null`
---
## Instructions
### Step 1: Check scan output
The "Candidate branches" block above contains either:
- Lines of the form `=== task- ===` followed by file paths and spec IDs
- Or the message "No unmerged candidate branches found..."
If the scan failed (e.g. "not in a git repository" or a Python traceback), report the error
and stop. The user should `cd` into the `agent-runtimes` repo first.
### Step 2: Report results
**No candidates:**
> No new implementations found. All recent agent-fork branches are already merged or empty.
**Candidates found** — present as a compact list:
```
Branch: task-
path/to/file.py → SPEC-ID, SPEC-ID
```
Then say: "**N branch(es) with unmerged implementations found.**"
### Step 3: Suggest next action
If candidates exist:
> To integrate, follow the workflow in `prompts/ralph_integration.md`.
> Start with the branch covering the highest-priority spec IDs.
>
> Quick recap:
> 1. `git checkout agent-fork/task-XXXX -- path/to/file.py`
> 2. Run the xfail test: `python -m pytest tests/test_foo.py::test_bar -v`
> 3. If XPASS(strict): remove the `@pytest.mark.xfail` decorator, commit
>
> Run `/scan-ralph` again after each integration to see the updated candidate list.
If no candidates:
> Run `scripts/scan-ralph-candidates --hours 168` to look back 7 days if you expect
> more results, or check `git fetch agent-fork` ran successfully.
---
## Loop usage
This skill is designed for:
```
/loop 5m /scan-ralph
```
Each firing re-fetches `agent-fork` and rescans, so new overnight branches appear
automatically without manual intervention.