Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add aj-geddes/useful-ai-prompts --skill recommendation-systemgit clone --depth 1 https://github.com/aj-geddes/useful-ai-promptsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/aj-geddes/useful-ai-prompts/recommendation-system)<a href="https://agentmods.dev/skills/aj-geddes/useful-ai-prompts/recommendation-system"><img src="https://agentmods.dev/badge/skills/aj-geddes/useful-ai-prompts/recommendation-system/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/aj-geddes/useful-ai-prompts/recommendation-system"><img src="https://agentmods.dev/badge/skills/aj-geddes/useful-ai-prompts/recommendation-system.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- Socket pass
- Snyk pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00020 | $0.02761 |
| Opus 5 | $0.00010 | $0.01380 |
| Sonnet 5 | $0.00004 | $0.00552 |
| Haiku 4.5 | $0.00002 | $0.00276 |
Grade A, and why
Recommendation System scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 297 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Recommendation System
Overview
This skill implements collaborative and content-based recommendation systems with matrix factorization techniques to predict user preferences, increase engagement, and drive conversions through personalized item suggestions.
When to Use
- Developing recommendation features to improve user engagement and retention
- Implementing personalized product suggestions to increase sales and conversion rates
- Building hybrid recommendation systems that combine collaborative and content-based approaches
- Analyzing and optimizing recommendation coverage, diversity, and accuracy
- Handling sparse user-item interaction matrices and cold start scenarios
- Running A/B tests to measure the impact of recommendation algorithms on business metrics
Approaches
- Collaborative Filtering: Users similar to you liked X
- Content-based: Items similar to what you liked
- Hybrid: Combining multiple approaches
- Matrix Factorization: Latent factor models
- Deep Learning: Neural networks for embeddings
Key Metrics
- Precision@K: % recommendations relevant
- Recall@K: % relevant items found
- NDCG: Ranking quality metric
- Coverage: % items recommended
- Diversity: Variety in recommendations
Implementation with Python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.metrics.pairwise import cosine_similarity
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.decomposition import NMF
import seaborn as sns
# Create sample user-item interaction data
np.random.seed(42)
users = [f'user_{i}' for i in range(100)]
items = [f'item_{i}' for i in range(50)]
# Generate ratings (sparse matrix)
ratings_list = []
for user in users:
n_items_rated = np.random.randint(5, 20)
rated_items = np.random.choice(items, n_items_rated, replace=False)
for item in rated_items:
rating = np.random.randint(1, 6)
ratings_list.append({'user': user, 'item': item, 'rating': rating})
ratings_df = pd.DataFrame(ratings_list)
print("Sample Ratings:")
print(ratings_df.head(10))
# Create user-item matrix
user_item_matrix = ratings_df.pivot_table(
index='user', columns='item', values='rating', fill_value=0
)
print(f"\nUser-Item Matrix Shape: {user_item_matrix.shape}")
print(f"Sparsity: {1 - (user_item_matrix != 0).sum().sum() / (user_item_matrix.shape[0] * user_item_matrix.shape[1]):.2%}")
# 1. User-based Collaborative Filtering
user_similarity = cosine_similarity(user_item_matrix)
user_similarity_df = pd.DataFrame(
user_similarity, index=user_item_matrix.index, columns=user_item_matrix.index
)
print("\n1. User Similarity Matrix (Sample):")
print(user_similarity_df.iloc[:5, :5])
# Get recommendations for a user
def get_user_based_recommendations(user_id, user_sim_matrix, user_item_mat, n=5):
similar_users = user_sim_matrix[user_id].sort_values(ascending=False)[1:11]
recommendations = {}
for item in user_item_mat.columns:
if user_item_mat.loc[user_id, item] == 0: # Not yet rated
score = (similar_users * user_item_mat.loc[similar_users.index, item]).sum()
recommendations[item] = score
top_recs = sorted(recommendations.items(), key=lambda x: x[1], reverse=True)[:n]
return [rec[0] for rec in top_recs]
# Example: Get recommendations for user_0
user_recommendations = get_user_based_recommendations('user_0', user_similarity_df, user_item_matrix)
print(f"\nRecommendations for user_0: {user_recommendations}")
# 2. Item-based Collaborative Filtering
item_similarity = cosine_similarity(user_item_matrix.T)
item_similarity_df = pd.DataFrame(
item_similarity, index=user_item_matrix.columns, columns=user_item_matrix.columns
)
print("\n2. Item Similarity Matrix (Sample):")
print(item_similarity_df.iloc[:5, :5])
# 3. Content-based Filtering
item_features = np.random.rand(len(items), 10) # Simulate item features
item_feature_similarity = cosine_similarity(item_features)
fig, axes = plt.subplots(2, 2, figsize=(14, 10))
# User similarity heatmap
sns.heatmap(user_similarity_df.iloc[:10, :10], annot=True, fmt='.2f', cmap='coolwarm',
ax=axes[0, 0], cbar_kws={'label': 'Similarity'})
axes[0, 0].set_title('User Similarity Matrix (Sample)')
# Item similarity heatmap
sns.heatmap(item_similarity_df.iloc[:10, :10], annot=True, fmt='.2f', cmap='coolwarm',
ax=axes[0, 1], cbar_kws={'label': 'Similarity'})
axes[0, 1].set_title('Item Similarity Matrix (Sample)')
# Rating distribution
axes[1, 0].hist(ratings_df['rating'], bins=5, color='steelblue', edgecolor='black', alpha=0.7)
axes[1, 0].set_xlabel('Rating')
axes[1, 0].set_ylabel('Count')
axes[1, 0].set_title('Rating Distribution')
axes[1, 0].grid(True, alpha=0.3, axis='y')
# Sparsity by user
user_rating_counts = user_item_matrix.astype(bool).sum(axis=1)
axes[1, 1].hist(user_rating_counts, bins=20, color='lightcoral', edgecolor='black', alpha=0.7)
axes[1, 1].set_xlabel('Number of Rated Items')
axes[1, 1].set_ylabel('Number of Users')
axes[1, 1].set_title('User Activity Distribution')
axes[1, 1].grid(True, alpha=0.3, axis='y')
plt.tight_layout()
plt.show()
# 4. Matrix Factorization (NMF)
nmf = NMF(n_components=10, init='random', random_state=42, max_iter=200)
user_latent = nmf.fit_transform(user_item_matrix)
item_latent = nmf.components_.T
print(f"\n4. Matrix Factorization:")
print(f"User latent factors shape: {user_latent.shape}")
print(f"Item latent factors shape: {item_latent.shape}")
# Reconstruct ratings
reconstructed_ratings = user_latent @ item_latent.T
reconstructed_df = pd.DataFrame(
reconstructed_ratings, index=user_item_matrix.index, columns=user_item_matrix.columns
)
# Calculate RMSE
original_ratings = user_item_matrix[user_item_matrix > 0]
predicted_ratings = reconstructed_df[user_item_matrix > 0]
rmse = np.sqrt(np.mean((original_ratings - predicted_ratings) ** 2))
print(f"Reconstruction RMSE: {rmse:.4f}")
# 5. Evaluation Metrics
def precision_at_k(actual, predicted, k=5):
if len(actual) == 0:
return 0
return len(set(actual[:k]) & set(predicted)) / k
def recall_at_k(actual, predicted, k=5):
if len(actual) == 0:
return 0
return len(set(actual[:k]) & set(predicted)) / len(actual)
# Simulate test set
test_user = 'user_0'
actual_items = ratings_df[ratings_df['user'] == test_user]['item'].values
predicted_items = get_user_based_recommendations(test_user, user_similarity_df, user_item_matrix, n=10)
p_at_5 = precision_at_k(predicted_items, actual_items, k=5)
r_at_5 = recall_at_k(predicted_items, actual_items, k=5)
print(f"\n5. Evaluation Metrics:")
print(f"Precision@5: {p_at_5:.2%}")
print(f"Recall@5: {r_at_5:.2%}")
print(f"F1@5: {2 * (p_at_5 * r_at_5) / (p_at_5 + r_at_5):.2%}")
# 6. Coverage and Diversity
recommended_items = set()
for user in user_item_matrix.index[:20]:
recs = get_user_based_recommendations(user, user_similarity_df, user_item_matrix, n=5)
recommended_items.update(recs)
coverage = len(recommended_items) / len(items)
print(f"\nCoverage: {coverage:.2%}")
# 7. Popularity Analysis
item_popularity = ratings_df['item'].value_counts()
fig, axes = plt.subplots(1, 2, figsize=(14, 5))
# Top items
axes[0].barh(item_popularity.head(10).index, item_popularity.head(10).values,
color='steelblue', edgecolor='black', alpha=0.7)
axes[0].set_xlabel('Number of Ratings')
axes[0].set_title('Top 10 Most Popular Items')
axes[0].grid(True, alpha=0.3, axis='x')
# Popularity distribution
axes[1].hist(item_popularity, bins=20, color='lightcoral', edgecolor='black', alpha=0.7)
axes[1].set_xlabel('Number of Ratings')
axes[1].set_ylabel('Number of Items')
axes[1].set_title('Item Popularity Distribution')
axes[1].grid(True, alpha=0.3, axis='y')
plt.tight_layout()
plt.show()
# 8. Cold Start Problem Analysis
new_user = 'new_user'
new_user_ratings = pd.DataFrame({
'user': [new_user] * 2,
'item': ['item_0', 'item_1'],
'rating': [5, 4]
})
print(f"\n8. Cold Start Problem:")
print(f"New user has rated: {len(new_user_ratings)} items")
print(f"Recommendation challenge: Limited user history")
# 9. Recommendation accuracy over time
k_values = [1, 3, 5, 10]
metrics_over_k = []
for k in k_values:
precision_scores = []
for user in user_item_matrix.index[:10]:
recs = get_user_based_recommendations(user, user_similarity_df, user_item_matrix, n=k)
actual = ratings_df[ratings_df['user'] == user]['item'].values
precision_scores.append(precision_at_k(recs, actual, k=k))
metrics_over_k.append({
'K': k,
'Precision': np.mean(precision_scores),
'Recall': np.mean([recall_at_k(get_user_based_recommendations(user, user_similarity_df, user_item_matrix, n=k),
ratings_df[ratings_df['user'] == user]['item'].values, k=k)
for user in user_item_matrix.index[:10]])
})
metrics_df = pd.DataFrame(metrics_over_k)
fig, ax = plt.subplots(figsize=(10, 5))
ax.plot(metrics_df['K'], metrics_df['Precision'], marker='o', linewidth=2, label='Precision', markersize=8)
ax.plot(metrics_df['K'], metrics_df['Recall'], marker='s', linewidth=2, label='Recall', markersize=8)
ax.set_xlabel('K (Number of Recommendations)')
ax.set_ylabel('Score')
ax.set_title('Precision and Recall vs K')
ax.legend()
ax.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()
# 10. A/B Test Results (Simulated)
print("\n10. A/B Test Results (Simulated):")
print("Control (No recommendations): 5.2% Conversion Rate")
print("Treatment (Recommendations): 7.8% Conversion Rate")
print("Lift: 50% (Statistically Significant, p < 0.05)")
print("\nRecommendation system complete!")
What ships with it
2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 9d ago First seen · 297 lines · 20 tokens per session scan A 824ca74bdd5e
Recommendation System is a skill published in the GitHub repository aj-geddes/useful-ai-prompts (338 stars, last pushed 6mo ago), licensed MIT. It adds 20 tokens to every session and 2,761 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other skills, from other repositories
apify-product-data-setup
Wire an AI agent to live e-commerce product data using Apify's E-commerce Scraping Tool over MCP, either as runtime tool calls or as a scheduled refresh into a vector store. Trigger on "give my agent live product data", "my agent quotes stale prices", "connect Apify MCP to Claude or Cursor or n8n", "add product data…
rp-source-csv
CSV file source adapter: parse core, vendor fingerprinting (Shopify, WooCommerce, Magento, BigCommerce), layout inference, file-set handling, and read contract for codegen. Use when the migration starts from one or more CSV/export files instead of a live source URL.
evo-taxonomy-merger
Merge product category taxonomies from multiple e-commerce platforms (Amazon, Facebook, Google Shopping) into a unified 5-level hierarchy. Use when you need to unify category systems across platforms with text normalization, embedding-based clustering, and constraint-validated naming.
linkfox-multimodal-extract-attributes
A product-image analysis tool that turns what appears in main listing photos into structured attributes, such as colour, shape, material, or style. It can also produce prompts describing the visual content.
ai-api-gateway-migration-guide-ai-hive
A migration guide for teams comparing an AI API gateway, which connects software to multiple AI providers, with AI-HIVE.
ai-api-task-ledger-ai-hive
An audit ledger for AI generation jobs, recording each input, model setup, price snapshot, task ID, status, result, and failure reason.