agentleFS
skatedduskateddu/claude-code-python-setup/CLAUDE.md

claude-code-python-setup

CLAUDE.md28 starsChanged 6 months agoMITView on GitHub

Explicit intent and maintainability over brevity. All code must be immediately understandable to another developer (or yourself in future). Prefer Python 3.10+ features: X | None over Optional[X], built-in generics (list[int], dict[str, Any]), match/case, f-strings, Path over os.path, @dataclass for simple containers (Pydantic BaseModel when validation needed). Adapt this stack to your project needs. Remove or replace layers that don't apply. Use each tool per its design intent. Don't force workarounds. Run after code changes to verify correctness: After dependency…

The file

We split this CLAUDE.md into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Explicit intent and maintainability over brevity: All code must be immediately understandable to another developer (or yourself in future).

    line 10
  2. Very specific:

    Boolean variables: Use is_, has_, can_ prefixes (is_authenticated, has_permission)

    line 15
  3. Very specific:

    Collections: Use plural nouns (users, orders, transactions)

    line 16
  4. Very specific:

    Acronyms: Treat as words (HttpRequest not HTTPRequest, api_client not API_client)

    line 22
  5. Distinctive:

    No circular imports: refactor if detected

    line 28
  6. Very specific:

    Prefer Python 3.10+ features: X | None over Optional[X], built-in generics (list[int], dict[str, Any]), match/case, f-strings, Path over …

    line 34
  7. Distinctive:

    Use each tool per its design intent.

    line 53
  8. Distinctive:

    Run after code changes to verify correctness:

    line 79

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

Project Specifications

  • Operating System: <YOUR_OPERATIVE_SYSTEM>
  • Programming Language: Python >= 3.10
  • Package Manager: uv
  • Linter & Formatter: ruff

Golden Rule

Explicit intent and maintainability over brevity. All code must be immediately understandable to another developer (or yourself in future).

Naming Conventions

  • Variables, functions: snake_case — descriptive and explicit about scope and purpose
  • Boolean variables: Use is_, has_, can_ prefixes (is_authenticated, has_permission)
  • Collections: Use plural nouns (users, orders, transactions)
  • Temporary variables: Acceptable in comprehensions/loops (for item in items)
  • Classes: PascalCase — single noun or noun phrase
  • Constants: UPPER_CASE — module-level immutable values
  • Private members: _leading_underscore — single underscore for internal use only
  • Dunder names: __double_underscore__ — reserved for Python magic; avoid unless implementing protocols
  • Acronyms: Treat as words (HttpRequest not HTTPRequest, api_client not API_client)

File Organization

  • One class per file unless classes are tightly coupled
  • Imports grouped: Standard library → Third-party → Local application (alphabetical within groups)
  • No circular imports: refactor if detected
  • Module docstring: brief one-liner describing purpose
  • Constants at module top, below imports

Python Modern Syntax

Prefer Python 3.10+ features: X | None over Optional[X], built-in generics (list[int], dict[str, Any]), match/case, f-strings, Path over os.path, @dataclass for simple containers (Pydantic BaseModel when validation needed).

Tech Stack

LayerTechnologyNotes
DatabasePostgreSQLDefault relational database
CacheRedisOptional, via redis-py
ORMSQLAlchemy 2.0Async support via asyncpg
Data ValidationPydanticAlso used for settings via pydantic-settings
Task QueueCelery / ARQCelery (sync) or ARQ (async)
APIFastAPIAsync, OpenAPI, Pydantic validation
CLITyperCommand-line interfaces
Terminal/LoggingRichRich output and logging
TestingpytestSee .claude/rules/testing.md
ContainersDocker + docker-composeLocal dev and deployment
CI/CDGitHub ActionsDefault pipeline

Adapt this stack to your project needs. Remove or replace layers that don't apply. Use each tool per its design intent. Don't force workarounds.

Common Commands

# Dependencies
uv sync                             # Install/sync default deps (dev group)
uv sync --group agents              # Also install agent tooling (mypy, bandit, ...)
uv add <package>                    # Add a dependency
uv add --dev <package>              # Add a dev dependency
uv remove <package>                 # Remove a dependency

# Testing
uv run pytest                       # Run all tests
uv run pytest tests/test_mod.py -v  # Run specific file, verbose
uv run pytest -k "test_name" -v     # Run tests matching pattern
uv run pytest --cov=src             # Run with coverage report

# Linting & Formatting
uv run ruff check .                 # Lint
uv run ruff check . --fix           # Lint + auto-fix
uv run ruff format .                # Format

Verification

Run after code changes to verify correctness:

uv run ruff check . && uv run ruff format --check . && uv run pytest -x

After dependency changes:

uv sync && uv run pytest

Detailed Rules

Coding standards are organized in .claude/rules/ by topic:

  • @.claude/rules/api-patterns.md
  • @.claude/rules/architecture.md
  • @.claude/rules/compaction.md
  • @.claude/rules/documentation.md
  • @.claude/rules/exception-handling.md
  • @.claude/rules/git-workflow.md
  • @.claude/rules/project-structure.md
  • @.claude/rules/python-idioms.md
  • @.claude/rules/security.md
  • @.claude/rules/testing.md

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.