format-python

Format Python code with Black

23 stars

Best use case

format-python is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Format Python code with Black

Teams using format-python should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/format-python/SKILL.md --create-dirs "https://raw.githubusercontent.com/wangjianjq/Skill/main/.agents/skills/format-python/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/format-python/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How format-python Compares

Feature / Agentformat-pythonStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Format Python code with Black

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 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](https://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

```powershell
# Windows
.\.agents\skills\format-python\scripts\format.ps1

# Linux/Mac
./.agents/skills/format-python/scripts/format.sh
```

### Method 3: With Parameters

```powershell
# Check without modifying (preview mode)
.\.agents\skills\format-python\scripts\format.ps1 -Check

# Specify directory
.\.agents\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

> **Safety Gate**: By default, this skill skips protected folders (`.agents/`, `bmad/`).

## ⚙️ Configuration

```toml
# pyproject.toml
[tool.black]
line-length = 88
target-version = ['py38']
include = '\.pyi?$'
extend-exclude = '''
/(
  \.git
  | \.venv
  | build
  | dist
)/
'''
```

## 🔗 Related Resources

- [Black Documentation](https://black.readthedocs.io/)