clean-code-formatting

Installation
SKILL.md

Formatting

Formatting is communication, and communication is a professional developer's first job. Working code changes over time, but the style and discipline of its layout outlive any particular version. Treat formatting as important, but not religiously.

First: team rules win

If the project has a formatter or linter (Prettier, Black, gofmt, rustfmt, clang-format, ESLint and so on) or a style guide, follow it. Don't hand-format against it. Consistency across a codebase beats any individual's preference. A team should agree on one style and automate it. The guidance below covers what formatters don't decide: ordering, grouping, blank lines and file size.

Vertical formatting

File size. Smaller files are easier to understand. Well-maintained projects routinely keep most files in the low hundreds of lines. Treat a file in the thousands of lines as a strong signal that it needs splitting.

Newspaper metaphor. A file should read like a news article. Its name is the headline, and it should be enough to tell whether you're in the right place. The top gives the high-level concepts and algorithms. Detail increases as you go down, with the lowest-level helpers at the bottom.

Vertical openness. Separate distinct thoughts with blank lines: between imports and code, between functions, and between logical groups within a function (though too many groups inside a function is itself a smell).

Vertical density. Keep lines that belong together tight. Don't break up closely related declarations with blank lines or noise comments.

Installs
1
First Seen
2 days ago