Skip to content

Disable auto-formatter in OpenCode.#29247

Open
kentonv wants to merge 1 commit intoproductionfrom
kenton/opencode-no-format
Open

Disable auto-formatter in OpenCode.#29247
kentonv wants to merge 1 commit intoproductionfrom
kenton/opencode-no-format

Conversation

@kentonv
Copy link
Member

@kentonv kentonv commented Mar 23, 2026

OpenCode tries to "helpfully" run prettier after every change an agent makes.

But somehow it does it in a way that actually breaks formatting.

Here is where OpenCode actually broke the formatting of a page: #28343 (comment)

That change got merged and the formatting on that page remains broken today, a month later. Nobody noticed.

Running prettier by hand does not cause this. It's only when OpenCode runs it, for some reason.

This change disables the feature entirely because it is causing much more harm than good.

OpenCode tries to "helpfully" run prettier after every change an agent makes.

But somehow it does it in a way that actually breaks formatting.

Here is where OpenCode actually broke the formatting of a page: #28343 (comment)

That change got merged and the formatting on that page remains broken today, a month later. Nobody noticed.

Running `prettier` by hand does not cause this. It's only when OpenCode runs it, for some reason.

This change disables the feature entirely because it is causing much more harm than good.
@kentonv kentonv requested a review from elithrar March 23, 2026 22:08
@kentonv kentonv requested a review from a team as a code owner March 23, 2026 22:08
@github-actions
Copy link
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
* @cloudflare/pcx-technical-writing

@github-actions
Copy link
Contributor

@pedrosousa
Copy link
Contributor

// When you run prettier manually (not through OpenCode),
// it doesn't cause problems.

Actually, I haven't found any different behavior between what AI agents do and what VS Code/Windsurf+prettier extension does. In the functions reference we've used prettier-ignore for this kind of blocks starting with <code> to prevent prettier from touching them (it would always handle this type of content like it would handle JSX).

Are you able to correctly format MDX files such as src/content/docs/workers/runtime-apis/bindings/worker-loader.mdx locally using prettier?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants