name: code-formatter description: 格式化源代码文件,支持Python、JavaScript、JSON等语言,使用行业标准格式化工具。 metadata: short-description: 格式化源代码 source: repository: https://github.com/psf/black license: MIT
代码格式化工具
描述
使用行业标准格式化工具(如用于Python的Black)格式化源代码文件,支持多种编程语言。
触发条件
/format命令- 用户需要格式化代码
- 用户希望保持一致的代码风格
使用方法
# 格式化Python文件
python scripts/code_formatter.py file.py
# 使用特定行长度格式化
python scripts/code_formatter.py file.py --line-length 100
# 格式化JSON文件
python scripts/code_formatter.py config.json
# 仅检查而不修改
python scripts/code_formatter.py file.py --check
# 格式化目录
python scripts/code_formatter.py ./src/ --recursive
标签
format, code, python, black, style
兼容性
- Codex: ✅
- Claude Code: ✅