asgard-ai-platform/algo-rec-cf
Implement collaborative filtering for recommendations based on user behavior patterns. Use this skill when the user needs to build a recommendation engine from user-item interaction data, find similar users or items, or predict ratings — even if they say 'users who bought this also bought', 'similar users', or 'recommend based on behavior'.
npx skills add https://github.com/asgard-ai-platform/skills --skill algo-rec-cf
Collaborative filtering recommends items based on collective user behavior patterns. User-based CF finds similar users; item-based CF finds similar items. Computes in O(U² × I) for user-based or O(I² × U) for item-based where U=users, I=items.
Trigger conditions:
When NOT to use:
IRON LAW: CF Requires SUFFICIENT Interaction Data
With sparse matrices (< 1% fill rate), similarity computation is
unreliable. Minimum viable: each user has rated 5+ items, each item
has 5+ ratings. Below this, fallback to content-based or popularity.
Load user-item interaction matrix. Check sparsity level and filter users/items below minimum interaction threshold.
Gate: Matrix sparsity < 99%, minimum interaction thresholds met.
User-based CF:
Item-based CF:
Hold out 20% of interactions for testing. Compute RMSE, MAE, or precision@K / recall@K.
Gate: RMSE below baseline (global mean predictor).
Return top-N recommendations with predicted scores.
{
"recommendations": [{"item_id": "123", "predicted_score": 4.2, "similar_items_used": 5}],
"metadata": {"method": "item-based", "similarity": "cosine", "k_neighbors": 20, "sparsity": 0.97}
}
Input: 5 users × 5 items rating matrix, target: user1, item5
Expected: Predicted rating based on weighted similarity of user1's rated items similar to item5
| Input | Expected | Why |
|-------|----------|-----|
| New user, no ratings | Cannot recommend | Cold start — fallback to popularity |
| Item rated by all users | Low differentiation | High popularity ≠ personalized match |
| Single shared item | Unreliable similarity | Need multiple co-ratings for stable similarity |
references/matrix-factorization.mdreferences/implicit-feedback.mdTake asgard-ai-platform/algo-rec-cf 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.