Applies consistent code formatting across languages with prettier, black, gofmt, rustfmt, and formatter configurations.
Agentic Workflow: Read -> Reason -> Act (code-formatting)
You are code-formatting (code-quality/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — code-quality context for code-formatting
- Domain: Applies consistent code formatting across languages with prettier, black, gofmt, rustfmt, and formatter configurations.
- prettier-format: Format JS/TS/HTML/CSS/MD with Prettier. —
npx prettier --write src/
- language-formatters: Format Python, Go, and Rust. —
black src/
- Check
knowledge and prerequisites: black, cargo, gofmt, npx
2. Reason — think for code-formatting
- For
prettier-format: Format JS/TS/HTML/CSS/MD with Prettier. — decide which checks to run
- For
language-formatters: Format Python, Go, and Rust. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with code-formatting tools
- Tools:
Glob, Grep, Read, Npx, Black (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
code-formatting:672cc44f
Code Formatting
Enforce one formatting style across the repo.
When to Use
- Every codebase with more than one contributor
- Ending style arguments with config, not discussion
- Pre-commit and CI formatting gates
- Language-agnostic consistency (configs, markdown, YAML)
Commands
# Prettier (JS/TS/CSS/HTML/MD/JSON)
npx prettier --write src/
npx prettier --check src/
npx prettier --write "src/**/*.{ts,tsx}"
# Python
black src/
black --check src/
# Go
gofmt -w ./
gofmt -l .
# Rust
cargo fmt --all
rustfmt --check src/
Prettier Config
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"printWidth": 100,
"trailingComma": "all"
}
Best Practices
- Commit the formatter config at the repo root
- Use --check in CI, --write in pre-commit
- Let formatters handle style; reviewers handle logic
- Format generated files with ignore directives
- Keep formatter versions pinned to avoid churn
- Run formatting before linting for stable error lines
Capabilities
prettier-format
Format JS/TS/HTML/CSS/MD with Prettier.
Parameters:
paths (string): Files or globs
check (boolean): Verify without writing
tab-width (integer): Indent width
Commands:
npx prettier --write src/
npx prettier --check src/
npx prettier --write "src/**/*.{ts,tsx}"
npx prettier --config .prettierrc --write .
npx prettier --write --single-quote src/
Examples:
- npx prettier --check .
- npx prettier --write . --tab-width 2
- npx prettier --write --prose-wrap always README.md
language-formatters
Format Python, Go, and Rust.
Parameters:
language (string): python, go, rust
config (string): Formatter config path
Commands:
black src/
gofmt -w ./
go fmt ./...
rustfmt --check src/
cargo fmt --all
Examples:
- gofmt -l .
- rustfmt --edition 2021 src/main.rs
- cargo fmt --all -- --check
References
1---2name: "code-formatting"3description: "Applies consistent code formatting across languages with prettier, black, gofmt, rustfmt, and formatter configurations. Use when working with prettier format, language formatters, code quality or when the user mentions prettier format, language formatters, code quality."4license: "MIT"5compatibility: "Requires black, cargo, gofmt, npx, rustfmt."6metadata:7 source: https://skillmd.com/skills/opknock/code-formatting8 author: Kdesk9 version: 2.0.010 category: code-quality11allowed-tools: "Glob Grep Read Bash(black:*) Bash(cargo:*) Bash(go:*) Bash(gofmt:*) Bash(npx:*) Bash(rustfmt:*)"12---1314Applies consistent code formatting across languages with prettier, black, gofmt, rustfmt, and formatter configurations.1516## Agentic Workflow: Read -> Reason -> Act (code-formatting)1718You are **code-formatting** (code-quality/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — code-quality context for `code-formatting`21- Domain: Applies consistent code formatting across languages with prettier, black, gofmt, rustfmt, and formatter configurations.22- **prettier-format**: Format JS/TS/HTML/CSS/MD with Prettier. — `npx prettier --write src/`23- **language-formatters**: Format Python, Go, and Rust. — `black src/`24- Check `knowledge` and `prerequisites: black, cargo, gofmt, npx`2526### 2. Reason — think for `code-formatting`27- For `prettier-format`: Format JS/TS/HTML/CSS/MD with Prettier. — decide which checks to run28- For `language-formatters`: Format Python, Go, and Rust. — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `code-formatting` tools32- Tools: `Glob`, `Grep`, `Read`, `Npx`, `Black` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `code-formatting:672cc44f`3536# Code Formatting3738Enforce one formatting style across the repo.3940## When to Use4142- Every codebase with more than one contributor43- Ending style arguments with config, not discussion44- Pre-commit and CI formatting gates45- Language-agnostic consistency (configs, markdown, YAML)4647## Commands4849```bash50# Prettier (JS/TS/CSS/HTML/MD/JSON)51npx prettier --write src/52npx prettier --check src/53npx prettier --write "src/**/*.{ts,tsx}"5455# Python56black src/57black --check src/5859# Go60gofmt -w ./61gofmt -l .6263# Rust64cargo fmt --all65rustfmt --check src/66```6768## Prettier Config6970```json71{72 "semi": true,73 "singleQuote": true,74 "tabWidth": 2,75 "printWidth": 100,76 "trailingComma": "all"77}78```7980## Best Practices8182- Commit the formatter config at the repo root83- Use --check in CI, --write in pre-commit84- Let formatters handle style; reviewers handle logic85- Format generated files with ignore directives86- Keep formatter versions pinned to avoid churn87- Run formatting before linting for stable error lines8889## Capabilities9091### prettier-format92Format JS/TS/HTML/CSS/MD with Prettier.9394**Parameters:**95- `paths` (string): Files or globs96- `check` (boolean): Verify without writing97- `tab-width` (integer): Indent width9899**Commands:**100- `npx prettier --write src/`101- `npx prettier --check src/`102- `npx prettier --write "src/**/*.{ts,tsx}"`103- `npx prettier --config .prettierrc --write .`104- `npx prettier --write --single-quote src/`105106**Examples:**107- npx prettier --check .108- npx prettier --write . --tab-width 2109- npx prettier --write --prose-wrap always README.md110111### language-formatters112Format Python, Go, and Rust.113114**Parameters:**115- `language` (string): python, go, rust116- `config` (string): Formatter config path117118**Commands:**119- `black src/`120- `gofmt -w ./`121- `go fmt ./...`122- `rustfmt --check src/`123- `cargo fmt --all`124125**Examples:**126- gofmt -l .127- rustfmt --edition 2021 src/main.rs128- cargo fmt --all -- --check129130## References131- [Prettier Docs](https://prettier.io/docs/)132- [gofmt Docs](https://pkg.go.dev/cmd/gofmt)133- [Rustfmt Docs](https://rust-lang.github.io/rustfmt/)