extractum-skills / rules
Cursor rule47 starsChanged 10 months agoMITView on GitHub
Python coding standards and best practices
- Reads credentials
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 4,263 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository7 other files it gives its agents.
- .cursor/rules/00-project-overview.mdcCursor rule
- .cursor/rules/05-solution-design.mdcCursor rule
- .cursor/rules/20-type-annotations.mdcCursor rule
- .cursor/rules/30-logging-standards.mdcCursor rule
- .cursor/rules/40-docstrings.mdcCursor rule
- .cursor/rules/50-error-handling.mdcCursor rule
- .cursor/rules/60-async-patterns.mdcCursor rule
The file
We split this 10-python-standards.mdc into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
All imports must be at the beginning of the file, never inline.
- Very specific: line 81
Use SCREAMING_SNAKE_CASE for constants:
≈ “Common” is an estimate: at least 1 in 5 of the 7,111 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: "Python coding standards and best practices"
globs:
- "**/*.py"
alwaysApply: false
priority: 20
---
# Python Coding Standards
## Imports Organization
All imports must be at the **beginning of the file**, never inline.
### Import Order
1. Standard library imports
2. Third-party imports
3. Local application imports
Separate each group with a blank line.
```python
# Standard library
import asyncio
import logging
import os
import sys
from datetime import datetime
from pathlib import Path
from typing import Any, TypedDict
# Third-party
from dotenv import load_dotenv
# Local application
from claude_agent_sdk import ClaudeAgentOptions, query
```
---
## Constants
### Numerical Values
Define constants for all magic numbers:
```python
# ✅ Good
DEFAULT_MAX_TURNS: int = 50
DEFAULT_MAX_BUDGET_USD: float = 1.0
LOG_PREVIEW_LENGTH: int = 200
# ❌ Bad
options = ClaudeAgentOptions(max_turns=50, max_budget_usd=1.0)
```
### String Values
Define constants for repeated strings. Use multiline `"""..."""` for long strings:
```python
# ✅ Good
ENV_API_KEY: str = "ANTHROPIC_API_KEY"
LOGGER_NAME: str = "claude_agent"
ERROR_API_KEY_MISSING: str = """
ANTHROPIC_API_KEY not found in environment variables.
Please ensure it is set in your .env file.
"""
# ❌ Bad
api_key = os.getenv("ANTHROPIC_API_KEY")
raise ValueError("ANTHROPIC_API_KEY not found...")
```
---
## Constants Naming
Use SCREAMING_SNAKE_CASE for constants:
```python
# Configuration
DEFAULT_MAX_TURNS: int = 50
LOG_ENCODING: str = "utf-8"
# Paths and directories
LOGS_DIR_NAME: str = "logs"
LOG_FILE_PREFIX: str = "agent_"
# Format strings
LOG_DATE_FORMAT: str = "%Y-%m-%d %H:%M:%S"
```
---
## Code Organization
Organize code into logical sections with separator comments:
```python
# =============================================================================
# Constants
# =============================================================================
# ... constants here ...
# =============================================================================
# Type Definitions
# =============================================================================
# ... types here ...
# =============================================================================
# Main Functions
# =============================================================================
# ... functions here ...
```
---
## Function Extraction
Extract repeated logic into helper functions (prefix private helpers with `_`):
```python
# ✅ Good - Extracted helper
def _log_separator(logger: logging.Logger) -> None:
"""Log a separator line."""
logger.info(SEPARATOR_CHAR * SEPARATOR_LENGTH)
# ❌ Bad - Repeated inline
logger.info("=" * 50)
logger.info("SUMMARY")
logger.info("=" * 50)
```
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

