agentleFS
Lukk17Lukk17/agent-standards/.agents/skills/code-formatter/SKILL.md

code-formatter

Skill1 starsChanged 56 days agoMITView on GitHub

Visual formatting and reading flow inside function bodies across Dart, Java and Python: braced control-flow exits, blank lines marking phase transitions, comments above the line they describe, doc comments sitting on their declaration, one chain step per line. Use when you say "format this function", "why is this hard to read", "clean up the spacing here", or "break this method chain up". Not for naming, error handling, or whether a comment or doc comment should exist at all, use `coding-standards`.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

Code Formatter

Formatting rules that optimise for one thing: the next reader locating a function's control-flow exits and its async phase transitions in a single scan. They deliberately diverge from what dart format, black and google-java-style produce in specific places, which each rule names.

TaskOpen
Applying or reviewing one rule, with wrong and right forms in every language it coversrules-by-language.md

When to activate

  • Writing a new source file in Dart, Java or Python
  • Editing a file already written in this style
  • Reviewing a branch or pull request and flagging readability problems

When not to activate

  • Naming, SOLID, immutability, error handling and architecture, use coding-standards
  • Deciding whether a comment or a doc comment should exist and what it says, use coding-standards
  • Language-specific idiom and typing in Java, use java-coding-standards
  • Language-specific idiom and typing in Python, use python-patterns
  • Language-specific idiom in Go, use golang-patterns
  • Auto-formatting an unrelated file the project has not adopted this style for
  • Human-facing markdown rather than source code, use markdown-writer

The rules

Each rule below has its full body, its reasoning, and its wrong-and-right forms per language in rules-by-language.md. Open that file before applying one you are unsure about.

RuleWhat it requires
Brace every inline exitA return or throw never shares a line with its if. Braced, body on its own indented line
Empty lines around try, catch and finallyA try is a control-flow landmark, so it gets a blank line before and after, and so does each clause body
Empty line above a standalone async callA hand-off to network or disk is a phase transition and reads as its own beat. Not for an await inside an assignment
Empty line above a closing returnA return ending a multi-statement block gets a blank line above it. Not for single-expression bodies
Blank line below a return inside a try with clausesThe blank line marks the seam between the happy path and the failure or cleanup clauses
Empty line above an operation-terminating callA call that ends a phase, such as a dismiss, a send, a publish or a navigation, separates from the arithmetic that set it up
Comments above the line, never trailingA trailing comment gets truncated by line length and forces horizontal scrolling
Doc comments sit on their declarationNo blank line between the block and what it documents, and no tag hard-wrapped to fit a width. Whether one exists is coding-standards
One concept per blank-separated paragraphRelated lines stay together with no blank between them, a topic change gets exactly one. Two blanks means extract a method
One chain step per lineBreak before each . in a fluent or functional pipeline, so a step can be added, removed or diffed on its own
Single-expression bodies stay on one lineThe blank-line rules govern blocks. Do not expand an arrow function or a one-line definition to satisfy them

What the rules look like together

Pass:

public Optional<Receipt> settle(Order order) {
    if (order.isEmpty()) {
        return Optional.empty();
    }

    var total = pricing.total(order);
    var payload = mapper.toPayload(order, total);

    var response = paymentClient.send(payload);

    logger.info("settled order {}", order.id());

    return Optional.of(Receipt.from(response));
}

Fail:

public Optional<Receipt> settle(Order order) {
    if (order.isEmpty()) return Optional.empty();
    var total = pricing.total(order); // price it
    var payload = mapper.toPayload(order, total);
    var response = paymentClient.send(payload);
    logger.info("settled order {}", order.id());
    return Optional.of(Receipt.from(response));
}

The failing version is what most default formatters produce and leave alone. Nothing in it is wrong to a compiler. It is harder to read because the exit, the network call and the return all sit at the same visual weight as the local arithmetic around them.


What this skill does not cover

  • Naming conventions, member ordering and import ordering, which vary per language. Use the language style guide and coding-standards
  • Line length caps, which stay readable by extracting locals rather than wrapping. Each project sets its own budget
  • Trailing commas, brace placement and indent width, which the default formatter for each language owns and this skill does not override

Related skills

  • coding-standards owns the engineering floor: SOLID, DRY, KISS, YAGNI, naming, error handling, architecture
  • java-coding-standards owns Java idiom, Lombok, Optional, streams and Javadoc discipline
  • python-patterns owns Python idiom, typing and package layout
  • golang-patterns owns Go idiom and error conventions
  • dart-flutter-patterns owns Dart and Flutter structure above the level of a function body
  • code-reviewer owns the review pass where these rules get applied to somebody else's diff

Checklist

  • No control-flow exit shares a line with its condition
  • Blank lines mark the try, the async hand-off and the terminating call as distinct beats
  • Every comment sits above the line it describes
  • Every doc comment sits directly on its declaration, with no tag wrapped onto a second line
  • No two consecutive blank lines inside a function body
  • Fluent chains break before each dot
  • Single-expression bodies were left on one line
  • The file was already in this style, or the user asked for the conversion

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.