Re: [PATCH 3/4] agents: add coding style documentation and rules

Sasha Levin
2025-07-28T05:10:27Z

On Sun, Jul 27, 2025 at 07:40:36PM -0700, Kees Cook wrote:
>On Sun, Jul 27, 2025 at 03:58:01PM -0400, Sasha Levin wrote:
>> +++ b/Documentation/agents/coding-style.rst
>
>All of this is redundant.
>
>> +**No trailing whitespaces**
>> + Never leave whitespace at the end of lines. Git will warn about patches that introduce trailing whitespace.
>
>If this isn't covered elsewhere in Documentation/, it should be. :)
>Also, "all files end with a newline"

This is a funny one. Yes, it's in the docs, but from my experiments the
tools kept "ignoring" this instruction.

I've asked around and the explanation that I got is that to manipulate
files agents call out to external tools, and often these interactions
are not perfect (if you use Claude you might have seen errors such as
"Error: Found 2 matches of the string to replace, but replace_all is
false.").

The end result is that those mis-interactions end up doing something
that the agent itself didn't intend on doing, such as adding trailing
whitespaces or having super long lines.

If we call these common issues out explicitly then the agent would also
look back at the code it generated to make sure that it doesn't actually
have any of these issues after code was edited.

>> +**80 character line limit**
>> + The preferred limit on the length of a single line is 80 columns. Statements longer than 80 columns should be broken into sensible chunks, unless exceeding 80 columns significantly increases readability and does not hide information.
>
>And this is why redundancy is bad: our line limit is 100, not 80.

Hrm, it is?

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst#n104
claims:

The preferred limit on the length of a single line is 80 columns.

Statements longer than 80 columns should be broken into sensible chunks,
unless exceeding 80 columns significantly increases readability and does
not hide information.

--
Thanks,
Sasha