asgard-ai-platform/algo-hr-matching
Implement Gale-Shapley stable matching algorithm for two-sided matching problems. Use this skill when the user needs to match candidates to positions, assign students to schools, or solve any two-sided preference matching — even if they say 'optimal job matching', 'stable assignment', or 'candidate-position pairing'.
npx skills add https://github.com/asgard-ai-platform/skills --skill algo-hr-matching
Gale-Shapley (deferred acceptance) finds a stable matching between two equally-sized sets where no unmatched pair prefers each other over their current match. Runs in O(n²) worst case. Proposer-optimal: the proposing side gets their best stable partner.
Trigger conditions:
When NOT to use:
IRON LAW: The Proposing Side Gets Their BEST Stable Partner
Gale-Shapley is proposer-optimal and reviewer-pessimal. If employers
propose, they get their best stable match; candidates get their worst.
The CHOICE of who proposes determines which stable matching is found.
Collect: preference rankings from both sides. Each participant ranks all members of the other side.
Gate: Complete preference lists, equal-sized groups (or handle unequal with dummy entries).
Check stability: for every unmatched pair (a,b), verify that at least one of them prefers their current match over the other. No blocking pairs = stable.
Gate: Zero blocking pairs found.
Return matching with stability confirmation.
{
"matching": [{"proposer": "Candidate_A", "reviewer": "Company_X", "proposer_rank": 1, "reviewer_rank": 2}],
"metadata": {"pairs": 10, "rounds": 23, "blocking_pairs": 0, "proposer_side": "candidates"}
}
Input: 3 candidates, 3 companies, each with full preference rankings
Expected: Stable matching with zero blocking pairs. Candidate-proposing gives candidate-optimal result.
| Input | Expected | Why |
|-------|----------|-----|
| All prefer same #1 | Still terminates, stable | Rejected proposers move to next choice |
| Identical preferences | Unique stable matching | Only one possibility |
| Unequal sides | Some unmatched on larger side | Add dummy entries or use many-to-one variant |
references/many-to-one.mdreferences/strategic-manipulation.mdTake asgard-ai-platform/algo-hr-matching from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.