agentleFS
carloss765carloss765/agent-skills/.claude/skills/python-extension/SKILL.md

python-development

Skill1 starsChanged 10 months agoISCView on GitHub

Best practices for writing clean, Pythonic, and maintainable Python code. Use when working with .py files, Python applications, data science projects, or backend services.

We split this skill into the rules it gives an agent

50 rules. 0 are common, 48 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 48

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 11
  2. Distinctive:

    PEP 8 Compliance: Follow PEP 8 style guide strictly (indentation, naming, line length).

    line 20
  3. Distinctive:

    Type Hints: Use type hints (PEP 484) for function signatures and complex variables.

    line 22
  4. Very specific:

    Snake Case: Use snake_case for functions and variables, PascalCase for classes, UPPER_CASE for constants.

    line 23
  5. Distinctive:

    Docstrings: Write docstrings for all public modules, functions, classes, and methods (PEP 257).

    line 24
  6. Very specific:

    Package Structure: Use __init__.py for package initialization and public API exposure.

    line 29
  7. Distinctive:

    Absolute Imports: Prefer absolute imports over relative except within packages.

    line 31
  8. Distinctive:

    Function Length: Keep functions focused and concise (ideally under 25 lines).

    line 36
  9. Distinctive:

    Default Arguments: Use immutable defaults. Never use mutable defaults ([], {}).

    line 37
  10. Distinctive:

    Keyword Arguments: Use keyword arguments for clarity, especially with multiple parameters.

    line 38
  11. Distinctive:

    Return Early: Use guard clauses to reduce nesting and improve readability.

    line 40
  12. Distinctive:

    Pure Functions: Prefer pure functions without side effects when possible.

    line 41
  13. Distinctive:

    List Comprehensions: Use comprehensions for simple transformations.

    line 45
  14. Distinctive:

    Generator Expressions: Use generators for large datasets to save memory.

    line 46
  15. Distinctive:

    Dictionary Operations: Use dict.get() for safe key access.

    line 47
  16. Distinctive:

    Sets for Membership: Use sets for fast membership testing and removing duplicates.

    line 48
  17. Distinctive:

    Unpacking: Use tuple/list unpacking for multiple assignments and function returns.

    line 49
  18. Distinctive:

    Enums: Use Enum for related constants instead of magic strings or numbers.

    line 50
  19. Distinctive:

    Data Classes: Use @dataclass (Python 3.7+) for simple data containers.

    line 54
  20. Distinctive:

    Properties: Use @property for getters, @setter for setters instead of direct attribute access.

    line 55
  21. Distinctive:

    Method Types: Use @staticmethod for utility methods, @classmethod for alternate constructors.

    line 59
  22. Distinctive:

    Custom Exceptions: Create custom exception classes for domain-specific errors.

    line 64
  23. Distinctive:

    EAFP Principle: Use "Easier to Ask Forgiveness than Permission" - try/except over if checks.

    line 65
  24. Distinctive:

    Context Managers: Use with statements for resource management (files, locks, connections).

    line 66
  25. Distinctive:

    Finally Blocks: Use finally for cleanup that must run regardless of exceptions.

    line 67
  26. Distinctive:

    Gradual Typing: Add type hints incrementally, focusing on public APIs first.

    line 72
  27. Distinctive:

    Common Types: Use List, Dict, Tuple, Optional, Union from typing module.

    line 73
  28. Distinctive:

    Generics: Use TypeVar for generic functions and classes.

    line 74
  29. Distinctive:

    Protocol: Use Protocol for structural subtyping (duck typing with types).

    line 75
  30. Distinctive:

    Type Checkers: Run mypy or pyright for static type checking.

    line 76
  31. Distinctive:

    Runtime Validation: Use pydantic or similar for runtime validation of complex types.

    line 77
  32. Distinctive:

    Async/Await: Use async/await for I/O-bound concurrent operations.

    line 81
  33. Distinctive:

    Async Context Managers: Use async with for asynchronous resource management.

    line 83
  34. Distinctive:

    Gather vs Wait: Use asyncio.gather() for concurrent tasks, wait() for conditional waiting.

    line 84
  35. Distinctive:

    Sync vs Async: Don't mix synchronous and asynchronous code carelessly.

    line 85
  36. Distinctive:

    Profile First: Use cProfile or line_profiler before optimizing.

    line 89
  37. Distinctive:

    List vs Generator: Use generators for large datasets or streaming data.

    line 90
  38. Distinctive:

    String Concatenation: Use join() for concatenating many strings, not +.

    line 92
  39. Distinctive:

    Caching: Use @lru_cache for expensive pure function calls.

    line 93
  40. Distinctive:

    NumPy: Use NumPy for numerical operations instead of loops when possible.

    line 94
  41. Distinctive:

    pytest Over unittest: Prefer pytest for its simplicity and powerful features.

    line 98
  42. Distinctive:

    Fixtures: Use pytest fixtures for setup and teardown.

    line 100
  43. Distinctive:

    Parametrize: Use @pytest.mark.parametrize for testing multiple inputs.

    line 101
  44. Distinctive:

    Mocking: Use unittest.mock for isolating units under test.

    line 103
  45. Distinctive:

    Virtual Environments: Always use venv or virtualenv for project isolation.

    line 107
  46. Distinctive:

    Poetry/Pipenv: Consider modern dependency managers for complex projects.

    line 110
  47. Distinctive:

    Not closing file handles

    line 128
  48. Distinctive:

    Module Docstrings: Document module purpose at the top of each file.

    line 132
  49. Distinctive:

    Function Docstrings: Use Google or NumPy style for consistency.

    line 133
  50. Distinctive:

    Before submitting Python code, verify:

    line 140

