skillfed

shfmt-py

Python wrapper around invoking shfmt (https://github.com/mvdan/sh)

shfmt-py v4.0.0 286.5K downloads/30d#8,042 on PyPI19
Permissive license MIT Active released

What it is and what it does

shfmt-py is a Python wrapper that downloads and bundles the shfmt shell script formatter binary for your operating system at install time. Once installed, it makes the shfmt command available on your PATH (or as shfmt.exe on Windows), allowing you to format shell scripts from the command line or integrate formatting into your development workflow via pre-commit hooks.

The package has no runtime dependencies and is independently versioned from the upstream shfmt project—each release notes specify which shfmt version is bundled. It supports Python 3.9 and later on CPython and PyPy, and provides platform-specific wheels for macOS (Intel and ARM), Linux (x86_64 and aarch64), and Windows. The wrapper handles the complexity of downloading the correct binary for your platform, so you get a consistent shfmt experience across development machines without manual binary management.

Use it for:

  • Enforce consistent shell script formatting in CI/CD pipelines by installing shfmt-py and running it as a linter step.
  • Set up a pre-commit hook to automatically format shell scripts before commits, using the sample .pre-commit-config.yaml configuration.
  • Format shell scripts locally during development without manually downloading or managing the shfmt binary for your platform.
  • Integrate shell script formatting into Python-based build or deployment tools that need to standardize script formatting.
  • Ensure shell script style consistency across a team by pinning a specific shfmt-py version in a shared development environment.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a Python-installable wrapper that bundles the shfmt shell script formatter binary for your platform, making it available as a command-line tool or pre-commit hook.

Yes, if you need to format shell scripts in a Python environment or CI/CD pipeline. The package is actively maintained, has no runtime dependencies, and provides convenient platform-specific binary distribution. Medium install friction (platform-specific downloads) is a minor trade-off for avoiding manual binary management. Be aware that the bundled shfmt version does not directly mirror the PyPI version—check release notes for the exact upstream version you're getting.

Install

shfmt-py on PyPI

pip

pip install shfmt-py

uv

uv add shfmt-py

poetry

poetry add shfmt-py

Installing shfmt-py

Before you install

Medium install friction due to platform-specific binary downloads at install time. The package is actively maintained with a recent release (93 days ago) and supports current Python versions (3.9+). No runtime dependencies simplifies the installation footprint.

License in practice

MIT license permits commercial and private use with minimal restrictions—you may use, modify, and distribute this package freely as long as you include the license notice.

Quickstart

pip install shfmt-py
shfmt --version
shfmt -i 2 script.sh

Requires Python 3.9 or later. Binary downloads occur at install time; SSL certificate issues may occur on macOS and require manual certificate installation.

Verify before relying

  • Whether the bundled shfmt version is documented clearly enough for users who need a specific upstream shfmt release.
  • Performance impact of the binary download during installation on slow or unreliable networks.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 93 days since the last release
Last repo commit
First released
Downloads 286,537/month — #8,042 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: shfmt_py-4.0.0-py2.py3-none-macosx_10_9_x86_64.whl; shfmt_py-4.0.0-py2.py3-none-macosx_11_0_arm64.whl; shfmt_py-4.0.0-py2.py3-none-manylinux2014_aarch64.whl; shfmt_py-4.0.0-py2.py3-none-manylinux2014_x86_64.whl; shfmt_py-4.0.0-py2.py3-none-win_amd64.whl

Programming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

shell script formattershfmt wrapper pythonformat bash scriptsshell code formatterpre-commit shell formattingsh script lintingshell script linter
shell-formattingpre-commit-hookcode-quality

More Build Tools packages