python-best-practices
Aplicar Padrões Python Type-First
또한 다음에서 사용할 수 있습니다: 0xBigBoss
Escrever Python sem definições de tipos leva a erros em tempo de execução e código difícil de manter. Esta habilidade fornece padrões testados em combate para desenvolvimento type-first usando dataclasses, unions discriminadas, Protocols e outros recursos modernos do Python para tornar estados ilegais não representáveis.
스킬 ZIP 다운로드
Claude에서 업로드
설정 → 기능 → 스킬 → 스킬 업로드로 이동
토글을 켜고 사용 시작
테스트해 보기
"python-best-practices" 사용 중입니다. Create a frozen dataclass for a product with required name and price, optional description
예상 결과:
- Use @dataclass(frozen=True) for immutability
- Mark required fields without defaults first
- Add optional fields with default values after required fields
- The frozen=True flag prevents accidental mutation
- Example output shows proper field ordering and type hints
"python-best-practices" 사용 중입니다. Show how to handle state transitions with discriminated unions
예상 결과:
- Define separate classes for each state (Idle, Loading, Success, Failure)
- Use Literal types to discriminate states
- Apply pattern matching with match/case for exhaustive handling
- Raise errors for unhandled cases
- Keep state logic isolated and testable
"python-best-practices" 사용 중입니다. Create a typed configuration loader from environment variables
예상 결과:
- Define a frozen dataclass with typed fields
- Use os.environ.get with defaults for optional values
- Use os.environ[] for required secrets
- Validate configuration at load time
- Fail fast if required values are missing
보안 감사
안전This is a pure documentation skill containing only markdown guidance with code examples. The static analyzer incorrectly flagged example code patterns in documentation as security issues. All reported findings are FALSE POSITIVES because the skill contains no executable code, no file system access, no network calls, and no external command execution. The flagged patterns (backticks, environment variables, API keys in examples) are educational documentation content only.
위험 요인
🌐 네트워크 접근 (2)
📁 파일 시스템 액세스 (1)
⚙️ 외부 명령어 (42)
품질 점수
만들 수 있는 것
Projetar modelos de dados type-safe
Aprenda a usar dataclasses, NewType e unions discriminadas para codificar restrições de domínio no nível de tipos.
Revisar padrões de tipos Python
Aplicar padrões de tipagem consistentes em bases de código usando Protocols, TypedDict e unions esgotadamente correspondidas.
Gerar Python idiomático
Produzir código Python que segue padrões type-first modernos ao trabalhar com Claude, Codex ou Claude Code.
이 프롬프트를 사용해 보세요
Create a frozen dataclass with proper type hints for a user profile including required fields and optional avatar. Use the python-best-practices patterns.
Model a request state machine with idle, loading, success, and failure states using discriminated unions and pattern matching. Apply python-best-practices patterns.
Create NewType wrappers for UserId and OrderId to prevent mixing them up. Show how to validate input and create the wrapped types.
Define a Protocol for a file-like object with read method, then show how to use it as a type hint for functions that accept any read-compatible object.
모범 사례
- Defina tipos antes da implementação; deixe o verificador de tipos guiar a completude
- Use dataclasses frozen e padrões imutáveis para prevenir mutação acidental de estado
- Valide dados nas fronteiras do sistema com verificações em tempo de execução junto com dicas de tipo
피하기
- Usar argumentos padrão mutáveis em assinaturas de funções
- Pular dicas de tipo para tipos de retorno 'óbvios'
- Capturar exceções sem relançar ou adicionar contexto