“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “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
SKILL.md

Python Development Skills

When to Use This Skill

Use this skill when:

  • Writing or refactoring Python code (.py files)
  • Developing backend services, APIs, or web applications
  • Working on data science, machine learning, or automation projects
  • Creating Python packages or libraries
  • Debugging or optimizing Python code

I. Pythonic Principles (PEP 8 & Beyond)

  • PEP 8 Compliance: Follow PEP 8 style guide strictly (indentation, naming, line length).
  • Zen of Python: Embrace "import this" principles - explicit is better than implicit, simple is better than complex.
  • Type Hints: Use type hints (PEP 484) for function signatures and complex variables.
  • Snake Case: Use snake_case for functions and variables, PascalCase for classes, UPPER_CASE for constants.
  • Docstrings: Write docstrings for all public modules, functions, classes, and methods (PEP 257).

II. Code Structure & Organization

  • Module Organization: Structure projects with clear separation (src/, tests/, docs/).
  • Package Structure: Use init.py for package initialization and public API exposure.
  • Import Order: Group imports (standard library, third-party, local) with blank lines between.
  • Absolute Imports: Prefer absolute imports over relative except within packages.
  • Single Responsibility: Each function, class, and module should have one clear purpose.

III. Functions & Methods

  • Function Length: Keep functions focused and concise (ideally under 25 lines).
  • Default Arguments: Use immutable defaults. Never use mutable defaults ([], {}).
  • Keyword Arguments: Use keyword arguments for clarity, especially with multiple parameters.
  • ***args and kwargs: Use sparingly and document their purpose.
  • Return Early: Use guard clauses to reduce nesting and improve readability.
  • Pure Functions: Prefer pure functions without side effects when possible.

IV. Data Structures & Collections

  • List Comprehensions: Use comprehensions for simple transformations. Avoid complex nested comprehensions.
  • Generator Expressions: Use generators for large datasets to save memory.
  • Dictionary Operations: Use dict.get() for safe key access. Use defaultdict or setdefault when appropriate.
  • Sets for Membership: Use sets for fast membership testing and removing duplicates.
  • Unpacking: Use tuple/list unpacking for multiple assignments and function returns.
  • Enums: Use Enum for related constants instead of magic strings or numbers.

V. Object-Oriented Programming

  • Data Classes: Use @dataclass (Python 3.7+) for simple data containers.
  • Properties: Use @property for getters, @setter for setters instead of direct attribute access.
  • Dunder Methods: Implement str, repr, eq for custom classes.
  • Inheritance: Favor composition over inheritance. Use ABC for abstract base classes.
  • Class vs Instance Attributes: Understand the difference. Be careful with mutable class attributes.
  • Method Types: Use @staticmethod for utility methods, @classmethod for alternate constructors.

VI. Error Handling

  • Specific Exceptions: Catch specific exceptions, not bare except.
  • Custom Exceptions: Create custom exception classes for domain-specific errors.
  • EAFP Principle: Use "Easier to Ask Forgiveness than Permission" - try/except over if checks.
  • Context Managers: Use with statements for resource management (files, locks, connections).
  • Finally Blocks: Use finally for cleanup that must run regardless of exceptions.
  • Error Messages: Provide clear, actionable error messages.

VII. Type Hints & Static Analysis

  • Gradual Typing: Add type hints incrementally, focusing on public APIs first.
  • Common Types: Use List, Dict, Tuple, Optional, Union from typing module.
  • Generics: Use TypeVar for generic functions and classes.
  • Protocol: Use Protocol for structural subtyping (duck typing with types).
  • Type Checkers: Run mypy or pyright for static type checking.
  • Runtime Validation: Use pydantic or similar for runtime validation of complex types.

