Search⌘ K
AI Features

Formatters and Agent Skills

Explore how OpenCode integrates automatic code formatting to keep your project consistent and agent skills to teach specialized workflows. Understand how to configure formatters for different languages, write reusable skills to guide OpenCode, and manage access permissions. This lesson helps you improve code quality and streamline AI collaboration by combining formatting tools and knowledge-driven agent skills.

We’ve learned how to configure OpenCode to work with different models, create custom tools, and write commands. Next, we’ll look at two features that help OpenCode fit into your workflow:

  • Automatic code formatting

  • Reusable agent skills

These features work differently but serve a similar purpose, as they help OpenCode work the way we do. Formatters ensure generated code matches our style automatically. Skills give OpenCode access to specialized knowledge we’ve encoded for specific tasks.

What are formatters and why do we need them?

Formatters automatically clean up code formatting after OpenCode writes or edits files. This ensures the generated code follows our project’s style conventions without manual cleanup.

Every project has formatting preferences. Some teams use tabs, others use spaces. Some prefer single quotes, others prefer double quotes. Without formatters, OpenCode’s output might not match our existing code style, leading to inconsistencies.

OpenCode solves this by detecting which formatters our project uses and applying them automatically after every file operation. We never need to manually format OpenCode’s output, as it happens in the background.

How do formatters work?

When OpenCode writes or edits a file, it follows this process:

  1. Check the file extension against all enabled formatters.

  2. Run the appropriate formatter command on the file.

  3. Apply formatting changes automatically.

This runs immediately after a file is written, before OpenCode finishes the operation. As a result, every file OpenCode modifies is formatted according to the project’s rules.

What formatters are built in?

...