# Run2 Scheduler

> An improved scheduling algorithm to find the earliest compatible free slots under time constraints.

- Skill: `cxcscmu/run2-scheduler` (Agent Skill)
- Install (CLI): `npx get-skill add cxcscmu/run2-scheduler`
- Raw SKILL.md: https://api.skillmd.com/api/skills/cxcscmu/run2-scheduler/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: cxcscmu (https://skillmd.com/u/cxcscmu)
- Updated: 2026-11-24
- Page: https://skillmd.com/skills/cxcscmu/run2-scheduler

---


# Optimal Scheduling Algorithm

This skill dynamically assigns overlapping interval constraints by sweeping over available free slots, factoring in required meeting durations and available windows.

## Merging Intervals
```python
def merge_intervals(intervals):
    intervals.sort(key=lambda x: x[0])
    merged = []
    for interval in intervals:
        if not merged or merged[-1][1] <= interval[0]:
            merged.append(interval)
        else:
            merged[-1][1] = max(merged[-1][1], interval[1])
    return merged
```

## Earliest Fit Logic
Finds the earliest possible block large enough to fit the request that intersects both the user availability and your availability.

```python
def find_earliest_slot(available_times, req_start, req_end, duration):
    for avail_start, avail_end in available_times:
        start = max(avail_start, req_start)
        end = min(avail_end, req_end)
        
        if end - start >= duration:
            return start, start + duration
    return None, None
```

## Advanced Considerations
When multiple requests might conflict, the optimal approach involves sorting the requests (e.g., by end deadline or duration constraint), attempting to schedule them, and committing slots recursively to ensure all can be accommodated.

