coding-style
Skill18 starsChanged 7 months agoMITView on GitHub
Coding style guidelines for C and POSIX code, covering layout, formatting, declarations, headers, and consistency expectations.
11 other projects use a version of this.
Adopted by
Most recently taken up by
- static-web-server/static-web-servertheir own version, first seen Nov 9, 2026
- thunderstormwang/AgentSkillstheir own version, first seen Nov 6, 2026
- els0r/skillstheir own version, first seen Oct 13, 2026
- AltraMayor/f3their own version, first seen Oct 8, 2026
- quarkusio/quarkustheir own version, first seen Oct 8, 2026
- 26zl/universal-agent-skillstheir own version, first seen Oct 6, 2026
Other versions11 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 11
- quarkusio/quarkus★ 16ksame name
- AltraMayor/f3★ 3.4ksame name
- static-web-server/static-web-server★ 2.4ksame name
- codetesla51/skills★ 32same name
- RichieHakim/agent_skills★ 5same name
- 26zl/universal-agent-skills★ 2same name
- els0r/skills★ 1same name
- loboking/gemini-skills★ 1same name
- matejformanek/postgres-claude★ 1same name
- gray-matter/skills★ 0same name
1 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository2 other files it gives its agents.
- bitreich-manifestoSkill
- philosophySkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
30 rules. 0 are common, 17 are distinctive, and 13 are very specific to this project.
0
Common
Most of the 11 edited versions we read keep these.
17
Distinctive
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 41
Use C99 without extensions (ISO/IEC 9899:1999).
- Very specific: line 43
When using gcc define _POSIX_C_SOURCE 200809L.
- Distinctive: line 45
Do not mix declarations and code.
- Distinctive: line 46
Do not use for loop initial declarations.
- Very specific: line 47
Use /* */ for comments, not //.
- Distinctive: line 55
All variable declarations at top of block.
- Distinctive: line 59
Use block for single statement if inner statement needs a block.
- Distinctive: line 68
Use block if another branch of the same statement needs a block:
- Distinctive: line 80
Use tabs for indentation and spaces for alignment.
- Distinctive: line 83
No tabs except beginning of line.
- Very specific: line 84
Use spaces - not tabs - for multiline macros as the indentation level is 0, where the #define began.
- Very specific: line 115
Use a space after if, for, while, switch (they are not function calls).
- Very specific: line 116
Do not use a space after the opening ( and before the closing ).
- Very specific: line 118
Do not use a space with sizeof().
- Distinctive: line 123
Do not indent cases another level.
- Distinctive: line 140
Place system/libc headers first in alphabetical order.
- Distinctive: line 141
If headers must be included in a specific order add a comment to explain.
- Distinctive: line 142
Place local headers after an empty line.
- Distinctive: line 143
When writing and using local headers.
- Distinctive: line 145
Instead ensure they are included where and when they are needed.
- Very specific: line 146
Read <https://talks.golang.org/2012/splash.article#TOC_5.>
- Very specific: line 147
Read <http://plan9.io/sys/doc/comp.html>
- Very specific: line 152
Do not use type_t naming (it is reserved for POSIX and less readable).
- Distinctive: line 154
Do not typedef builtin types.
- Very specific: line 155
Use CamelCase for typedef'd types.
- Distinctive: line 160
Keep lines to reasonable length (max 79 characters).
- Very specific: line 165
Do not use C99 bool types (stick to integer types).
- Very specific: line 174
When functions return -1 for error test against 0 not -1:
- Very specific: line 179
Use goto to unwind and cleanup when necessary instead of multiple nested levels.
- Distinctive: line 190
Use enums for values that are grouped semantically and #define otherwise:
“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Style
Note that the following are guidelines and the most important aspect of style is consistency. Strive to keep your style consistent with the project on which you are working. It is up to the project maintainer to take some liberty in the style guidelines.
Recommended Reading
The following contain good information, some of which is repeated below, some of which is contradicted below.
- https://man.openbsd.org/style
- http://doc.cat-v.org/bell_labs/pikestyle
- https://www.kernel.org/doc/Documentation/process/coding-style.rst
File Layout
- Comment with LICENSE and possibly short explanation of file/tool.
- Headers
- Macros
- Types
- Function declarations:
- Include variable names.
- For short files these can be left out.
- Group/order in logical manner.
- Global variables.
- Function definitions in same order as declarations.
main
C Features
- Use C99 without extensions (ISO/IEC 9899:1999).
- Use POSIX.1-2008:
- When using gcc define
_POSIX_C_SOURCE 200809L. - Alternatively define
_XOPEN_SOURCE 700.
- When using gcc define
- Do not mix declarations and code.
- Do not use for loop initial declarations.
- Use
/* */for comments, not//. - Variadic macros are acceptable, but remember:
__VA_ARGS__not a named parameter.- Arg list cannot be empty.
Blocks
- All variable declarations at top of block.
{on same line preceded by single space (except functions).}on own line unless continuing statement (if else,do while, ...).
Use block for single statement if inner statement needs a block.
for (;;) {
if (foo) {
bar;
baz;
}
}Use block if another branch of the same statement needs a block:
if (foo) {
bar;
} else {
baz;
qux;
}Leading Whitespace
Use tabs for indentation and spaces for alignment. This ensures everything will line up independent of tab size. This means:
- No tabs except beginning of line.
- Use spaces - not tabs - for multiline macros as the indentation level is 0,
where the
#definebegan.
Functions
- Return type and modifiers on own line.
- Function name and argument list on next line. This allows to grep for function
names simply using
grep ^functionname(. - Opening
{on own line (function definitions are a special case of blocks as they cannot be nested). - Functions not used outside translation unit should be declared and defined
static.
Example:
static void
usage(void)
{
eprintf("usage: %s [file ...]\n", argv0);
}Variables
- Global variables not used outside translation unit should be declared
static. - In declaration of pointers the
*is adjacent to variable name, not type.
Keywords
- Use a space after
if,for,while,switch(they are not function calls). - Do not use a space after the opening
(and before the closing). - Preferably use
()withsizeof. - Do not use a space with
sizeof().
Switch
- Do not indent cases another level.
- Comment cases that FALLTHROUGH.
Example:
switch (value) {
case 0: /* FALLTHROUGH */
case 1:
case 2:
break;
default:
break;
}Headers
- Place system/libc headers first in alphabetical order.
- If headers must be included in a specific order add a comment to explain.
- Place local headers after an empty line.
- When writing and using local headers.
- Try to avoid cyclic header inclusion dependencies.
- Instead ensure they are included where and when they are needed.
- Read https://talks.golang.org/2012/splash.article#TOC_5.
- Read http://plan9.io/sys/doc/comp.html
User Defined Types
- Do not use
type_tnaming (it is reserved for POSIX and less readable). - Typedef opaque structs.
- Do not typedef builtin types.
- Use
CamelCasefor typedef'd types.
Line Length
- Keep lines to reasonable length (max 79 characters).
Tests and Boolean Values
- Do not use C99
booltypes (stick to integer types). Otherwise use compound assignment and tests unless the line grows too long:
if (!(p = malloc(sizeof(*p)))) hcf();
Handling Errors
When functions
return -1for error test against0not-1:if (func() < 0) hcf();
- Use
gototo unwind and cleanup when necessary instead of multiple nested levels. returnorexitearly on failures instead of multiple nested levels.- Unreachable code should have a NOTREACHED comment.
- Think long and hard on whether or not you should cleanup on fatal errors. For simple "one-shot" programs (not daemons) it can be OK to not free memory. It is advised to cleanup temporary files however.
Enums and #define
Use enums for values that are grouped semantically and #define otherwise:
#define MAXSZ 4096
#define MAGIC1 0xdeadbeef
enum {
DIRECTION_X,
DIRECTION_Y,
DIRECTION_Z
};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
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.

