project-main-rules

project-main-rules is a cursor rule for Cursor from wassim249/fastapi-langgraph-agent-production-ready-template. It costs 2,109 tokens per session, scanned A, original, MIT.

Project-wide rules for building AI-agent services with Python, FastAPI, LangGraph, and LangChain. They cover the system's workflow, API layer, memory, authentication, monitoring, retries, and logging.

In plain words
What is it for?
Use them when developing or reviewing the project's agent workflows, REST endpoints, database-backed memory, access control, usage limits, tracing, metrics, retries, or console output.
Why use it?
They give developers a shared design and coding standard for a service with multiple connected infrastructure parts. This reduces inconsistent implementations and makes production concerns explicit.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

About the project

FastAPI LangGraph Agent Template is a starter codebase for building AI-agent backends with FastAPI and LangGraph, including conversation state, memory, tool calls, monitoring, rate limits, and authentication. AI engineers use it as a foundation for deploying agent services, and the catalogue instructions and rule support development and operation of those services.

wassim249/fastapi-langgraph-agent-production-ready-template · 2,639 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.

agentmods
npx agentmods add rules/wassim249/fastapi-langgraph-agent-production-ready-template/project-main-rules
Clone the repo
git clone --depth 1 https://github.com/wassim249/fastapi-langgraph-agent-production-ready-template

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 project-main-rules

README.md
[![agentmods](https://agentmods.dev/badge/rules/wassim249/fastapi-langgraph-agent-production-ready-template/project-main-rules.svg)](https://agentmods.dev/rules/wassim249/fastapi-langgraph-agent-production-ready-template/project-main-rules)
Your own site
<a href="https://agentmods.dev/rules/wassim249/fastapi-langgraph-agent-production-ready-template/project-main-rules"><img src="https://agentmods.dev/badge/rules/wassim249/fastapi-langgraph-agent-production-ready-template/project-main-rules.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,109 This file is loaded in full into every session.
When invoked 2,109 The same file — it is already loaded in full.
Security scan A 0 findings. 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.1 $0.02109 $0.02109
Opus 5 $0.01055 $0.01055
Sonnet 5 $0.00422 $0.00422
Haiku 4.5 $0.00211 $0.00211

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

Security

Grade A, and why

project-main-rules 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 6d 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.

.cursor/rules/project-main-rules.mdc · 220 lines

How it starts

The opening of the file, as written. The whole thing — 220 lines — stays where its author put it; the contents beside it link to each section on GitHub.

LangGraph FastAPI AI Agent Development

You are an expert in building production-ready AI agent applications using Python, FastAPI, LangGraph, and LangChain.

This is a LangGraph FastAPI Agent Project for building scalable, secure AI agent services with LLM orchestration, observability, and persistence.

Project Architecture Overview

This is an AI agent application that:

  • Uses LangGraph for building stateful, multi-step AI agent workflows
  • Uses FastAPI for high-performance async REST API endpoints
  • Integrates Langfuse for LLM observability and tracing
  • Uses PostgreSQL with pgvector for long-term memory storage (mem0ai)
  • Implements JWT authentication with session management
  • Provides rate limiting with slowapi
  • Includes Prometheus metrics and Grafana dashboards for monitoring
  • Uses structlog for structured logging with environment-specific formatting
  • Implements retry logic using tenacity library
  • Uses rich library for colored, formatted console outputs

Key Principles

  • Write concise, technical responses with accurate Python examples
  • Use functional, declarative programming; avoid classes where possible except for services and agents
  • Prefer iteration and modularization over code duplication
  • Use descriptive variable names with auxiliary verbs (e.g., is_active, has_permission)
  • Use lowercase with underscores for directories and files (e.g., routers/user_routes.py)
  • Favor named exports for routes and utility functions
  • Use the Receive an Object, Return an Object (RORO) pattern
  • All imports must be at the top of the file - never add imports inside functions or classes

Python/FastAPI Conventions

  • Use def for pure functions and async def for asynchronous operations
  • Use type hints for all function signatures; prefer Pydantic models over raw dictionaries
  • File structure: exported router, sub-routes, utilities, static content, types (models, schemas)
  • Use concise, one-line syntax for simple conditional statements (e.g., if condition: do_something())
  • Avoid unnecessary else statements; use the if-return pattern instead

Read the full file on GitHub · 220 lines

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. 6d ago First seen · 220 lines · 2,109 tokens per session scan A 3c0efd2b50c0

Subscribe to this mod's changes

project-main-rules is a cursor rule published in the GitHub repository wassim249/fastapi-langgraph-agent-production-ready-template (2,639 stars, last pushed 20d ago), licensed MIT. It adds 2,109 tokens to every session, about $0.0105 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-08-30.