Use when configuring shfmt for shell script formatting including .shfmt.toml setup, EditorConfig integration, and project-specific settings.
View on GitHubTheBushidoCollective/han
jutsu-shfmt
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-shfmt/skills/shfmt-configuration/SKILL.md -a claude-code --skill shfmt-configurationInstallation paths:
.claude/skills/shfmt-configuration/# shfmt Configuration
Master shfmt configuration for consistent shell script formatting across projects, including configuration files, EditorConfig integration, and team standardization.
## Overview
shfmt is a shell parser, formatter, and interpreter that supports POSIX Shell, Bash, and mksh. Configuration allows you to define consistent formatting rules for your shell scripts.
## Configuration Methods
shfmt supports multiple configuration approaches, in order of precedence:
1. Command-line flags (highest precedence)
2. EditorConfig settings
3. `.shfmt.toml` or `shfmt.toml` file
## TOML Configuration File
### Basic Configuration
Create `.shfmt.toml` or `shfmt.toml` in your project root:
```toml
# Shell dialect (posix, bash, mksh, bats)
shell = "bash"
# Indent with spaces (0 for tabs)
indent = 2
# Binary operators at start of line
binary-next-line = true
# Switch cases indented
switch-case-indent = true
# Redirect operators followed by space
space-redirects = false
# Keep column alignment paddings
keep-padding = false
# Function opening brace on next line
func-next-line = false
```
### Configuration Options Explained
#### shell
Specifies the shell dialect for parsing:
```toml
# POSIX-compliant shell (most portable)
shell = "posix"
# Bash (default for .bash files)
shell = "bash"
# MirBSD Korn Shell
shell = "mksh"
# Bats (Bash Automated Testing System)
shell = "bats"
```
Auto-detection based on shebang if not specified:
- `#!/bin/sh` -> posix
- `#!/bin/bash` or `#!/usr/bin/env bash` -> bash
- `#!/bin/mksh` -> mksh
#### indent
Controls indentation style:
```toml
# 2 spaces (common)
indent = 2
# 4 spaces
indent = 4
# Tabs (use 0)
indent = 0
```
#### binary-next-line
Controls binary operator positioning:
```toml
# Operators at end of line (default)
binary-next-line = false
```
```bash
# Result:
if [ "$a" = "foo" ] &&
[ "$b" = "bar" ]; then
echo "match"
fi
```
```toml
# Operators at start of next line
binary-next-line = true
```