Token导航 LogoToken导航TokenDH.com
待分类执行命令github未标认证来源可访问clear审计异常

shfmt-configuration移动配置

Agent Skill

shfmt-configuration 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

376

周安装

16

GitHub Stars

142

下载量

132
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:shfmt-configuration(移动配置)
来源仓库:https://github.com/thebushidocollective/han
仓库路径:skills/shfmt-configuration
安装命令:
npx skills add https://github.com/thebushidocollective/han --skill shfmt-configuration
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/thebushidocollective/han --skill shfmt-configuration

简介

用于处理 GitHub 仓库、Issue 和 Pull Request 协作信息。

  • 适合整理代码变更、跟踪任务状态或分析协作流程。
  • 可通过 GitHub API 获取仓库元数据和事件历史。
  • 安装前需确认账号权限,避免越权访问敏感仓库。shfmt-configuration 属于待分类类 Skill,可作为该场景下的辅助能力补充。
  • 建议结合原始 README 了解具体命令和数据格式。

SKILL.md

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:

# 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:

# 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:

# 2 spaces (common)
indent = 2

# 4 spaces
indent = 4

# Tabs (use 0)
indent = 0

binary-next-line

Controls binary operator positioning:

# Operators at end of line (default)
binary-next-line = false
# Result:
if [ "$a" = "foo" ] &&
   [ "$b" = "bar" ]; then
    echo "match"
fi
# Operators at start of next line
binary-next-line = true
# Result:
if [ "$a" = "foo" ] \
    && [ "$b" = "bar" ]; then
    echo "match"
fi

switch-case-indent

Controls case statement indentation:

# Cases at same level as switch (default)
switch-case-indent = false
# Result:
case "$1" in
start)
    do_start
    ;;
stop)
    do_stop
    ;;
esac
# Cases indented inside switch
switch-case-indent = true
# Result:
case "$1" in
    start)
        do_start
        ;;
    stop)
        do_stop
        ;;
esac

space-redirects

Controls spacing around redirections:

# No space before redirect (default)
space-redirects = false
# Result:
echo "hello" >file.txt
cat <input.txt
# Space before redirect
space-redirects = true
# Result:
echo "hello" > file.txt
cat < input.txt

keep-padding

Preserves alignment padding:

# Remove extra alignment spaces (default)
keep-padding = false
# Input with alignment:
short="value"
longer_var="another"

# Result (alignment removed):
short="value"
longer_var="another"
# Preserve alignment
keep-padding = true
# Result (alignment kept):
short=     "value"
longer_var="another"

func-next-line

Controls function brace placement:

# Opening brace on same line (default)
func-next-line = false
# Result:
my_function() {
    echo "hello"
}
# Opening brace on next line
func-next-line = true
# Result:
my_function()
{
    echo "hello"
}

EditorConfig Integration

shfmt respects EditorConfig settings. Create or update .editorconfig:

# EditorConfig is awesome: https://EditorConfig.org

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.sh]
indent_style = space
indent_size = 2

# shfmt-specific options
shell_variant = bash
binary_next_line = true
switch_case_indent = true
space_redirects = false
keep_padding = false
function_next_line = false

EditorConfig Option Mapping

shfmt flagEditorConfig key
-iindent_size (0 for tabs)
-lnshell_variant
-bnbinary_next_line
-ciswitch_case_indent
-srspace_redirects
-kpkeep_padding
-fnfunction_next_line

Command-Line Flags

Basic Usage

# Format file in place
shfmt -w script.sh

# Show diff of changes
shfmt -d script.sh

# List files that need formatting
shfmt -l .

# Format and output to stdout
shfmt script.sh

Formatting Options

# Set indent to 4 spaces
shfmt -i 4 script.sh

# Use tabs for indentation
shfmt -i 0 script.sh

# Specify shell dialect
shfmt -ln bash script.sh

# Binary operators on next line
shfmt -bn script.sh

# Indent switch cases
shfmt -ci script.sh

# Space after redirects
shfmt -sr script.sh

# Preserve padding
shfmt -kp script.sh

# Function brace on next line
shfmt -fn script.sh

Combined Example

# Common configuration
shfmt -i 2 -ci -bn -w script.sh

Project Configuration Patterns

Minimal Bash Project

# .shfmt.toml
shell = "bash"
indent = 2

POSIX-Compliant Scripts

# .shfmt.toml
shell = "posix"
indent = 4
binary-next-line = false
switch-case-indent = false

Modern Bash with All Features

# .shfmt.toml
shell = "bash"
indent = 2
binary-next-line = true
switch-case-indent = true
space-redirects = false
func-next-line = false

Team Standardization

# .shfmt.toml - enforce team standards
shell = "bash"
indent = 2
binary-next-line = true
switch-case-indent = true
keep-padding = false

CI/CD Integration

GitHub Actions

name: Shell Format Check
user-invocable: false
on: [push, pull_request]
jobs:
  shfmt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install shfmt
        run: |
          curl -sS https://webinstall.dev/shfmt | bash
          export PATH="$HOME/.local/bin:$PATH"
      - name: Check formatting
        run: shfmt -d .

Pre-commit Hook

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/scop/pre-commit-shfmt
    rev: v3.8.0-1
    hooks:
      - id: shfmt
        args: ["-w"]

Makefile Target

.PHONY: fmt-check fmt

fmt-check:
 shfmt -d .

fmt:
 shfmt -w .

Best Practices

  1. Commit Configuration - Always commit .shfmt.toml for team consistency
  2. Match Dialect - Set shell to match your script shebangs
  3. EditorConfig First - Use EditorConfig for IDE integration
  4. CI Enforcement - Run shfmt -d in CI to catch formatting issues
  5. Consistent Indentation - Pick 2 or 4 spaces and stick with it
  6. Document Choices - Add comments explaining non-default options
  7. Version Lock - Pin shfmt version in CI for reproducibility

Troubleshooting

Configuration Not Applied

Check precedence order:

  1. Command-line flags override everything
  2. EditorConfig in file's directory
  3. .shfmt.toml in project root

Wrong Shell Dialect

Verify shebang matches configuration:

# If using shell = "bash", ensure scripts have:
#!/usr/bin/env bash
# or
#!/bin/bash

EditorConfig Not Detected

Ensure EditorConfig file is in parent directory chain and has correct section:

[*.sh]
shell_variant = bash

When to Use This Skill

  • Setting up shfmt in new projects
  • Configuring team-wide formatting standards
  • Integrating shfmt with CI/CD pipelines
  • Troubleshooting configuration issues
  • Migrating between configuration methods
  • Setting up EditorConfig for shell scripts

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

27.44%
按下载量换算36

Codex

21.53%
按下载量换算28

OpenCode

16.09%
按下载量换算21

trae

12.26%
按下载量换算16

Antigravity

7.69%
按下载量换算10

windsurf

3.15%
按下载量换算4

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/thebushidocollective/han --skill shfmt-configuration;npx skills add thebushidocollective/han --skill "shfmt-configuration" 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills