← 返回 Skills 市场
terrycarter1985

Code Formatter

作者 terrycarter1985 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
81
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install code-formatter
功能描述
Code formatting best practices and quick references for Python, JavaScript, JSON, Markdown, and common languages with Prettier, Black, ESLint, and other form...
使用说明 (SKILL.md)

Code Formatter & Style Guide

Quick references for code formatting tools and style best practices.


🐍 Python Formatting

Black (Opinionated Formatter)

# Install
pip install black

# Format file
black file.py

# Format directory
black src/

# Check without modifying
black --check file.py

# Configuration (pyproject.toml)
[tool.black]
line-length = 88
target-version = ['py310']

isort (Import Sorting)

# Install
pip install isort

# Sort imports
isort file.py
isort src/

# Black-compatible config
[tool.isort]
profile = "black"

flake8 (Linting)

# Install
pip install flake8

# Lint
flake8 file.py
flake8 src/

# Config (setup.cfg)
[flake8]
max-line-length = 88
extend-ignore = E203, W503

ruff (Fast Linter & Formatter)

# Install
pip install ruff

# Lint
ruff check file.py

# Fix automatically
ruff check --fix file.py

# Format
ruff format file.py

💛 JavaScript/TypeScript Formatting

Prettier

# Install
npm install -D prettier

# Format
npx prettier --write file.js
npx prettier --write src/

# Check
npx prettier --check file.js

# Config (.prettierrc)
{
  "semi": true,
  "singleQuote": true,
  "tabWidth": 2,
  "trailingComma": "es5",
  "printWidth": 80
}

# Ignore (.prettierignore)
node_modules/
build/
dist/

ESLint

# Install
npm install -D eslint

# Initialize
npx eslint --init

# Lint
npx eslint file.js
npx eslint src/

# Fix
npx eslint --fix file.js

# Config (.eslintrc.js)
module.exports = {
  extends: ['eslint:recommended'],
  parserOptions: { ecmaVersion: 2022 },
  rules: {
    'no-unused-vars': 'warn',
    'no-console': 'warn'
  }
}

Format on Save (VS Code)

// settings.json
{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true,
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[python]": {
    "editor.defaultFormatter": "ms-python.black-formatter"
  }
}

📋 JSON Formatting

jq

# Pretty print JSON
jq '.' file.json

# Compact (one line)
jq -c '.' file.json

# Sort keys
jq -S '.' file.json

Prettier for JSON

npx prettier --write file.json
npx prettier --write *.json

Python json.tool

python3 -m json.tool file.json
python3 -m json.tool file.json --sort-keys

📝 Markdown Formatting

Prettier

npx prettier --write README.md
npx prettier --write docs/

markdownlint

# Install
npm install -D markdownlint-cli

# Lint
npx markdownlint README.md
npx markdownlint docs/

# Fix
npx markdownlint --fix README.md

Common Rules

  • Line length: 80-120 chars
  • ATX headers: # Header not Header =====
  • Consistent list indentation (2 spaces)
  • One blank line between sections
  • Trailing whitespace removal

🔧 EditorConfig (Cross-Editor)

Create .editorconfig in project root:

root = true

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

[*.py]
indent_size = 4

[*.{json,yml,yaml}]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

🚀 Quick Format Commands

Language Tool Command
Python black black file.py
Python ruff ruff format file.py
JS/TS Prettier npx prettier --write file.js
JSON jq jq '.' file.json
Markdown Prettier npx prettier --write README.md
Shell shfmt shfmt -w script.sh
Go gofmt gofmt -w file.go
Rust rustfmt rustfmt file.rs

💡 Best Practices

  1. Commit config files: .prettierrc, .eslintrc, pyproject.toml, .editorconfig
  2. Format on save: Set up your editor to auto-format
  3. Pre-commit hooks: Use pre-commit or husky to enforce
  4. Consistency: Pick one style and stick to it
  5. CI checks: Run formatters/lint in CI pipeline

Pre-commit Setup (.pre-commit-config.yaml)

repos:
  - repo: https://github.com/psf/black
    rev: 23.12.1
    hooks:
      - id: black
  - repo: https://github.com/pycqa/isort
    rev: 5.13.2
    hooks:
      - id: isort
  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v4.0.0-alpha.8
    hooks:
      - id: prettier
安全使用建议
This skill appears safe as a formatting reference. Before running its commands, confirm the target files or directories, review changes after write/fix operations, and install formatter packages only from sources you trust.
功能分析
Type: OpenClaw Skill Name: code-formatter Version: 1.0.0 The skill bundle is a documentation-only reference guide for code formatting best practices across multiple languages (Python, JavaScript, JSON, Markdown). It contains standard commands for well-known tools like Black, Prettier, and ESLint, with no executable scripts, suspicious network calls, or prompt injection attempts in SKILL.md.
能力评估
Purpose & Capability
The skill’s purpose is code formatting guidance, and the listed formatter/linter commands align with that purpose; some examples are write/fix commands that can change local code files.
Instruction Scope
Commands are presented as examples and quick references, not as automatic actions; users should be careful with broad directory targets such as src/ or docs/.
Install Mechanism
There is no skill install script or code package, but the documentation includes optional pip/npm/pre-commit setup commands for third-party formatter tools.
Credentials
No credentials, environment variables, network services, or OS-specific privileges are required by the skill itself.
Persistence & Privilege
The skill does not include background processes, hidden persistence, account access, or privilege escalation; editor format-on-save and pre-commit examples are disclosed developer workflow options.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install code-formatter
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /code-formatter 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release - Code formatting best practices for Python, JavaScript, JSON, Markdown with Prettier, Black, ESLint, ruff, and editor config
元数据
Slug code-formatter
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Code Formatter 是什么?

Code formatting best practices and quick references for Python, JavaScript, JSON, Markdown, and common languages with Prettier, Black, ESLint, and other form... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 81 次。

如何安装 Code Formatter?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install code-formatter」即可一键安装,无需额外配置。

Code Formatter 是免费的吗?

是的,Code Formatter 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Code Formatter 支持哪些平台?

Code Formatter 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Code Formatter?

由 terrycarter1985(@terrycarter1985)开发并维护,当前版本 v1.0.0。

💬 留言讨论