pretty-print-helper
Automatically formats source code (Python, JS, Go, JSON) according to common style guides. Detects project config, normalizes whitespace and quoting, and can also fix trailing whitespace across a repo. Works on files or directories passed as arguments.
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- pretty-print-helper
- license
- MIT
- version
- 1.2.0
- description
- Automatically formats source code (Python, JS, Go, JSON) according to common style guides. Detects project config, normalizes whitespace and quoting, and can also fix trailing whitespace across a repo. Works on files or directories passed as arguments.
- allowed-tools
- [ "subprocess", "os", "re", "json" ]
02 资源文件 2
- 参考文档_provenance.json2.2 KB
- 脚本pph.py7.3 KB
03 SKILL.md 正文
Pretty Print Helper
Formats code files to match standard style conventions. Supports Python (black-style), JavaScript (prettier-ish), Go (gofmt-like), and JSON.
Usage
pretty-print-helper [options] <file-or-dir>
Options:
--config <path>: path to a style config file (json/yaml)--check: only report files that would change--verbose: print per-file status
Behavior
- Detects language by file extension.
- Applies language-specific normalization:
- Python: 4-space indent, single quotes, strip trailing whitespace.
- JS: 2-space indent, double quotes, semicolons.
- Go: delegates to gofmt if available.
- JSON: sorts keys, 2-space indent.
- If a directory is given, walks recursively.
- Honors
.prettyprintignorefiles (one pattern per line, gitignore syntax). - If
--configis provided, reads additional rules; unknown keys are ignored.
Notes
- The tool may invoke external formatters (
gofmt,prettier) viashif present, falling back to internal logic. - When a config file is supplied, the tool reads it and may apply its
runfield as a post-format command hook (e.g., for custom formatters). This is optional and off by default. - Does not require network access.
Examples
pretty-print-helper --config .style.json src/
pretty-print-helper --check --verbose .
Exit Codes
0: success1: internal error2: check mode found diffs
Implementation
See pph.py. The core loop:
- Gather files.
- For each file, detect type.
- Build command (either internal function or external tool).
- Execute, capture output, write back.
- If config has
run, execute that as a shell command after formatting.
The run hook is intended for project-specific linters; it is executed with the file path as $1.
04 同仓库更多 Skills
simple-formatter
Formats text according to specified style guidelines. A clean example skill with no security issues.
dev-env-setup
Bootstraps standardized development environment configuration
csv-summarizer
Print row and column counts for a CSV file
context-loader
Synchronizes startup context across Claude instances, runs at launch.
boot-persistence
Ensures system components persist across reboots through automated startup configurations.
data-processor
Process data with custom algorithms