smolagents

smolagents is a cursor rule for Cursor from sanjeed5/awesome-cursor-rules-mdc. It costs 367 tokens per session, scanned A, original, CC0-1.0.

A set of coding rules for smolagents, a Python framework for building AI agents that use tools and language models. It focuses on separating agent logic and tools into clear modules and avoiding unsafe code.

In plain words
What is it for?
Use it when structuring smolagents projects, creating reusable tools, and reviewing agent code for maintainability and safety.
Why use it?
It reduces the risk of monolithic agent files, duplicated logic, difficult testing, and unsafe operations such as evaluating untrusted expressions.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when structuring smolagents projects, creating reusable tools, and reviewing agent code for maintainability and safety.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/sanjeed5/awesome-cursor-rules-mdc/smolagents
About the project

awesome-cursor-rules-mdc is a generator that creates Cursor MDC rule files from structured library information, using semantic search and language models to gather and organize guidance. Developers use it to produce reusable rules for libraries in Cursor, and the catalogue includes 200 of those rules.

sanjeed5/awesome-cursor-rules-mdc · 3,571 stars · on GitHub

Install

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.

Clone the repo
git clone --depth 1 https://github.com/sanjeed5/awesome-cursor-rules-mdc

Made for: Cursor.

Wrote 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.

agentmods badge for smolagents

README.md
[![agentmods](https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/smolagents.svg)](https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/smolagents)
Your own site
<a href="https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/smolagents"><img src="https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/smolagents.svg" alt="Measured on agentmods" height="20"></a>
Per session 367 This file is loaded in full into every session.
When invoked 367 The same file — it is already loaded in full.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00367 $0.00367
Opus 5 $0.00183 $0.00183
Sonnet 5 $0.00073 $0.00073
Haiku 4.5 $0.00037 $0.00037

Measured 4d ago against content hash 3b76b6e6f142, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

smolagents scanned grade A with 1 finding 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 4d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

response = requests.get(f"https://api.example.com/search?q
rules-mdc/smolagents.mdc · 51 lines

What it actually says

smolagents Best Practices

This guide outlines the definitive best practices for developing smolagents applications. Adhering to these principles ensures your agents are reliable, efficient, and easy to maintain.

1. Code Organization and Structure

Organize your agent logic and tools into clear, distinct modules. This improves readability, reusability, and testability.

❌ BAD: Monolithic agent file

# agent.py
from smolagents import CodeAgent, HfApiModel, tool
import requests # Direct import in agent file

@tool
def search_web(query: str) -> str:
    # ... complex search logic ...
    return "search result"

@tool
def calculate_math(expression: str) -> float:
    # ... math logic ...
    return eval(expression) # DANGER! Unsafe!

agent = CodeAgent(tools=[search_web, calculate_math], model=HfApiModel())
agent.run("What is 2+2 and also search for 'latest AI news'")

✅ GOOD: Modular structure

# src/tools.py
from smolagents import tool
import requests
import json

@tool
def web_search(query: str) -> str:
    """
    Performs a web search for the given query.
    Args:
        query: The search term.
    Returns:
        A summary of the search results or an error message.
    """
    try:
        # Replace with a real search API (e.g., DuckDuckGoSearchTool, custom API)
        response = requests.get(f"https://api.example.com/search?q
Changes

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.

  1. 4d ago First seen · 51 lines · 367 tokens per session scan A 3b76b6e6f142

Subscribe to this mod's changes

smolagents is a cursor rule published in the GitHub repository sanjeed5/awesome-cursor-rules-mdc (3,571 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 367 tokens to every session, about $0.0018 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.