name: format-python description: Format Python code with Black
Python Format Skill
๐ Overview
Use Black to automatically format Python code, an uncompromising code formatter:
- ๐จ Unified style: Automatic team code style consistency
- โก Fast execution: Extremely fast formatting speed
- ๐ Deterministic: Same code always produces same result
- ๐ง Zero config: Works out of the box
๐ง Prerequisites
| Tool | Min Version | Check Command | Installation |
|---|---|---|---|
| Python | 3.8+ | python --version |
python.org |
| Black | 22.0+ | black --version |
pip install black |
๐ Usage
Method 1: AI Assistant
"Use format-python to format my code"
Method 2: Run Script Directly
# Windows
.\.agent\skills\format-python\scripts\format.ps1
# Linux/Mac
./.agent/skills/format-python/scripts/format.sh
Method 3: With Parameters
# Check without modifying (preview mode)
.\.agent\skills\format-python\scripts\format.ps1 -Check
# Specify directory
.\.agent\skills\format-python\scripts\format.ps1 -Path ".\src"
๐ฏ What It Formats
- โ Indentation standardization (4 spaces)
- โ Line length limit (default 88 characters)
- โ String quote unification
- โ Bracket and comma normalization
- โ Import statement formatting
โ๏ธ Configuration
# pyproject.toml
[tool.black]
line-length = 88
target-version = ['py38']
include = '\.pyi?$'
extend-exclude = '''
/(
\.git
| \.venv
| build
| dist
)/
'''