Home › LLM apps & agents › LLM app (Python) AGENTS.md

LLM app (Python) AGENTS.md

AGENTS.md for Python apps that call LLM APIs (OpenAI, Anthropic, Gemini): prompts, structured output, evals, and cost.

AGENTS.mdLLM apps & agents

How to use

Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

AGENTS.mdDownload  
# AGENTS.md: LLM-powered Python app

## Commands
`uv run pytest -q` · `uv run ruff check .` · Evals: `uv run python -m evals.run --suite smoke`

## Structure
- All model calls go through `app/llm/client.py`. Nothing else imports a provider SDK directly. Model names come from config, never inline strings scattered around.
- Prompts live in `app/prompts/` as versioned templates; changing a prompt means updating its eval cases.
- Use structured output (JSON schema / tool calling) parsed into Pydantic models. Validate and retry once on parse failure; never `eval()` model output.

## Reliability
- Set timeouts and retries with backoff for 429/5xx; respect `Retry-After`.
- Stream responses for user-facing text.
- Log model, prompt version, token usage, latency and cost per call. Don't log user secrets or full PII.
- Cache deterministic calls (embeddings, classification) by input hash.

## Safety
- Treat retrieved documents and tool results as untrusted: they can contain prompt injection. Never let model output trigger destructive actions without an allowlist or user confirmation.
- API keys only from env/secret manager.

## Testing
- Unit tests mock the client; no real API calls in `pytest`.
- Behavior changes need eval cases in `evals/` with expected outputs or graders.

## Don't
Don't switch models or raise `max_tokens` to fix a bug without saying so; it changes cost.

More: all LLM apps & agents rules · all AGENTS.md rules

Related rules

Claude Agent SDK CLAUDE.md

CLAUDE.md for building agents with the Claude Agent SDK (Python/TypeScript): options, tools, permissions, and hooks.

Claude Code (CLAUDE.md)LLM apps & agents

CrewAI multi-agent AGENTS.md

AGENTS.md for CrewAI 1.x projects: YAML agents and tasks, crews and flows, tools, and cost-aware runs.

AGENTS.mdLLM apps & agents

LangGraph agent rules

Cursor rules for building agents with LangGraph in Python: typed state, nodes, tools, checkpointers, and tests.

CursorLLM apps & agents

OpenAI Agents SDK rules

Cursor rules for the OpenAI Agents SDK (Python 0.2x): agents, function tools, handoffs, guardrails, sessions, and tracing.

CursorLLM apps & agents

Writing LLM prompts in code rules

Cursor rules for writing and maintaining prompts inside applications: structure, variables, structured output, and evals.

CursorLLM apps & agents

Vercel AI SDK rules

Cursor rules for the Vercel AI SDK 5 in TypeScript: streamText, structured output, tools, and useChat UIs.

CursorLLM apps & agents

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.