c-code-style
AGENTS.md1.4k starsChanged 4 months agoMITView on GitHub
This repository defines a C coding style. If you (an AI coding agent) are writing, editing, or reviewing .c/.h files in a project that adopts this style guide, follow this file. Read CODING_RULES.md before writing code — it is the authoritative, complete rule set. Do not assume "typical" C conventions; several rules here are deliberately non-default (e.g. (void) required on zero-parameter functions, at most 2 return points per function, stdbool.h avoided, 3-character minimum name length). template.c and template.h are worked,…
Trending
Quiet this year.thin dataabout the whole repository
Who's talking about MaJerle/c-code-style
- lwvmobile/dsd-fme“Refactor: Modular RTL‑SDR FM pipeline with unified device control, accurate rate chain, and cooperative …”GitHub · Sep 11, 2025
- DavitMelikyan/Homework“Consistent C Coding Style”GitHub · Mar 24, 2025
- sw33tdreams/C_projects“Consistent C Coding Style”GitHub · Mar 22, 2025
- DavitMelikyan/Homework“Consistent C Coding Style”GitHub · Mar 22, 2025
- Gevorg-Mkrtchyan7/Control-Structures“Consistent C Coding Style”GitHub · Mar 22, 2025
The biggest 5 of 6 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 6
Talked about on GitHub (6 times).
On GitHub · 6
- Sep 11, 2025Refactor: Modular RTL‑SDR FM pipeline with unified device control, accurate rate chain, and cooperative retune/shutdown. Attempts to fix NXDN demodulation. — lwvmobile/dsd-fme0 reactions · 1 comment
- Mar 24, 2025Consistent C Coding Style — DavitMelikyan/Homework0 reactions
- Mar 22, 2025Consistent C Coding Style — sw33tdreams/C_projects0 reactions
- Mar 22, 2025Consistent C Coding Style — DavitMelikyan/Homework0 reactions
- Mar 22, 2025Consistent C Coding Style — Gevorg-Mkrtchyan7/Control-Structures0 reactions · 1 comment
1 more on GitHub
- Sep 14, 2022applied source code format from https://github.com/MaJerle/c-code-style — bontango/lisy-src-5.x0 reactions
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- c-code-styleSkill
The file
We split this AGENTS.md into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 9
Read CODING_RULES.md before writing code — it is the authoritative, complete rule set.
- Very specific: line 33
Don't rely on static initializers for global/static variables needing a real startup value in embedded contexts — add a module init() …
- Distinctive: line 35
All locals declared at the top of a block, grouped by type, ordered: structs/enums (and pointers) → integers (widest unsigned first) → …
- Very specific: line 40
Every zero-parameter function uses (void), never empty ().
- Very specific: line 44
Check pointers against NULL before dereferencing (unless provably non-NULL by construction).
- Very specific: line 57
After editing any .c/.h file, run:
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent instructions
This repository defines a C coding style. If you (an AI coding agent) are
writing, editing, or reviewing .c/.h files in a project that adopts this
style guide, follow this file.
Source of truth
Read CODING_RULES.md before writing code — it is the authoritative,
complete rule set. Do not assume "typical" C conventions; several rules here
are deliberately non-default (e.g. (void) required on zero-parameter
functions, at most 2 return points per function, stdbool.h avoided,
3-character minimum name length). template.c and template.h are
worked, clang-format-verified reference examples — match their formatting
and doxygen alignment exactly.
What the formatter fixes for you
clang-format (this repo ships .clang-format) handles indentation,
spacing, brace placement, pointer-asterisk alignment, function-prototype
alignment, and trailing commas in struct initializers. Don't hand-format
these — write reasonably and run the formatter afterward (see below).
What you must apply yourself while writing
A formatter cannot infer these; apply them as you write, not after:
- Names (variables, parameters, struct/enum members): lowercase, underscore
word-separated, at least 3 characters. No
__/_prefix (reserved).staticmodule-private functions get aprv_prefix. stdint.htypes exceptchar/float/double; avoidstdbool.h(use1/0).- Don't rely on static initializers for
global/staticvariables needing a real startup value in embedded contexts — add a moduleinit()function. - All locals declared at the top of a block, grouped by type, ordered: structs/enums (and pointers) → integers (widest unsigned first) → floating point.
const-correct pointers/parameters; generic pointers arevoid*, cast internally, never cast away avoid*return value.- Every zero-parameter function uses
(void), never empty(). - At most 2
returnpoints per function: one early return for parameter/argument validation, one at the end. Noreturnin the middle — use a return-value variable instead. - Check pointers against
NULLbefore dereferencing (unless provably non-NULLby construction). Set a pointer toNULLimmediately afterfree(). - Boolean-treated variables:
if (x)/if (!x), never== 1/== 0. Counter/value variables:> 0/== 0, never bareif (x). - Doxygen on every function (including
static):\brief,\param[in]/\param[out]per parameter,\returnif non-void. Written at the function's definition (the.cfile body), never duplicated at the header declaration. Description text aligned to column 22 (matchtemplate.c). Backtick any identifier/constant/literal in prose.
Format and verify
After editing any .c/.h file, run:
scripts/check-format.sh <changed-file.c> [<changed-file.h> ...]It checks clang-format is installed (>= version 20; prints the right
install command for your OS and exits non-zero if not, or if too old), then
runs clang-format -i using this repo's .clang-format.
To verify without writing changes:
scripts/check-format.sh --check <file.c> [<file.h> ...]Exits 0 if compliant, non-zero with the specific violations otherwise. This
script and flow were verified directly in this repository (missing-tool path,
detect → fix → re-verify round trip, and both template files passing
--check as-is).
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.

