agentleFS
iliaaliliaal/ai-skills/skills/c-systems/SKILL.md

c-systems

Skill43 starsChanged 2 months agoMITView on GitHub

C patterns for systems code, libraries, and native extensions: module layout, function decomposition, status-enum errors, memory safety, undefined behavior, and performance measurement. Use when writing, reviewing, refactoring, or debugging C, working with malloc lifetimes, buffer overflows, sanitizers, or Valgrind, or building native extensions. For C++, see ia-cpp-systems.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 6 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Verify the actual rebuilt artifact.

    line 24
  2. Very specific:

    Read the repo's AGENTS.md/CLAUDE.md, its public headers, and two adjacent .c files before writing anything.

    line 28
  3. Distinctive:

    Do not skip this gate. Established C codebases sanction idioms these rules would otherwise flag:

    line 30
  4. Distinctive:

    Never widen a scoped task into a repo-wide restyle because adjacent untouched C predates a rule here.

    line 39
  5. Very specific:

    Test suite passes under -fsanitize=address,undefined with zero reports

    line 47
  6. Distinctive:

    Every new fallible call site checked.

    line 49
  7. Distinctive:

    Every new state-mutating leaf carries an assert

    line 50
  8. Very specific:

    No new goto outside the repo's sanctioned form or the single-forward-jump cleanup.

    line 51
  9. Distinctive:

    Read the relevant reference before implementing or reviewing the matching behavior:

    line 55

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill 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
SKILL.md

C Systems & Native Code

Covers C11 and later for libraries, systems code, and native extensions. For C++ (RAII, templates, move semantics), see the ia-cpp-systems skill.

Working rules

  • Preserve the repository's sanctioned idioms and ABI; do not turn a scoped fix into a restyle.
  • State ownership, check fallible calls, validate public boundaries, and assert internal invariants.
  • Bound traversal of external input and check sizes before allocation or narrowing.
  • Choose helpers only when they name a concept, own an error, or isolate a side effect.
  • Verify the actual rebuilt artifact; use instrumented tests for safety and representative release builds for performance.

Repo conventions outrank this skill

Read the repo's AGENTS.md/CLAUDE.md, its public headers, and two adjacent .c files before writing anything. Where they conflict with the rules below, they win, and the diff carries no note about it.

Do not skip this gate. Established C codebases sanction idioms these rules would otherwise flag:

Local idiomWhere it is correct
Tab indentationphp-src and its extensions, Linux kernel
goto cleanup / goto errKernel, OpenSSL, curl, php-src: the dominant multi-resource release idiom
Macros containing returnRETURN_*/RETVAL_* in PHP extensions, Py_RETURN_* in CPython
Project status typeszend_result, CURLcode, int plus errno: do not invent a parallel enum beside one

Never widen a scoped task into a repo-wide restyle because adjacent untouched C predates a rule here.

When the target is a PHP extension (php_*.h, PHP_FUNCTION, zend_, config.m4), load php-extension-c.md before applying any rule below. Layout, macros, the error model, memory, and assertions all carry extension-specific overrides, and the memory one in particular inverts the base guidance: extensions use a request-scoped allocator, not malloc/free.

Verify

  • Build passes under the repo's warning profile with zero newly introduced warnings (greenfield: the full -Wall -Wextra -Werror -Wconversion -Wshadow bundle, zero warnings)
  • Test suite passes under -fsanitize=address,undefined with zero reports
  • valgrind --leak-check=full --error-exitcode=1 clean where the suite links under it
  • Every new fallible call site checked; every new error value traced to one producer
  • Every new state-mutating leaf carries an assert
  • No new goto outside the repo's sanctioned form or the single-forward-jump cleanup; no recursion over external input; no loop over external input without a named bound

Task-specific references

Read the relevant reference before implementing or reviewing the matching behavior:

  • For module layout, naming, decomposition, control flow, errors, types, or macros: implementation-structure.md.
  • For memory, external input, assertions, ABI changes, or shared-helper contracts: runtime-safety.md.
  • For compiler setup, tests, build provenance, packaging, or performance claims: build-and-measurement.md.

Existing specialized references, when the corresponding topic applies:

  • php-extension-c.md.
  • memory-safety.md.
  • correctness-traps.md.
  • legibility-standard.md.

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.