← All tools

Code Engineering

Format

Run a code formatter; auto-detects prettier / black / ruff format / gofmt / cargo fmt / rubocop / spotless.

format

Overview

Companion to lint. Lint flags semantic problems; format normalises whitespace, quoting, and line length per the repo's chosen style.

How it works

Detection: .prettierrc* → prettier · pyproject.toml [tool.black] → black · pyproject.toml [tool.ruff.format] → ruff format · go.mod → gofmt · Cargo.toml → cargo fmt · .rubocop.yml → rubocop · pom.xml → spotless.

Example

When a user asks:

Would any files change if I ran the formatter?

the agent calls the tool:

format()

and gets back: prettier: 3 files would change — src/api/handlers.ts, src/api/router.ts, src/utils/dates.ts

What it's good for

Real scenarios where agents put this tool to work.

Pre-commit normalisation
CI-style format gate the agent runs before opening a PR

Source

Implementation lives at swarmai-tools/src/main/java/ai/intelliswarm/swarmai/tool/code/build/FormatterTool.java in the swarm-ai repository.

Open format on GitHub →