VIII. Asynchronous Programming

  • Async/Await: Use async/await for I/O-bound concurrent operations.
  • Event Loop: Understand asyncio event loop and avoid blocking operations.
  • Async Context Managers: Use async with for asynchronous resource management.
  • Gather vs Wait: Use asyncio.gather() for concurrent tasks, wait() for conditional waiting.
  • Sync vs Async: Don't mix synchronous and asynchronous code carelessly.

IX. Performance & Optimization

  • Profile First: Use cProfile or line_profiler before optimizing.
  • List vs Generator: Use generators for large datasets or streaming data.
  • Local Variables: Access local variables is faster than global or attribute access.
  • String Concatenation: Use join() for concatenating many strings, not +.
  • Caching: Use @lru_cache for expensive pure function calls.
  • NumPy: Use NumPy for numerical operations instead of loops when possible.

X. Testing

  • pytest Over unittest: Prefer pytest for its simplicity and powerful features.
  • Test Organization: Mirror source structure in tests/ directory.
  • Fixtures: Use pytest fixtures for setup and teardown.
  • Parametrize: Use @pytest.mark.parametrize for testing multiple inputs.
  • Coverage: Aim for high test coverage but focus on critical paths.
  • Mocking: Use unittest.mock for isolating units under test.

XI. Dependencies & Environment

  • Virtual Environments: Always use venv or virtualenv for project isolation.
  • Requirements Files: Maintain requirements.txt or use pyproject.toml (PEP 518).
  • Pinned Versions: Pin exact versions for reproducible builds (requirements-lock.txt).
  • Poetry/Pipenv: Consider modern dependency managers for complex projects.
  • Python Version: Specify minimum Python version in setup.py or pyproject.toml.

XII. Common Patterns

Good Patterns:

  • Context managers for resource management
  • Decorators for cross-cutting concerns
  • Generators for lazy evaluation
  • Factory functions for object creation
  • Strategy pattern with callable objects

Anti-Patterns to Avoid:

  • Mutable default arguments
  • Catching Exception or BaseException
  • Using global variables
  • Star imports (from module import *)
  • Bare except clauses
  • Not closing file handles

XIII. Documentation

  • Module Docstrings: Document module purpose at the top of each file.
  • Function Docstrings: Use Google or NumPy style for consistency.
  • Type Information: Include parameter and return types in docstrings if not using type hints.
  • Examples: Provide usage examples in docstrings for complex functions.
  • README: Maintain comprehensive README.md with usage examples.

XIV. Best Practices Checklist

Before submitting Python code, verify:

  • PEP 8 compliant (use black or autopep8)
  • Type hints on public functions
  • Docstrings on all public APIs
  • No mutable default arguments
  • Specific exception handling
  • Context managers for resources
  • List comprehensions are readable
  • No unused imports or variables
  • Tests written and passing
  • Virtual environment used

Download now (ZIP)

  • Other versions11 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 11

    1. microsoft/agent-framework★ 14ksame name
    2. Community-Access/accessibility-agents★ 409same name
    3. sammcj/agentic-coding★ 164same name
    4. d-padmanabhan/agent-engineering-handbook★ 17same name
    5. tstapler/dotfiles★ 8same name
    6. HK-hub/AgentSkills★ 6same name
    7. ProjAnvil/MindForge★ 3same name
    8. CODE-SAURABH/OpenSkills★ 2same name
    9. pepebot-space/skills★ 2same name
    10. jgeorgeai11/claude_code_resources★ 1same name

    1 more not listed

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • Used alongsideProjects with it also use javascript-typescript, github and 4 more.

    Other files people use alongside this one.

    Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
    • pepebot-spaceSkill

      javascript-typescript

      JavaScript and TypeScript development with ES6+, Node.js, React, and modern web frameworks. Use for frontend, backend, or full-stack JavaScript/TypeScript projects.

      Also in 3 projects that use this

    • NVIDIASkill

      github

      Interact with GitHub using the gh CLI restricted to REST API only (no GraphQL). Use when the user wants to work with GitHub issues, pull requests, repos, releases, or Actions — especially in sandboxed environments where the GraphQL endpoint may be blocked. Trigger keywords - github, gh, pull request, PR, github issue, github actions, workflow, release, gh api.

      Also in 3 projects that use this

    • MicrosoftSkill

      api-design

      Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.

      Also in 3 projects that use this

    • JetBrainsSkill

      brand-guidelines

      Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

      Also in 3 projects that use this

    • AnthropicSkill

      pdf

      Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.

      Also in 3 projects that use this

    • GoogleSkill

      code-review

      Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.

      Also in 3 projects that use this

  • In this repository13 other files it gives its agents.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

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.