agentleFS
MaJerleMaJerle/c-code-style/AGENTS.md

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

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the MaJerle/c-code-style repository that our weekly crawl found: only 6 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about MaJerle/c-code-style

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

1 more on GitHub
  • 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.

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
  1. Very specific:

    Read CODING_RULES.md before writing code — it is the authoritative, complete rule set.

    line 9
  2. Very specific:

    Don't rely on static initializers for global/static variables needing a real startup value in embedded contexts — add a module init() …

    line 33
  3. Distinctive:

    All locals declared at the top of a block, grouped by type, ordered: structs/enums (and pointers) → integers (widest unsigned first) → …

    line 35
  4. Very specific:

    Every zero-parameter function uses (void), never empty ().

    line 40
  5. Very specific:

    Check pointers against NULL before dereferencing (unless provably non-NULL by construction).

    line 44
  6. Very specific:

    After editing any .c/.h file, run:

    line 57

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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). static module-private functions get a prv_ prefix.
  • stdint.h types except char/float/double; avoid stdbool.h (use 1/0).
  • Don't rely on static initializers for global/static variables needing a real startup value in embedded contexts — add a module init() 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 are void*, cast internally, never cast away a void* return value.
  • Every zero-parameter function uses (void), never empty ().
  • At most 2 return points per function: one early return for parameter/argument validation, one at the end. No return in the middle — use a return-value variable instead.
  • Check pointers against NULL before dereferencing (unless provably non-NULL by construction). Set a pointer to NULL immediately after free().
  • Boolean-treated variables: if (x) / if (!x), never == 1/== 0. Counter/value variables: > 0 / == 0, never bare if (x).
  • Doxygen on every function (including static): \brief, \param[in] / \param[out] per parameter, \return if non-void. Written at the function's definition (the .c file body), never duplicated at the header declaration. Description text aligned to column 22 (match template.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).

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.