cursorrules

A set of coding rules for Agent2, a Python framework for building AI agents with web APIs, authentication, approvals, and knowledge search.

In plain words
What is it for?
Use it when creating or modifying Agent2 agents, their tools, configuration, API services, prompts, and typed outputs.
Why use it?
It keeps agent code consistent and prevents developers from bypassing the framework’s required structure and shared runtime.

Cursor rule for Cursor

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.

agentmods
npx agentmods add rules/artesiana/agent2/cursorrules
Clone the repo
git clone --depth 1 https://github.com/Artesiana/agent2

Made for: Cursor.

Per session 399 This file is loaded in full into every session.
When invoked 399 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
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 $0.00399 $0.00399
Opus 5 $0.00199 $0.00199
Sonnet 5 $0.00080 $0.00080
Haiku 4.5 $0.00040 $0.00040

Measured yesterday against content hash 8087baa08bc4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cursorrules 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 yesterday.

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.

- Docker: docker compose up -d && curl localhost:8001/health
.cursorrules · 40 lines

What it actually says

Agent2 — Production Runtime for AI Agents

What this repo is

Agent2 is a framework for building production AI agents with typed HTTP APIs. PydanticAI handles the agent loop. Agent2 handles everything else: API, auth, pause/resume, approvals, provider routing, knowledge search.

Key patterns

  • Agents live in agents// with: schemas.py, agent.py, tools.py, config.yaml, main.py
  • create_agent() from shared/runtime.py is the ONLY way to build agents
  • create_app() from shared/api.py is the ONLY way to build FastAPI apps
  • Use instructions= (not system_prompt=) for agent prompts
  • Use toolsets= for MCP server connections
  • Output schemas are Pydantic BaseModel classes passed as output_type=

Code style

  • Python 3.12+, type hints on all signatures
  • from future import annotations in all shared/ modules
  • RFC 7807 error responses via ProblemError
  • Config uses frozen dataclasses with from_env(), not pydantic-settings
  • OpenRouter models: OpenAIChatModel + OpenRouterProvider

Architecture rules

  • shared/ is framework code — never modify it for agent-specific logic
  • Each agent is a separate Docker service
  • Prompts are code-first; Langfuse is optional for observability
  • Knowledge is in R2R, accessed via Knowledge MCP

Testing

  • uv run pytest tests/ -v (unit tests, no Docker needed)
  • Docker: docker compose up -d && curl localhost:8001/health

Creating a new agent

  1. cp -r agents/_template agents/my-agent
  2. Edit schemas.py (Pydantic output model)
  3. Edit agent.py (create_agent + tools)
  4. Edit config.yaml (name, model, collections)
  5. Edit main.py (create_app call)
  6. Add to docker-compose.yml
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. yesterday First seen · 40 lines · 399 tokens per session scan A 8087baa08bc4

Subscribe to this mod's changes

cursorrules is a cursor rule published in the GitHub repository Artesiana/agent2 (36 stars, last pushed 3mo ago), licensed MIT. It adds 399 tokens to every session, about $0.0020 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-08-30.