The Deska blog
Formatting Churn: When an Agent Touches Every Line
Learn how to prevent formatting churn when using AI coding agents. Technical strategies for managing linters, diffs, and workspace configuration.
· 10 min read
Formatting churn represents one of the most frustrating friction points in modern software development. It occurs when an automated tool or an AI agent modifies the whitespace, indentation, or stylistic structure of a file without changing its functional logic. When an agent touches every line of a source file to enforce its own preferred style, the resulting pull request becomes impossible to review. Critical logic changes disappear inside a sea of trivial updates. This behavior wastes human time and complicates the project history.
The Mechanics of Formatting Churn
AI agents like Claude Code or OpenCode operate by reading context and generating file edits. If the agent is not explicitly aware of the local project configuration, it might default to a generic style. For example, if your project uses four spaces for indentation but the agent interprets the context as two spaces, it will rewrite the entire file. This is not a failure of the agent logic but a mismatch in environmental awareness.
The consequences of this churn are significant. First, the git history becomes polluted. When you use git blame to find who authored a specific line, you see the agent name rather than the developer who wrote the logic. Second, code reviews take longer. A reviewer must filter out hundreds of lines of stylistic changes to find the three lines that actually fix a bug.
Why Agents Trigger Mass Edits
Agents often lack a persistent understanding of the local linter or formatter rules. Unlike a human developer who sees a red underline in their editor and adjusts, an agent might simply overwrite the file. There are three primary reasons this happens.
- Lack of local configuration awareness. The agent does not read the
.prettierrcor.eslintrcfile before proposing an edit. - Token optimization strategies. Some agents rewrite larger chunks of code to ensure consistency, inadvertently applying new formatting to the entire block.
- Differences in editor defaults. The agent environment may have different default settings than the developer machine.
Technical Strategies for Prevention
To stop formatting churn, you must bridge the gap between the agent and your local development standards. This involves both configuration and architectural choices in how you run your agents.
Strict Linting Integration
The most effective way to prevent churn is to make the linter an integral part of the agent loop. If the agent can run a command like npm run lint and see the output, it can correct its own formatting before you ever see the diff. You can manage this by running coding agents in an environment where they have access to the local shell.
Use of .editorconfig
An .editorconfig file is a vendor neutral way to define coding styles. Most modern tools and agents respect these settings. By defining indent_style, indent_size, and end_of_line at the root of your repository, you provide a clear signal to any tool touching your files.
Pre-commit Hooks
Using tools like Husky or lint-staged ensures that no matter what the agent produces, the code is formatted correctly before it is committed. This does not prevent the churn in the working directory, but it keeps the git history clean.
Managing Agents in a Visual Workspace
One way to monitor agent behavior is through a multi panel environment. When you run agents side by side with your code, you can see the changes in real time. This visibility allows you to catch mass formatting changes before they are saved to disk.
| Strategy | Difficulty | Effectiveness |
|---|---|---|
| .editorconfig | Low | Medium |
| Linter Panel Integration | Medium | High |
| Manual Review | High | Low |
| Pre-commit Hooks | Medium | High |
Using a tool like Deska allows you to observe these agents in an infinite canvas. Because you can place terminals and the code editor in a single view, you can watch the agent output as it happens. If you see an agent start to rewrite a 500 line file just for indentation, you can intervene immediately.
The Role of Local Context
Local-first development is a significant advantage when dealing with formatting. When the agent runs on your machine, it has direct access to your local files and environment. This is different from cloud based agents that might only see a snippet of code without the surrounding configuration files.
In a local-first setup, the agent can check the local filesystem for configuration. If the agent is running as a panel in your workspace, it shares the same environment variables and file paths as your primary editor. This shared context reduces the likelihood of style mismatches.
Reviewing Agent Changes
When an agent does cause churn, you need a way to filter the noise. Most modern diff tools have an option to ignore whitespace changes. Using git diff -w or similar flags in your browser or terminal helps focus the review on logic.
However, the best approach is to prevent the agent from touching the lines it doesn't need to change. You can explicitly instruct an agent to only modify specific functions or lines. In Ask Deska, you can use natural language to tell the assistant to perform a task without changing the existing formatting. This kind of high level control is essential for maintaining a clean codebase.
Workspace Monitoring
Monitoring your work from different locations can also help. If an agent is running a long task, you can check the progress via the mobile app. This allows you to see if the agent has started a massive, unnecessary refactor while you are away from your desk. The secure relay ensures you can stop the process before the churn reaches your main branch.
Frequently Asked Questions
How to stop AI agent from changing indentation?
You should place an .editorconfig file in your project root and ensure the agent has access to it. Additionally, you can include a prompt instruction that explicitly forbids whitespace changes. Integrating the agent into a workspace where it can run the local linter is the most robust solution.
Why does git show every line changed after agent edit?
This usually happens because the agent used a different line ending format or indentation level. Even if the text looks the same, a change from CRLF to LF or from tabs to spaces marks every line as modified. You can use git diff --ignore-all-space to verify if any logic actually changed.
Can I limit an agent to specific files?
Yes, most agent implementations allow you to define a scope. In a panel based workspace, you can provide the agent with specific file paths or open only the relevant files in the code editor. Restricting the agent to a small set of files prevents it from wandering into other parts of the repository and causing churn elsewhere.
Getting Started with a Clean Workspace
Maintaining a clean codebase requires the right tools and a disciplined approach to agentic workflows. By integrating your terminals, editors, and agents into a single environment, you gain the visibility needed to eliminate formatting churn.
Deska provides a free desktop application for Mac, Windows, and Linux that helps you manage these workflows locally. You can run multiple agents side by side and monitor their impact on your code in real time. To start building a more transparent development environment, you can download the app and set up your first infinite canvas.